diff --git a/core/css/styles.css b/core/css/styles.css index 4dfa3f64a375c70a5ea3f9e8b524b229e5a25c45..49cdc8836f8b0d474210341eef8502bae7c16588 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -345,6 +345,9 @@ li.update, li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; bac #notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position: relative; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } #notification span { cursor:pointer; font-weight:bold; margin-left:1em; } +#update-notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position: relative; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } +#update-notification span { cursor:pointer; font-weight:bold; margin-left:1em; } + tr .action:not(.permanent), .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; } tr:hover .action, tr .action.permanent, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter:alpha(opacity=50); opacity:.5; } tr .action { width:16px; height:16px; } diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index cfe0a5519434fbff5ea01615d780e6bdd5d816d5..12509019b040ae24ed8214c566f9977cf08bc48c 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -32,6 +32,9 @@ <body id="<?php p($_['bodyid']);?>"> <div id="notification-container"> <div id="notification"></div> + <?php if ($_['updateAvailable']): ?> + <div id="update-notification" style="display: inline;"><a href=""><?php print_unescaped($l->t('%s is available. <a href="%s">Click here to get more information.', array($_['updateVersion'], $_['updateLink']))); ?></a></a></div> + <?php endif; ?> </div> <header><div id="header"> <a href="<?php print_unescaped(link_to('', 'index.php')); ?>" title="" id="owncloud"><img class="svg" diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 3c496f56e41769f9c14ccaf4f70c99520d4ddd83..3d344058facdf6e57cfe62949d466fdddf33327e 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -18,6 +18,20 @@ class OC_TemplateLayout extends OC_Template { $this->assign('bodyid', 'body-user'); } + // Update notification + if(OC_Config::getValue('updatechecker', true) === true) { + $data=OC_Updater::check(); + if(isset($data['version']) && $data['version'] != '' and $data['version'] !== Array() && OC_User::isAdminUser(OC_User::getUser())) { + $this->assign('updateAvailable', true); + $this->assign('updateVersion', $data['versionstring']); + $this->assign('updateLink', $data['web']); + } else { + $this->assign('updateAvailable', false); // No update available or not an admin user + } + } else { + $this->assign('updateAvailable', false); // Update check is disabled + } + // Add navigation entry $this->assign( 'application', '', false ); $navigation = OC_App::getNavigation(); diff --git a/lib/updater.php b/lib/updater.php index e7d33ac2bb970c5ac240850594057982f5357bea..9081bfc4be80be4310acc7103b049a7045df90f8 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -29,7 +29,14 @@ class OC_Updater{ * Check if a new version is available */ public static function check() { - OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); + + // Look up the cache - it is invalidated all 30 minutes + if((OC_Appconfig::getValue('core', 'lastupdatedat') + 1800) > time()) { + return json_decode(OC_Appconfig::getValue('core', 'lastupdateResult'), true); + } + + OC_Appconfig::setValue('core', 'lastupdatedat', time()); + if(OC_Appconfig::getValue('core', 'installedat', '')=='') { OC_Appconfig::setValue('core', 'installedat', microtime(true)); } @@ -65,38 +72,9 @@ class OC_Updater{ $tmp['url'] = $data->url; $tmp['web'] = $data->web; - 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); - } - - - /** - * do ownCloud update - */ - public static function doUpdate() { - - //update ownCloud core - - //update all apps - - //update version in config + // Cache the result + OC_Appconfig::setValue('core', 'lastupdateResult', json_encode($data)); + return $tmp; } -} +} \ No newline at end of file diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 182168ce9eb4553344f83357d8ea1c06bf774afe..28254b7aa1844a5c5d9ebbb8cb51f3ca9c6314a6 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -233,8 +233,7 @@ endfor;?> <fieldset class="personalblock"> <legend><strong><?php p($l->t('Version'));?></strong></legend> - <strong>ownCloud</strong> <?php p(OC_Util::getVersionString()); ?> <?php p(OC_Util::getEditionString()); ?> - (<?php print_unescaped(OC_Updater::ShowUpdatingHint()); ?>)<br/> + <strong>ownCloud</strong> <?php p(OC_Util::getVersionString()); ?> <?php p(OC_Util::getEditionString()); ?><br/> <?php print_unescaped($l->t('Developed by the <a href="http://ownCloud.org/contact" target="_blank">ownCloud community</a>, the <a href="https://github.com/owncloud" target="_blank">source code</a> is licensed under the <a href="http://www.gnu.org/licenses/agpl-3.0.html" target="_blank"><abbr title="Affero General Public License">AGPL</abbr></a>.')); ?> </fieldset>