From 7f49d359306cbcd3303fcdd7feb0e6931ecffd8d Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 19:15:02 +0100 Subject: [PATCH 1/2] Move checkMaintenance and checkUpgrade This is needed to ensure that the routing and linkTo() function for CSP are available. --- lib/base.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index f1a60a1773..81a5a615de 100644 --- a/lib/base.php +++ b/lib/base.php @@ -422,8 +422,6 @@ class OC self::checkSSL(); self::initSession(); self::initTemplateEngine(); - self::checkMaintenanceMode(); - self::checkUpgrade(); $errors = OC_Util::checkServer(); if (count($errors) > 0) { @@ -563,10 +561,13 @@ class OC return; } + // Check if ownCloud is installed or in maintenance (update) mode if (!OC_Config::getValue('installed', false)) { require_once 'core/setup.php'; exit(); } + self::checkMaintenanceMode(); + self::checkUpgrade(); // Handle redirect URL for logged in users if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) { From dbc13cf6ee775745c86f92d97d636f9ed3cf5432 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 19:18:16 +0100 Subject: [PATCH 2/2] Move update inline JS --- core/js/update.js | 24 ++++++++++++++++++++++++ core/templates/update.php | 28 +--------------------------- lib/base.php | 1 + 3 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 core/js/update.js diff --git a/core/js/update.js b/core/js/update.js new file mode 100644 index 0000000000..c10aa013e6 --- /dev/null +++ b/core/js/update.js @@ -0,0 +1,24 @@ +$(document).ready(function () { + OC.EventSource.requesttoken = oc_requesttoken; + 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')); + }); + 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); + }); +}); \ No newline at end of file diff --git a/core/templates/update.php b/core/templates/update.php index c9f3144f25..d403410976 100644 --- a/core/templates/update.php +++ b/core/templates/update.php @@ -2,30 +2,4 @@
  • t('Updating ownCloud to version %s, this may take a while.', array($_['version'])); ?>

  • - - \ No newline at end of file + \ No newline at end of file diff --git a/lib/base.php b/lib/base.php index 81a5a615de..402a8af421 100644 --- a/lib/base.php +++ b/lib/base.php @@ -252,6 +252,7 @@ class OC if ($showTemplate && !OC_Config::getValue('maintenance', false)) { OC_Config::setValue('maintenance', true); OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG); + OC_Util::addscript('update'); $tmpl = new OC_Template('', 'update', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); $tmpl->printPage();