diff options
-rw-r--r-- | core/ajax/update.php | 16 | ||||
-rw-r--r-- | lib/legacy/updater.php | 14 | ||||
-rw-r--r-- | lib/updater.php | 39 |
3 files changed, 36 insertions, 33 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php index 309bad819c8..d530a4c7b6d 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -5,26 +5,26 @@ require_once '../../lib/base.php'; if (OC::checkUpgrade(false)) { $eventSource = new OC_EventSource(); - $updater = new \OC\Updater(); - $updater->listen('\OC\Updater', 'maintenanceStart', function () use ($eventSource) { + $updater = new OC_Updater(); + $updater->listen('\OC_Updater', 'maintenanceStart', function () use ($eventSource) { $eventSource->send('success', 'Turned on maintenance mode'); }); - $updater->listen('\OC\Updater', 'maintenanceEnd', function () use ($eventSource) { + $updater->listen('\OC_Updater', 'maintenanceEnd', function () use ($eventSource) { $eventSource->send('success', 'Turned off maintenance mode'); }); - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource) { + $updater->listen('\OC_Updater', 'dbUpgrade', function () use ($eventSource) { $eventSource->send('success', 'Updated database'); }); - $updater->listen('\OC\Updater', 'filecacheStart', function () use ($eventSource) { + $updater->listen('\OC_Updater', 'filecacheStart', function () use ($eventSource) { $eventSource->send('success', 'Updating filecache, this may take really long...'); }); - $updater->listen('\OC\Updater', 'filecacheDone', function () use ($eventSource) { + $updater->listen('\OC_Updater', 'filecacheDone', function () use ($eventSource) { $eventSource->send('success', 'Updated filecache'); }); - $updater->listen('\OC\Updater', 'filecacheProgress', function ($out) use ($eventSource) { + $updater->listen('\OC_Updater', 'filecacheProgress', function ($out) use ($eventSource) { $eventSource->send('success', '... ' . $out . '% done ...'); }); - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) { + $updater->listen('\OC_Updater', 'failure', function ($message) use ($eventSource) { $eventSource->send('failure', $message); $eventSource->close(); OC_Config::setValue('maintenance', false); diff --git a/lib/legacy/updater.php b/lib/legacy/updater.php deleted file mode 100644 index eea7bb129cf..00000000000 --- a/lib/legacy/updater.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -class OC_Updater { - public static function check() { - $updater = new \OC\Updater(); - return $updater->check('http://apps.owncloud.com/updater.php'); - } -} diff --git a/lib/updater.php b/lib/updater.php index 68b64b59b2d..93a8c49128e 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -6,7 +6,6 @@ * See the COPYING-README file. */ -namespace OC; use OC\Hooks\BasicEmitter; /** @@ -21,13 +20,13 @@ use OC\Hooks\BasicEmitter; * - filecacheDone() * - failure(string $message) */ -class Updater extends BasicEmitter { +class OC_Updater extends BasicEmitter { /** * Check if a new version is available * @param string $updateUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php' * @return array | bool */ - public function check($updaterUrl) { + static public function check($updaterUrl='http://apps.owncloud.com/updater.php') { OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); if ((\OC_Appconfig::getValue('core', 'lastupdatedat') + 1800) > time()) { return json_decode(\OC_Appconfig::getValue('core', 'lastupdateResult'), true); @@ -71,6 +70,24 @@ class Updater extends BasicEmitter { return $tmp; } + public static function ShowUpdatingHint() { + $l = OC_L10N::get('lib'); + + if(OC_Config::getValue('updatechecker', true)==true) { + $data=OC_Updater::check(); + if(isset($data['version']) and $data['version']<>'') { + $txt='<span style="color:#AA0000; font-weight:bold;">' + .$l->t('%s is available. Get <a href="%s">more information</a>', + array($data['versionstring'], $data['web'])).'</span>'; + }else{ + $txt=$l->t('up to date'); + } + } else { + $txt=$l->t('updates check is disabled'); + } + return($txt); + } + /** * runs the update actions in maintenance mode, does not upgrade the source files */ @@ -80,23 +97,23 @@ class Updater extends BasicEmitter { $installedVersion = \OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', \OC_Util::getVersion()); \OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, \OC_Log::WARN); - $this->emit('\OC\Updater', 'maintenanceStart'); + $this->emit('\OC_Updater', 'maintenanceStart'); try { \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); - $this->emit('\OC\Updater', 'dbUpgrade'); + $this->emit('\OC_Updater', 'dbUpgrade'); // do a file cache upgrade for users with files // this can take loooooooooooooooooooooooong $this->upgradeFileCache(); } catch (\Exception $exception) { - $this->emit('\OC\Updater', 'failure', array($exception->getMessage())); + $this->emit('\OC_Updater', 'failure', array($exception->getMessage())); } \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); \OC_App::checkAppsRequirements(); // load all apps to also upgrade enabled apps \OC_App::loadApps(); \OC_Config::setValue('maintenance', false); - $this->emit('\OC\Updater', 'maintenanceEnd'); + $this->emit('\OC_Updater', 'maintenanceEnd'); } private function upgradeFileCache() { @@ -124,16 +141,16 @@ class Updater extends BasicEmitter { if (!$startInfoShown) { //We show it only now, because otherwise Info about upgraded apps //will appear between this and progress info - $this->emit('\OC\Updater', 'filecacheStart'); + $this->emit('\OC_Updater', 'filecacheStart'); $startInfoShown = true; } $percentCompleted += $step; $out = floor($percentCompleted); if ($out != $lastPercentCompletedOutput) { - $this->emit('\OC\Updater', 'filecacheProgress', array($out)); + $this->emit('\OC_Updater', 'filecacheProgress', array($out)); $lastPercentCompletedOutput = $out; } } - $this->emit('\OC\Updater', 'filecacheDone'); + $this->emit('\OC_Updater', 'filecacheDone'); } -} +}
\ No newline at end of file |