From d450a5f083749a889bb513b2cbbf371017643722 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 4 Dec 2015 22:17:29 -0500 Subject: [PATCH] CRM-17637 - Refactor out versionCheck setting --- CRM/Admin/Form/Setting/Miscellaneous.php | 1 - CRM/Core/Config/MagicMerge.php | 1 - CRM/Utils/Check/Env.php | 114 ++++++++++-------- api/v3/examples/Setting/GetFields.php | 14 --- settings/Core.setting.php | 14 --- .../CRM/Admin/Form/Setting/Miscellaneous.tpl | 21 ---- 6 files changed, 63 insertions(+), 102 deletions(-) diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 4a4645a628..1630ed9ce9 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -40,7 +40,6 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'max_attachments' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'dashboardCacheTimeout' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'versionCheck' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'empoweredBy' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'logging' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, diff --git a/CRM/Core/Config/MagicMerge.php b/CRM/Core/Config/MagicMerge.php index 39a0a493f5..57bf9c9c0f 100644 --- a/CRM/Core/Config/MagicMerge.php +++ b/CRM/Core/Config/MagicMerge.php @@ -172,7 +172,6 @@ class CRM_Core_Config_MagicMerge { 'userFrameworkLogging' => array('setting'), 'userFrameworkUsersTableName' => array('setting'), 'verpSeparator' => array('setting'), - 'versionCheck' => array('setting'), 'wkhtmltopdfPath' => array('setting'), 'wpBasePage' => array('setting'), 'wpLoadPhp' => array('setting'), diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 7b4a9d9112..574795a081 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -292,63 +292,75 @@ class CRM_Utils_Check_Env { public function checkVersion() { $messages = array(); - if (Civi::settings()->get('versionCheck')) { - $vc = new CRM_Utils_VersionCheck(); - $newerVersion = $vc->isNewerVersionAvailable(); - - if ($newerVersion['version']) { - $vInfo = array( - 1 => $newerVersion['version'], - 2 => $vc->localVersion, - ); - // LTS = long-term support version - if ($newerVersion['status'] == 'lts') { - $vInfo[1] .= ' ' . ts('(long-term support)'); - } - - if ($newerVersion['upgrade'] == 'security') { - // Security - $severity = \Psr\Log\LogLevel::CRITICAL; - $title = ts('CiviCRM Security Update Required'); - $message = ts('New security release %1 is available. The site is currently running %2.', $vInfo); - } - elseif ($newerVersion['status'] == 'eol') { - // Warn about EOL - $severity = \Psr\Log\LogLevel::WARNING; - $title = ts('CiviCRM Update Needed'); - $message = ts('New version %1 is available. The site is currently running %2, which has reached its end of life.', $vInfo); - } - else { - // For most new versions, just make them notice - $severity = \Psr\Log\LogLevel::NOTICE; - $title = ts('CiviCRM Update Available'); - $message = ts('New version %1 is available. The site is currently running %2.', $vInfo); - } + $vc = new CRM_Utils_VersionCheck(); + $newerVersion = $vc->isNewerVersionAvailable(); + + if ($newerVersion['version']) { + $vInfo = array( + 1 => $newerVersion['version'], + 2 => $vc->localVersion, + ); + // LTS = long-term support version + if ($newerVersion['status'] == 'lts') { + $vInfo[1] .= ' ' . ts('(long-term support)'); + } + + if ($newerVersion['upgrade'] == 'security') { + // Security + $severity = \Psr\Log\LogLevel::CRITICAL; + $title = ts('CiviCRM Security Update Required'); + $message = ts('New security release %1 is available. The site is currently running %2.', $vInfo); + } + elseif ($newerVersion['status'] == 'eol') { + // Warn about EOL + $severity = \Psr\Log\LogLevel::WARNING; + $title = ts('CiviCRM Update Needed'); + $message = ts('New version %1 is available. The site is currently running %2, which has reached its end of life.', $vInfo); } else { - $vNum = $vc->localVersion; - // LTS = long-term support version - if ($newerVersion['status'] == 'lts') { - $vNum .= ' ' . ts('(long-term support)'); - } - - $severity = \Psr\Log\LogLevel::INFO; - $title = ts('CiviCRM Up-to-Date'); - $message = ts('CiviCRM version %1 is up-to-date.', array(1 => $vNum)); + // For most new versions, just make them notice + $severity = \Psr\Log\LogLevel::NOTICE; + $title = ts('CiviCRM Update Available'); + $message = ts('New version %1 is available. The site is currently running %2.', $vInfo); } - - $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - $message, - $title, - $severity, - 'fa-cloud-upload' - ); } else { + $vNum = $vc->localVersion; + // LTS = long-term support version + if ($newerVersion['status'] == 'lts') { + $vNum .= ' ' . ts('(long-term support)'); + } + + $severity = \Psr\Log\LogLevel::INFO; + $title = ts('CiviCRM Up-to-Date'); + $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'], + ); + } $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - ts('The check for new versions of CiviCRM has been disabled. Re-enable the setting to receive important security update notifications.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1') . '"')), + 'checkVersionDisabled', + ts('The check for new versions of CiviCRM has been disabled. Re-enable the scheduled job 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' diff --git a/api/v3/examples/Setting/GetFields.php b/api/v3/examples/Setting/GetFields.php index 2f1b5d0ff8..4d3549586d 100644 --- a/api/v3/examples/Setting/GetFields.php +++ b/api/v3/examples/Setting/GetFields.php @@ -527,20 +527,6 @@ function setting_getfields_expectedresult() { 'description' => 'Allow Permanent Delete for contacts who are linked to live financial transactions', 'help_text' => '', ), - 'versionCheck' => array( - 'group_name' => 'CiviCRM Preferences', - 'group' => 'core', - 'name' => 'versionCheck', - 'type' => 'Boolean', - 'quick_form_type' => 'YesNo', - 'default' => 1, - 'add' => '4.3', - 'title' => 'Automatically Check for Updates', - 'is_domain' => 1, - 'is_contact' => 0, - 'description' => '', - 'help_text' => '', - ), 'securityAlert' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', diff --git a/settings/Core.setting.php b/settings/Core.setting.php index e7a0931c50..00bbf3525e 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -361,20 +361,6 @@ return array( 'description' => 'Allow Permanent Delete for contacts who are linked to live financial transactions', 'help_text' => NULL, ), - 'versionCheck' => array( - 'group_name' => 'CiviCRM Preferences', - 'group' => 'core', - 'name' => 'versionCheck', - 'type' => 'Boolean', - 'quick_form_type' => 'YesNo', - 'default' => 1, - 'add' => '4.3', - 'title' => 'Automatically Check for Updates', - 'is_domain' => 1, - 'is_contact' => 0, - 'description' => "", - 'help_text' => NULL, - ), 'securityAlert' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', diff --git a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl index 5af743be02..b995a3fb04 100644 --- a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl +++ b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl @@ -72,11 +72,6 @@

{ts 1="http://wkhtmltopdf.org/"}wkhtmltopdf is an alternative utility for generating PDF's which may provide better performance especially if you are generating a large number of PDF letters or receipts. Your system administrator will need to download and install this utility, and enter the executable path here.{/ts}

- - {$form.versionCheck.label} - {$form.versionCheck.html}
-

{ts}When enabled, statistics about your CiviCRM installation are reported anonymously to the CiviCRM team to assist in prioritizing ongoing development efforts. The following information is gathered: CiviCRM version, versions of PHP, MySQL and framework (Drupal/Joomla/standalone), and default language. Counts (but no actual data) of the following record types are reported: contacts, activities, cases, relationships, contributions, contribution pages, contribution products, contribution widgets, discounts, price sets, profiles, events, participants, tell-a-friend pages, grants, mailings, memberships, membership blocks, pledges, pledge blocks and active payment processor types.{/ts}

- {$form.empoweredBy.label} {$form.empoweredBy.html}
@@ -126,19 +121,3 @@
{include file="CRM/common/formButtons.tpl" location="bottom"}
-{literal} - -{/literal} \ No newline at end of file -- 2.25.1