diff --git a/core/js/js.js b/core/js/js.js index 38b9759043..80cd0104fe 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -175,9 +175,13 @@ var OC={ PERMISSION_DELETE:8, PERMISSION_SHARE:16, PERMISSION_ALL:31, + /* jshint camelcase: false */ webroot:oc_webroot, appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, + config: oc_config, + appConfig: oc_appconfig || {}, + theme: oc_defaults || {}, coreApps:['', 'admin','log','search','settings','core','3rdparty'], /** diff --git a/core/js/update.js b/core/js/update.js index b1b7f6e37e..abf2d6ae6d 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -1,26 +1,84 @@ -$(document).ready(function () { - var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); - updateEventSource.listen('success', function(message) { - $('').append(message).append('
').appendTo($('.update')); - }); - updateEventSource.listen('error', function(message) { - $('').addClass('error').append(message).append('
').appendTo($('.update')); - message = t('core', 'Please reload the page.'); - $('').addClass('error').append(message).append('
').appendTo($('.update')); - updateEventSource.close(); - }); - updateEventSource.listen('failure', function(message) { - $('').addClass('error').append(message).append('
').appendTo($('.update')); - $('') - .addClass('error bold') - .append('
') - .append(t('core', 'The update was unsuccessful. Please report this issue to the ownCloud community.')) - .appendTo($('.update')); - }); - updateEventSource.listen('done', function(message) { - $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update')); - setTimeout(function () { - window.location.href = OC.webroot; - }, 3000); +/* + * Copyright (c) 2014 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + OC.Update = { + _started : false, + + /** + * Start the upgrade process. + * + * @param $el progress list element + */ + start: function($el) { + var self = this; + if (this._started) { + return; + } + + this.$el = $el; + + this._started = true; + this.addMessage(t( + 'core', + 'Updating {productName} to version {version}, this may take a while.', { + productName: OC.theme.name, + version: OC.config.versionstring + }), + 'bold' + ).append('
'); // FIXME: these should be ul/li with CSS paddings! + + var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); + updateEventSource.listen('success', function(message) { + $('').append(message).append('
').appendTo($el); + }); + updateEventSource.listen('error', function(message) { + $('').addClass('error').append(message).append('
').appendTo($el); + message = t('core', 'Please reload the page.'); + $('').addClass('error').append(message).append('
').appendTo($el); + updateEventSource.close(); + }); + updateEventSource.listen('failure', function(message) { + $('').addClass('error').append(message).append('
').appendTo($el); + $('') + .addClass('error bold') + .append('
') + .append(t('core', 'The update was unsuccessful.' + + 'Please report this issue to the ownCloud community.')) + .appendTo($el); + }); + updateEventSource.listen('done', function(message) { + // FIXME: use product name + $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($el); + setTimeout(function () { + OC.redirect(OC.webroot); + }, 3000); + }); + }, + + addMessage: function(message, className) { + var $span = $(''); + $span.addClass(className).append(message).append('
').appendTo(this.$el); + return $span; + } + }; + +})(); + +$(document).ready(function() { + $('.updateForm').on('submit', function(ev) { + ev.preventDefault(); + var $progressEl = $('.updateProgress'); + $progressEl.removeClass('hidden'); + $('.updateForm').addClass('hidden'); + OC.Update.start($progressEl); + return false; }); }); diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index a652d5f195..0b1ae7854d 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -1,6 +1,32 @@ -
    -
  • - t('Updating ownCloud to version %s, this may take a while.', - array($_['version']))); ?>

    -
  • -
+
+
+

+ t('%s will be updated to version %s.', + array($_['productName'], $_['version']))); ?> +

+ +
+
t('The following apps will be disabled during the upgrade:')) ?>
+
    + +
  • + +
+
+ + +
+
t('The theme %s has been disabled.', array($_['oldTheme']))) ?>
+
+ +
+
t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?>
+
+
+ +
+
+ + +
diff --git a/lib/base.php b/lib/base.php index a022b9d005..455e8ad461 100644 --- a/lib/base.php +++ b/lib/base.php @@ -284,11 +284,26 @@ class OC { public static function checkUpgrade($showTemplate = true) { if (self::needUpgrade()) { if ($showTemplate && !OC_Config::getValue('maintenance', false)) { + $version = OC_Util::getVersion(); + $oldTheme = OC_Config::getValue('theme'); OC_Config::setValue('theme', ''); OC_Util::addScript('config'); // needed for web root OC_Util::addScript('update'); $tmpl = new OC_Template('', 'update.admin', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); + + // get third party apps + $apps = OC_App::getEnabledApps(); + $incompatibleApps = array(); + foreach ($apps as $appId) { + $info = OC_App::getAppInfo($appId); + if(!OC_App::isAppCompatible($version, $info)) { + $incompatibleApps[] = $info['name']; + } + } + $tmpl->assign('appList', $incompatibleApps); + $tmpl->assign('productName', 'ownCloud'); // for now + $tmpl->assign('oldTheme', $oldTheme); $tmpl->printPage(); exit(); } else {