From 7342d7c429de3eacf3350b1dae51f743f4982bef Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 8 May 2014 14:38:48 -0700 Subject: [PATCH] CRM-14513 - Move notices to CRM_Utils_Check_* --- CRM/Core/Page.php | 19 -------- CRM/Utils/Check/Env.php | 48 ++++++++++++++++++++- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index a0a01e6956..e9b0b378cf 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -225,25 +225,6 @@ class CRM_Core_Page { CRM_Utils_VersionCheck::singleton()->versionAlert(); CRM_Utils_Check::singleton()->showPeriodicAlerts(); - // Debug msg once per hour - if ($config->debug && CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Session::singleton()->timer('debug_alert', 7200)) { - $msg = ts('Warning: Debug is enabled in system settings. This should not be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))); - CRM_Core_Session::setStatus($msg, ts('Debug Mode')); - } - - $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); - - // Outbound email msg once every 2 hours if outbound email is redirected or disabled - if (($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB - || (defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG) - || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED - || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) - && CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Session::singleton()->timer('outboundEmail_alert', 7200)) - { - $msg = ts('Warning: Outbound email is disabled in system settings. Proper settings should be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))); - CRM_Core_Session::setStatus($msg, ts('Outbound Email Settings')); - } - if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) { diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 7170b453e7..8212acfae6 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -41,11 +41,18 @@ class CRM_Utils_Check_Env { */ public function checkAll() { $messages = array_merge( - $this->checkMysqlTime() + $this->checkMysqlTime(), + $this->checkDebug(), + $this->checkOutboundMail() ); return $messages; } + /** + * Check that the MySQL time settings match the PHP time settings. + * + * @return array an empty array, or a list of warnings + */ public function checkMysqlTime() { $messages = array(); @@ -55,7 +62,7 @@ class CRM_Utils_Check_Env { $messages[] = new CRM_Utils_Check_Message( 'checkMysqlTime', ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.
Read more about this warning', array( - 1 => CRM_Utils_System::getWikiBaseURL() . 'checkMysqlTime', + 1 => CRM_Utils_System::getWikiBaseURL() . 'checkMysqlTime', 2 => $sqlNow, 3 => $phpNow, )), @@ -65,4 +72,41 @@ class CRM_Utils_Check_Env { return $messages; } + + public function checkDebug() { + $messages = array(); + + $config = CRM_Core_Config::singleton(); + if ($config->debug) { + $messages[] = new CRM_Utils_Check_Message( + 'checkDebug', + ts('Warning: Debug is enabled in system settings. This should not be enabled on production servers.', + array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))), + ts('Debug Mode') + ); + } + + return $messages; + } + + public function checkOutboundMail() { + $messages = array(); + + $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); + if (($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB + || (defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG) + || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED + || $mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) + ) { + $messages[] = new CRM_Utils_Check_Message( + 'checkOutboundMail', + ts('Warning: Outbound email is disabled in system settings. Proper settings should be enabled on production servers.', + array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))), + + ts('Outbound Email Settings') + ); + } + + return $messages; + } } \ No newline at end of file diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 31e618722d..68640d4bb3 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -313,7 +313,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array(); $env = new CRM_Utils_Check_Env(); - CRM_Utils_Check::singleton()->assertValid($env->checkAll()); + CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime()); } /** -- 2.25.1