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();
}