From: Coleman Watts Date: Wed, 18 Nov 2015 19:40:41 +0000 (-0500) Subject: CRM-13823 - Split extension status into multiple messages X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6e61248df6a6dfec27406b834d8d463af03667fd;p=civicrm-core.git CRM-13823 - Split extension status into multiple messages --- diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 01c17bafa1..b01f5db17d 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -462,37 +462,25 @@ class CRM_Utils_Check_Env { $keys = array_keys($manager->getStatuses()); sort($keys); - $severity = 1; - $msgArray = $okextensions = array(); - $title = ts('Extension Updates Available'); - - // Icons used for list bullets - $okIcon = ''; - $upgradeIcon = ''; - $problemIcon = ''; + $updates = $errors = $okextensions = array(); foreach ($keys as $key) { try { $obj = $mapper->keyToInfo($key); } catch (CRM_Extension_Exception $ex) { - $severity = 4; - $title = ts('Extension Problem'); - $msgArray[] = $problemIcon . ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)); + $errors[] = ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)); continue; } $row = CRM_Admin_Page_Extensions::createExtendedInfo($obj); switch ($row['status']) { case CRM_Extension_Manager::STATUS_INSTALLED_MISSING: - $severity = 4; - $title = ts('Extension Problem'); - $msgArray[] = $problemIcon . ts('%1 extension (%2) is installed but missing files.', array(1 => CRM_Utils_Array::value('label', $row), 2 => $key)); + $errors[] = ts('%1 extension (%2) is installed but missing files.', array(1 => CRM_Utils_Array::value('label', $row), 2 => $key)); break; case CRM_Extension_Manager::STATUS_INSTALLED: if (!empty($remotes[$key]) && version_compare($row['version'], $remotes[$key]->version, '<')) { - $severity = ($severity < 3) ? 3 : $severity; - $msgArray[] = $upgradeIcon . ts('%1 (%2) version %3 is installed. Upgrade to version %5.', array( + $updates[] = ts('%1 (%2) version %3 is installed. Upgrade to version %5.', array( 1 => CRM_Utils_Array::value('label', $row), 2 => $key, 3 => $row['version'], @@ -515,28 +503,49 @@ class CRM_Utils_Check_Env { break; } } - if ($msgArray) { - $msg = ''; - if ($okextensions) { - $msg .= ts('Other extensions are up-to-date:'); - } + + if (!$okextensions && !$updates && !$errors) { + return array(new CRM_Utils_Check_Message( + __FUNCTION__, + ts('No extensions installed. Browse available extensions.', array( + 1 => CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'), + )), + ts('Extensions'), + \Psr\Log\LogLevel::INFO, + 'fa-plug' + )); } - else { - $title = ts('Extensions Up-to-Date'); - $msg = !$okextensions ? ts('No extensions installed.') : ''; + + if ($errors) { + $messages[] = new CRM_Utils_Check_Message( + __FUNCTION__, + '', + ts('Extension Error'), + \Psr\Log\LogLevel::ERROR, + 'fa-plug' + ); } - if ($okextensions) { - $msg .= ''; + + if ($updates) { + $messages[] = new CRM_Utils_Check_Message( + 'extensionUpdates', + '', + ts('Extension Update Available', array('plural' => '%count Extension Updates Available', 'count' => count($updates))), + \Psr\Log\LogLevel::WARNING, + 'fa-plug' + ); } - // OK, return several data rows - $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - $msg, - $title, - $severity, - 'fa-plug' - ); + if ($okextensions) { + $messages[] = new CRM_Utils_Check_Message( + 'extensionsOk', + ts('1 extension is up-to-date:', array('plural' => '%count extensions are up-to-date:', 'count' => count($okextensions))) . + '', + ts('Extensions'), + \Psr\Log\LogLevel::INFO, + 'fa-plug' + ); + } return $messages; }