function view() { $upd = new Update(); $updates = $upd->getLocalAvailableUpdates(); $remote = $upd->getApplicationUpdateInformation(); $this->set('updates', $updates); if (MULTI_SITE == 0) { $this->set('showDownloadBox', true); } else { $this->set('showDownloadBox', false); } if (is_object($remote) && version_compare($remote->version, APP_VERSION, '>')) { // loop through local updates $downloadableUpgradeAvailable = true; foreach ($updates as $upd) { if ($upd->getUpdateVersion() == $remote->version) { // we have a LOCAL version ready to install that is the same, so we abort $downloadableUpgradeAvailable = false; $this->set('showDownloadBox', false); break; } } $this->set('downloadableUpgradeAvailable', $downloadableUpgradeAvailable); $this->set('update', $remote); } else { $this->set('downloadableUpgradeAvailable', false); } }
public function getLatestAvailableVersionNumber() { if (defined('MULTI_SITE') && MULTI_SITE == 1) { $updates = Update::getLocalAvailableUpdates(); $multiSiteVersion = 0; foreach ($updates as $up) { if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) { $multiSiteVersion = $up->getUpdateVersion(); } } Config::save('APP_VERSION_LATEST', $multiSiteVersion); return $multiSiteVersion; } $d = Loader::helper('date'); // first, we check session $queryWS = false; Cache::disableCache(); $vNum = Config::get('APP_VERSION_LATEST', true); Cache::enableCache(); if (is_object($vNum)) { $seconds = strtotime($vNum->timestamp); $version = $vNum->value; if (is_object($version)) { $versionNum = $version->version; } else { $versionNum = $version; } $diff = time() - $seconds; if ($diff > APP_VERSION_LATEST_THRESHOLD) { // we grab a new value from the service $queryWS = true; } } else { $queryWS = true; } if ($queryWS) { Loader::library('marketplace'); $mi = Marketplace::getInstance(); if ($mi->isConnected()) { Marketplace::checkPackageUpdates(); } $update = Update::getLatestAvailableUpdate(); $versionNum = $update->version; if ($versionNum) { Config::save('APP_VERSION_LATEST', $versionNum); if (version_compare($versionNum, APP_VERSION, '>')) { Loader::model('system_notification'); SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/backup_restore/update')); } } else { // we don't know so we're going to assume we're it Config::save('APP_VERSION_LATEST', APP_VERSION); } } return $versionNum; }
public static function getByVersionNumber($version) { $upd = new Update(); $updates = $upd->getLocalAvailableUpdates(); foreach ($updates as $up) { if ($up->getUpdateVersion() == $version) { return $up; } } }