From 46a903fb310fb1cdd53fc0aa4c5c019ed45ad5f9 Mon Sep 17 00:00:00 2001 From: Nikki Murray Date: Wed, 30 Sep 2015 16:31:33 -0400 Subject: [PATCH] changing api to allow for searching for hushed status alerts --- CRM/Utils/Check.php | 12 ++++-------- CRM/Utils/Check/Message.php | 16 ++++++++++++++++ api/v3/System.php | 17 ++++++++++++++--- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 4b8267fde9..7951832397 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -181,7 +181,7 @@ class CRM_Utils_Check { * Array of messages * @link https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements */ - public function checkAll($showHushed = FALSE) { + public function checkAll() { $checks = array(); $checks[] = new CRM_Utils_Check_Security(); $checks[] = new CRM_Utils_Check_Env(); @@ -204,13 +204,9 @@ class CRM_Utils_Check { CRM_Utils_Hook::check($messages); - if (!$showHushed) { - foreach ($messages as $key => $message) { - $hush = self::checkHushSnooze($message); - if ($hush) { - unset($messages[$key]); - } - } + foreach ($messages as $key => $message) { + $hush = self::checkHushSnooze($message); + $message->setVisible($hush); } uasort($messages, array(__CLASS__, 'severitySort')); diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index 2bf5dec909..0b76d8ad88 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -58,6 +58,13 @@ class CRM_Utils_Check_Message { */ private $help; + /** + * + * @var bool + * This is used for Admin Status Page to determine hushed statuses. + */ + private $isVisible; + /** * @param string $name * Symbolic name for the check. @@ -135,6 +142,7 @@ class CRM_Utils_Check_Message { 'message' => $this->message, 'title' => $this->title, 'severity' => $this->level, + 'isVisible' => $this->isVisible, ); if (!empty($this->help)) { $array['help'] = $this->help; @@ -142,4 +150,12 @@ class CRM_Utils_Check_Message { return $array; } + public function isVisibile() { + return $this->isVisible; + } + + public function setVisible($isVisible) { + $this->isVisible = $isVisible; + } + } diff --git a/api/v3/System.php b/api/v3/System.php index c73968e65b..2017d5a6fa 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -104,10 +104,21 @@ function _civicrm_api3_system_check_spec(&$spec) { */ function civicrm_api3_system_check($params) { $returnValues = array(); - $messages = CRM_Utils_Check::singleton()->checkAll(CRM_Utils_Array::value('show_hushed', $params)); - foreach ($messages as $msg) { - $returnValues[] = $msg->toArray(); + $messages = CRM_Utils_Check::singleton()->checkAll(); + $showHushed = CRM_Utils_Array::value('show_hushed', $params); + if (!$showHushed) { + foreach ($messages as $key => $message) { + if (!$message->isVisible()) { + unset($messages[$key]); + } + } } + else { + foreach ($messages as $msg) { + $returnValues[] = $msg->toArray(); + } + } + // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL) return civicrm_api3_create_success($returnValues, $params, 'System', 'Check'); -- 2.25.1