public function checkVersion() {
$messages = array();
+ // 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']);
+ $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) . '"')),
+ ts('Update Check Disabled'),
+ \Psr\Log\LogLevel::NOTICE,
+ 'fa-times-circle-o'
+ );
+ }
+
$vc = new CRM_Utils_VersionCheck();
$newerVersion = $vc->isNewerVersionAvailable();
$message = ts('New version %1 is available. The site is currently running %2.', $vInfo);
}
}
- else {
+ elseif ($jobEnabled) {
$vNum = $vc->localVersion;
// LTS = long-term support version
if ($newerVersion['status'] == 'lts') {
$message = ts('CiviCRM version %1 is up-to-date.', array(1 => $vNum));
}
- $messages[] = new CRM_Utils_Check_Message(
- __FUNCTION__,
- $message,
- $title,
- $severity,
- 'fa-cloud-upload'
- );
- }
-
- // Make sure the version_check job is enabled
- $jobs = civicrm_api3('Job', 'get', array(
- 'sequential' => 1,
- 'api_action' => "version_check",
- 'api_entity' => "job",
- ));
- if (!$jobs['count'] || empty($jobs['values'][0]['is_active'])) {
- $args = array('reset' => 1);
- if (!empty($jobs['id'])) {
- $args += array(
- 'action' => 'update',
- 'id' => $jobs['id'],
+ if (!empty($message)) {
+ $messages[] = new CRM_Utils_Check_Message(
+ __FUNCTION__,
+ $message,
+ $title,
+ $severity,
+ 'fa-cloud-upload'
);
}
- $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) . '"')),
- ts('Update Check Disabled'),
- \Psr\Log\LogLevel::NOTICE,
- 'fa-times-circle-o'
- );
}
return $messages;