*/
public function checkVersion() {
$messages = array();
+ $vc = new CRM_Utils_VersionCheck();
- // See if the version_check job is enabled
- $jobs = civicrm_api3('Job', 'get', array(
- 'sequential' => 1,
- 'api_action' => "version_check",
- 'api_entity' => "job",
- ));
- $jobEnabled = !empty($jobs['values'][0]['is_active']);
- if (!$jobEnabled) {
- $args = empty($josb['id']) ? array('reset' => 1) : array('reset' => 1, 'action' => 'update', 'id' => $jobs['id']);
+ // Show a notice if the version_check job is disabled
+ if (empty($vc->cronJob['is_active'])) {
+ $args = empty($vc->cronJob['id']) ? array('reset' => 1) : array('reset' => 1, 'action' => 'update', 'id' => $vc->cronJob['id']);
$messages[] = new CRM_Utils_Check_Message(
'checkVersionDisabled',
ts('The check for new versions of CiviCRM has been disabled. <a %1>Re-enable the scheduled job</a> to receive important security update notifications.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/job', $args) . '"')),
);
}
- $vc = new CRM_Utils_VersionCheck();
- $newerVersion = $vc->isNewerVersionAvailable();
-
if ($vc->isInfoAvailable) {
+ $newerVersion = $vc->isNewerVersionAvailable();
if ($newerVersion['version']) {
$vInfo = array(
1 => $newerVersion['version'],
$message = ts('New version %1 is available. The site is currently running %2.', $vInfo);
}
}
- elseif ($jobEnabled) {
+ elseif (!empty($vc->cronJob['is_active'])) {
$vNum = $vc->localVersion;
// LTS = long-term support version
if ($newerVersion['status'] == 'lts') {
class CRM_Utils_VersionCheck {
const
PINGBACK_URL = 'http://latest.civicrm.org/stable.php?format=json',
- // relative to $civicrm_root
- LOCALFILE_NAME = '[civicrm.root]/civicrm-version.php',
// relative to $config->uploadDir
CACHEFILE_NAME = '[civicrm.files]/persist/version-info-cache.json';
*/
public $isInfoAvailable;
+ /**
+ * @var array
+ */
+ public $cronJob = array();
+
/**
* Pingback params
*
* Class constructor.
*/
public function __construct() {
- // Populate local version
- $localFile = Civi::paths()->getPath(self::LOCALFILE_NAME);
- if (file_exists($localFile)) {
- require_once $localFile;
- }
- if (function_exists('civicrmVersion')) {
- $info = civicrmVersion();
- $this->localVersion = trim($info['version']);
- $this->localMajorVersion = $this->getMajorVersion($this->localVersion);
- }
+ $this->localVersion = CRM_Utils_System::version();
+ $this->localMajorVersion = $this->getMajorVersion($this->localVersion);
+
+ $this->getJob();
// Populate remote $versionInfo from cache file
$this->cacheFile = Civi::paths()->getPath(self::CACHEFILE_NAME);
fclose($fp);
}
+ /**
+ * Lookup version_check scheduled job
+ */
+ private function getJob() {
+ $jobs = civicrm_api3('Job', 'get', array(
+ 'sequential' => 1,
+ 'api_action' => "version_check",
+ 'api_entity' => "job",
+ ));
+ $this->cronJob = CRM_Utils_Array::value(0, $jobs['values'], array());
+ }
+
}