Ejemplo n.º 1
0
 /**
  * Fetches the version of the latest stable release
  *
  * @link http://framework.zend.com/download/latest
  * @return string
  */
 public static function getLatest()
 {
     if (null === self::$_lastestVersion) {
         self::$_lastestVersion = 'not available';
         $handle = fopen('http://www.opensolutions.ie/open-source/vimbadmin/latest', 'r');
         if ($handle !== false) {
             self::$_lastestVersion = trim(stream_get_contents($handle));
             fclose($handle);
         }
     }
     return self::$_lastestVersion;
 }
Ejemplo n.º 2
0
 public function checkVersion()
 {
     if (isset($this->_options['skipVersionCheck']) && $this->_options['skipVersionCheck']) {
         return;
     }
     if (!$this->getAdmin()->isSuper()) {
         return;
     }
     // only check once per 24 hours per session
     if (isset($this->getSessionNamespace()->versionChecked) && $this->getSessionNamespace()->versionChecked > time() - 86400) {
         return;
     }
     // only check once in a 24h period for each user
     $lastCheck = $this->getAdmin()->getPreference('version_last_check_at');
     if ($lastCheck && $lastCheck > time() - 86400) {
         $this->getSessionNamespace()->versionChecked = $lastCheck;
         return;
     }
     // is there a new version available?
     $latest = ViMbAdmin_Version::getLatest();
     if ($latest != 'not available') {
         if (ViMbAdmin_Version::compareVersion($latest) == 1) {
             $this->addMessage(sprintf(_('Current version is: %s. There is a new version available: %s. ' . 'See the <a href="https://github.com/opensolutions/ViMbAdmin/releases/tag/' . $latest . '">releases list</a>.'), ViMbAdmin_Version::VERSION, ViMbAdmin_Version::getLatest()), OSS_Message::INFO);
         }
     }
     $this->getSessionNamespace()->versionChecked = time();
     $this->getAdmin()->setPreference('version_last_check_at', $this->getSessionNamespace()->versionChecked);
     $this->getD2EM()->flush();
 }
Ejemplo n.º 3
0
 public function checkVersion()
 {
     // only check once per 24 hours per session
     if (isset($this->_session->versionChecked) && $this->_session->versionChecked > time() - 86400) {
         return;
     }
     // only check once in a 24h period for each user
     $lastCheck = ConfigTable::getValue('version_last_check_at.' . $this->getAdmin()->id);
     if ($lastCheck && $lastCheck > time() - 86400) {
         $this->_session->versionChecked = $lastCheck;
         return;
     }
     // is there a new version available?
     if (ViMbAdmin_Version::compareVersion(ViMbAdmin_Version::getLatest()) == 1) {
         $this->addMessage(sprintf(_('Current version is: %s. There is a new version available: %s. See the <a href="https://github.com/opensolutions/ViMbAdmin/blob/master/CHANGELOG">change log</a>.'), ViMbAdmin_Version::VERSION, ViMbAdmin_Version::getLatest()), ViMbAdmin_Message::INFO);
     }
     $this->_session->versionChecked = time();
     ConfigTable::setValue('version_last_check_at.' . $this->getAdmin()->id, $this->_session->versionChecked);
 }