ViMbAdmin_Version::compareVersion PHP Method

compareVersion() public static method

Compare the specified version string $version with the current ViMbAdmin_Version::VERSION.
public static compareVersion ( string $version ) : integer
$version string A version string (e.g. "0.7.1").
return integer -1 if the $version is older, 0 if they are the same, and +1 if $version is newer.
    public static function compareVersion($version)
    {
        return version_compare($version, self::VERSION);
    }

Usage Example

Ejemplo n.º 1
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();
 }
All Usage Examples Of ViMbAdmin_Version::compareVersion