From: Coleman Watts Date: Wed, 18 Nov 2015 17:54:58 +0000 (-0500) Subject: CRM-13823 - Tweak popup status alerts X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f608a24a93a26b243321c0bb772e73e993821f31;p=civicrm-core.git CRM-13823 - Tweak popup status alerts --- diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index 972850a04f..0c3dbd4233 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -354,36 +354,8 @@ class CRM_Core_Invoke { } // always use cached results - they will be refreshed by the session timer $status = Civi::settings()->get('systemStatusCheckResult'); - switch ($status) { - case 7: - $statusMessage = ts('System Status: Emergency'); - break; - - case 6: - $statusMessage = ts('System Status: Alert'); - break; - - case 5: - $statusMessage = ts('System Status: Critical'); - break; - - case 4: - $statusMessage = ts('System Status: Error'); - break; - - case 3: - $statusMessage = ts('System Status: Warning'); - break; - - case 2: - $statusMessage = ts('System Status: Notice'); - break; - - default: - $statusMessage = ts('System Status: Ok'); - } $template->assign('footer_status_severity', $status); - $template->assign('footer_status_message', $statusMessage); + $template->assign('footer_status_message', CRM_Utils_Check::toStatusLabel($status)); } /** diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 783989b0f4..73129d04c4 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -77,16 +77,9 @@ class CRM_Utils_Check { } /** - * Execute "checkAll". - * - * @param array|NULL $messages - * List of CRM_Utils_Check_Message; or NULL if the default list should be fetched. - * @param array|string|callable $filter - * Restrict messages using a callback filter. - * By default, only show warnings and errors. - * Set TRUE to show all messages. + * Display daily system status alerts (admin only). */ - public function showPeriodicAlerts($messages = NULL, $filter = array(__CLASS__, 'severityMap')) { + public function showPeriodicAlerts() { if (CRM_Core_Permission::check('administer CiviCRM')) { $session = CRM_Core_Session::singleton(); if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) { @@ -95,29 +88,28 @@ class CRM_Utils_Check { $config = CRM_Core_Config::singleton(); $config->cleanup(0, FALSE); - if ($messages === NULL) { - $messages = $this->checkAll(); - } $statusMessages = array(); - $statusType = 'alert'; - foreach ($messages as $message) { + $maxSeverity = 0; + foreach ($this->checkAll() as $message) { if (!$message->isVisible()) { continue; } - if ($filter === TRUE || $message->getLevel() >= 3) { - $statusType = $message->getLevel() >= 4 ? 'error' : $statusType; + if ($message->getLevel() >= 3) { + $maxSeverity = max($maxSeverity, $message->getLevel()); $statusMessage = $message->getMessage(); $statusMessages[] = $statusTitle = $message->getTitle(); } } - if (count($statusMessages)) { + if ($statusMessages) { if (count($statusMessages) > 1) { - $statusTitle = ts('Multiple Alerts'); - $statusMessage = ts('Please check your status page for a full list and further details.', array(1 => CRM_Utils_System::url('civicrm/a/#/status'))) . ''; + $statusTitle = self::toStatusLabel($maxSeverity); + $statusMessage = ''; } - // @todo add link to status page + $statusMessage .= '

' . ts('View details and manage alerts') . '

'; + + $statusType = $maxSeverity >= 4 ? 'error' : 'alert'; CRM_Core_Session::setStatus($statusMessage, $statusTitle, $statusType); } } @@ -240,4 +232,33 @@ class CRM_Utils_Check { return ($max) ? $maxSeverity : $messages; } + /** + * @param int $level + * @return string + */ + public static function toStatusLabel($level) { + switch ($level) { + case 7: + return ts('System Status: Emergency'); + + case 6: + return ts('System Status: Alert'); + + case 5: + return ts('System Status: Critical'); + + case 4: + return ts('System Status: Error'); + + case 3: + return ts('System Status: Warning'); + + case 2: + return ts('System Status: Notice'); + + default: + return ts('System Status: Ok'); + } + } + }