From fe8bdad8ccbbe2dad659215178f102be30151c65 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 17 Nov 2015 16:27:32 -0500 Subject: [PATCH] CRM-13823 - Allow string and numeric output of severity level --- CRM/Utils/Check.php | 8 ++++---- CRM/Utils/Check/Message.php | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 7833779407..0f7db75aea 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -106,8 +106,8 @@ class CRM_Utils_Check { if (!$message->isVisible()) { continue; } - if ($filter === TRUE || $message->getSeverity() >= 3) { - $statusType = $message->getSeverity() >= 4 ? 'error' : $statusType; + if ($filter === TRUE || $message->getLevel() >= 3) { + $statusType = $message->getLevel() >= 4 ? 'error' : $statusType; $statusMessage = $message->getMessage(); $statusMessages[] = $statusTitle = $message->getTitle(); } @@ -134,8 +134,8 @@ class CRM_Utils_Check { * @return int */ public static function severitySort($a, $b) { - $aSeverity = $a->getSeverity(); - $bSeverity = $b->getSeverity(); + $aSeverity = $a->getLevel(); + $bSeverity = $b->getLevel(); if ($aSeverity == $bSeverity) { return strcmp($a->getName(), $b->getName()); } diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index caccaa3c01..827613da60 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -134,9 +134,9 @@ class CRM_Utils_Check_Message { } /** - * Get level. + * Get severity level number. * - * @return string + * @return int * @see Psr\Log\LogLevel */ public function getLevel() { @@ -144,11 +144,13 @@ class CRM_Utils_Check_Message { } /** - * Alias for Level + * Get severity string. + * * @return string + * @see Psr\Log\LogLevel */ public function getSeverity() { - return $this->getLevel(); + return CRM_Utils_Check::severityMap($this->level, TRUE); } /** @@ -170,7 +172,7 @@ class CRM_Utils_Check_Message { 'name' => $this->name, 'message' => $this->message, 'title' => $this->title, - 'severity' => CRM_Utils_Check::severityMap($this->level, TRUE), + 'severity' => $this->getSeverity(), 'severity_id' => $this->level, 'is_visible' => (int) $this->isVisible(), 'icon' => $this->icon, @@ -231,8 +233,7 @@ class CRM_Utils_Check_Message { } if ($spid) { // If so, compare severity to StatusPreference->severity. - $severity = $this->getSeverity(); - if ($severity <= $statusPreference['values'][$spid]['ignore_severity']) { + if ($this->level <= $statusPreference['values'][$spid]['ignore_severity']) { // A hush or a snooze has been set. Find out which. if (isset($statusPreference['values'][$spid]['hush_until'])) { // Snooze is set. -- 2.25.1