*/
_container: null,
+ /**
+ * dialog overlay
+ * @var jQuery
+ */
+ _dialog: null,
+
/**
* package input field
* @var jQuery
*/
_searchID: 0,
+ /**
+ * currently selected package
+ * @var string
+ */
+ _selectedPackage: '',
+
+ /**
+ * currently selected package's version
+ */
+ _selectedPackageVersion: '',
+
/**
* Initializes the WCF.ACP.Package.Seach class.
*/
this._button = null;
this._cache = { };
this._container = $('#packageSearch');
+ this._dialog = null;
this._package = null;
this._packageName = null;
this._packageSearchResultContainer = $('#packageSearchResultContainer');
this._pageNo = 1;
this._searchDescription = null;
this._searchID = 0;
+ this._selectedPackage = '';
+ this._selectedPackageVersion = '';
this._proxy = new WCF.Action.Proxy({
success: $.proxy(this._success, this)
this._insertTemplate(data.returnValues.template);
break;
+ case 'prepareInstallation':
+ if (data.returnValues.queueID) {
+ if (this._dialog !== null) {
+ this._dialog.wcfDialog('close');
+ }
+
+ var $installation = new WCF.ACP.Package.Installation(data.returnValues.queueID, undefined, false);
+ $installation.prepareInstallation();
+ }
+ else if (data.returnValues.template) {
+ if (this._dialog === null) {
+ this._dialog = $('<div>' + data.returnValues.template + '</div>').hide().appendTo(document.body);
+ this._dialog.wcfDialog({
+ title: WCF.Language.get('wcf.acp.package.update.unauthorized')
+ });
+ }
+ else {
+ this._dialog.html(data.returnValues.template).wcfDialog('open');
+ }
+
+ this._dialog.find('.formSubmit > button').click($.proxy(this._submitAuthentication, this));
+ }
+ break;
+
case 'search':
this._pageCount = data.returnValues.pageCount;
this._searchID = data.returnValues.searchID;
}
},
+ /**
+ * Submits authentication data for current update server.
+ *
+ * @param object event
+ */
+ _submitAuthentication: function(event) {
+ var $usernameField = $('#packageUpdateServerUsername');
+ var $passwordField = $('#packageUpdateServerPassword');
+
+ // remove error messages if any
+ $usernameField.next('small.innerError').remove();
+ $passwordField.next('small.innerError').remove();
+
+ var $continue = true;
+ if ($.trim($usernameField.val()) === '') {
+ $('<small class="innerError">' + WCF.Language.get('wcf.global.form.error.empty') + '</small>').insertAfter($usernameField);
+ $continue = false;
+ }
+
+ if ($.trim($passwordField.val()) === '') {
+ $('<small class="innerError">' + WCF.Language.get('wcf.global.form.error.empty') + '</small>').insertAfter($passwordField);
+ $continue = false;
+ }
+
+ if ($continue) {
+ this._prepareInstallation($(event.currentTarget).data('packageUpdateServerID'));
+ }
+ },
+
/**
* Inserts search result list template.
*
// update badge count
if (count !== undefined) {
this._content = { 1: template };
- this._packageSearchResultContainer.find('> header > h1 > .badge').html(count);
+ this._packageSearchResultContainer.find('> header > h2 > .badge').html(count);
}
+
+ // bind listener
+ this._packageSearchResultList.find('.jsInstallPackage').click($.proxy(this._click, this));
+ },
+
+ /**
+ * Prepares a package installation.
+ *
+ * @param object event
+ */
+ _click: function(event) {
+ var $button = $(event.currentTarget);
+ WCF.System.Confirmation.show($button.data('confirmMessage'), $.proxy(function(action) {
+ if (action === 'confirm') {
+ this._selectedPackage = $button.data('package');
+ this._selectedPackageVersion = $button.data('packageVersion');
+ this._prepareInstallation();
+ }
+ }, this));
+ },
+
+ /**
+ * Prepares package installation.
+ *
+ * @param integer packageUpdateServerID
+ */
+ _prepareInstallation: function(packageUpdateServerID) {
+ var $parameters = {
+ 'package': { }
+ };
+ $parameters['package'][this._selectedPackage] = this._selectedPackageVersion;
+
+ if (packageUpdateServerID) {
+ $parameters.authData = {
+ packageUpdateServerID: packageUpdateServerID,
+ password: $.trim($('#packageUpdateServerPassword').val()),
+ saveCredentials: ($('#packageUpdateServerSaveCredentials:checked').length ? true : false),
+ username: $.trim($('#packageUpdateServerUsername').val())
+ };
+ }
+
+ this._proxy.setOption('data', {
+ actionName: 'prepareInstallation',
+ className: 'wcf\\data\\package\\update\\PackageUpdateAction',
+ parameters: $parameters
+ });
+ this._proxy.sendRequest();
},
/**
this._packageSearchResultContainer.find('.pageNavigation').wcfPages('destroy').remove();
if (this._pageCount > 1) {
- var $topNavigation = $('<div class="contentNavigation" />').insertBefore(this._packageSearchResultList).wcfPages({
+ $('<div class="contentNavigation" />').insertBefore(this._packageSearchResultList).wcfPages({
activePage: this._pageNo,
maxPage: this._pageCount
}).bind('wcfpagesswitched', $.proxy(this._showPage, this));
- var $bottomNavigation = $('<div class="contentNavigation" />').insertAfter(this._packageSearchResultList).wcfPages({
+ $('<div class="contentNavigation" />').insertAfter(this._packageSearchResultList).wcfPages({
activePage: this._pageNo,
maxPage: this._pageCount
}).bind('wcfpagesswitched', $.proxy(this._showPage, this));
password: $.trim($('#packageUpdateServerPassword').val()),
saveCredentials: ($('#packageUpdateServerSaveCredentials:checked').length ? true : false),
username: $.trim($('#packageUpdateServerUsername').val())
- }
+ };
}
this._proxy.setOption('data', {
if (!empty($this->parameters['packageName'])) {
$conditions->add("package_update.packageName LIKE ?", array('%'.$this->parameters['packageName'].'%'));
}
+ $conditions->add("package.packageID IS NULL");
// find matching packages
$sql = "SELECT package_update.packageUpdateID
FROM wcf".WCF_N."_package_update package_update
+ LEFT JOIN wcf".WCF_N."_package package
+ ON (package.package = package_update.package)
".$conditions."
ORDER BY package_update.packageName ASC";
$statement = WCF::getDB()->prepareStatement($sql, 1000);
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("packageUpdateID IN (?)", array(array_keys($updateData)));
- $sql = "SELECT packageUpdateID, packageName, packageDescription, author, authorURL
+ $sql = "SELECT *
FROM wcf".WCF_N."_package_update
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
* @return array
*/
public function prepareUpdate() {
+ return $this->createQueue('update');
+ }
+
+ /**
+ * Validates parameters to prepare a package installation.
+ */
+ public function validatePrepareInstallation() {
+ WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
+
+ $this->readString('package');
+
+ if (isset($this->parameters['authData'])) {
+ if (!is_array($this->parameters['authData'])) {
+ throw new UserInputException('authData');
+ }
+
+ $this->readInteger('packageUpdateServerID', false, 'authData');
+ $this->readString('password', false, 'authData');
+ $this->readString('username', false, 'authData');
+ $this->readBoolean('saveCredentials', true, 'authData');
+ }
+ }
+
+ /**
+ * Prepares a package installation.
+ *
+ * @return array
+ */
+ public function prepareInstallation() {
+ return $this->createQueue('install');
+ }
+
+ /**
+ * Creates a new package installation queue.
+ *
+ * @param string $queueType
+ * @return array
+ */
+ protected function createQueue($queueType) {
if (isset($this->parameters['authData'])) {
PackageUpdateServer::storeAuthData($this->parameters['authData']['packageUpdateServerID'], $this->parameters['authData']['username'], $this->parameters['authData']['password'], $this->parameters['authData']['saveCredentials']);
}
- $scheduler = new PackageInstallationScheduler($this->parameters['packages']);
+ $scheduler = new PackageInstallationScheduler($this->parameters['package']);
try {
$scheduler->buildPackageInstallationStack();
'packageName' => $package['packageName'],
'packageID' => ($package['packageID'] ?: null),
'archive' => $package['archive'],
- 'action' => 'update'
+ 'action' => $queueType
));
$parentQueueID = $queue->queueID;
-
+
if ($queueID === null) {
$queueID = $queue->queueID;
}