示例#1
0
 /**
  * Provide static instance of CRM_Utils_Check.
  *
  * @return CRM_Utils_Check
  */
 public static function &singleton()
 {
     if (!isset(self::$_singleton)) {
         self::$_singleton = new CRM_Utils_Check();
     }
     return self::$_singleton;
 }
示例#2
0
 /**
  * @param string $name
  *   Symbolic name for the check.
  * @param string $message
  *   Printable message (short or long).
  * @param string $title
  *   Printable message (short).
  * @param string $level
  *   The severity of the message. Use PSR-3 log levels.
  *
  * @see Psr\Log\LogLevel
  */
 public function __construct($name, $message, $title, $level = \Psr\Log\LogLevel::WARNING)
 {
     $this->name = $name;
     $this->message = $message;
     $this->title = $title;
     // Handle non-integer severity levels.
     if (!CRM_Utils_Rule::integer($level)) {
         $level = CRM_Utils_Check::severityMap($level);
     }
     $this->level = $level;
 }
 /**
  * Create or update a Status Preference entry.
  *
  * @param array $params
  *
  * @return array
  */
 public static function create($params)
 {
     $statusPreference = new CRM_Core_BAO_StatusPreference();
     // Default severity level to ignore is 0 (DEBUG).
     if (!isset($params['ignore_severity'])) {
         $params['ignore_severity'] = 0;
     }
     // Severity can be either text ('critical') or an integer <= 7.
     // It's a magic number, but based on PSR-3 standards.
     if (!CRM_Utils_Rule::integer($params['ignore_severity'])) {
         $params['ignore_severity'] = CRM_Utils_Check::severityMap($params['ignore_severity']);
     }
     if ($params['ignore_severity'] > 7) {
         CRM_Core_Error::fatal(ts('You can not pass a severity level higher than 7.'));
     }
     // If severity is now blank, you have an invalid severity string.
     if (is_null($params['ignore_severity'])) {
         CRM_Core_Error::fatal(ts('Invalid string passed as severity level.'));
     }
     // Check if this StatusPreference already exists.
     if (empty($params['id']) && CRM_Utils_Array::value('name', $params)) {
         $statusPreference->domain_id = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID());
         $statusPreference->name = $params['name'];
         $statusPreference->find(TRUE);
     }
     $statusPreference->copyValues($params);
     $edit = $statusPreference->id ? TRUE : FALSE;
     if ($edit) {
         CRM_Utils_Hook::pre('edit', 'StatusPreference', $statusPreference->id, $statusPreference);
     } else {
         CRM_Utils_Hook::pre('create', 'StatusPreference', NULL, $statusPreference);
     }
     $statusPreference->save();
     if ($edit) {
         CRM_Utils_Hook::post('edit', 'StatusPreference', $statusPreference->id, $statusPreference);
     } else {
         CRM_Utils_Hook::post('create', 'StatusPreference', NULL, $statusPreference);
     }
     return $statusPreference;
 }
示例#4
0
/**
 * System Check API.
 *
 * @param array $params
 *
 * @return array
 *   API result descriptor; return items are alert codes/messages
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
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();
    }
    // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL)
    return civicrm_api3_create_success($returnValues, $params, 'System', 'Check');
}
示例#5
0
 /**
  * This function takes care of all the things common to all
  * pages. This typically involves assigning the appropriate smarty
  * variable :)
  *
  * @return void|string
  *   The content generated by running this page
  */
 public function run()
 {
     if ($this->_embedded) {
         return NULL;
     }
     self::$_template->assign('mode', $this->_mode);
     $pageTemplateFile = $this->getHookedTemplateFileName();
     self::$_template->assign('tplFile', $pageTemplateFile);
     // invoke the pagRun hook, CRM-3906
     CRM_Utils_Hook::pageRun($this);
     if ($this->_print) {
         if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) {
             $content = self::$_template->fetch('CRM/common/snippet.tpl');
         } else {
             $content = self::$_template->fetch('CRM/common/print.tpl');
         }
         CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName());
         //its time to call the hook.
         CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
         if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
             CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
         } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) {
             $this->ajaxResponse['content'] = $content;
             CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse);
         } else {
             echo $content;
         }
         CRM_Utils_System::civiExit();
     }
     $config = CRM_Core_Config::singleton();
     // Intermittent alert to admins
     CRM_Utils_Check::singleton()->showPeriodicAlerts();
     if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) {
         CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
     }
     $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
     // Render page header
     if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
         CRM_Utils_System::addHTMLHead($region->render(''));
     }
     CRM_Utils_System::appendTPLFile($pageTemplateFile, $content);
     //its time to call the hook.
     CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
     echo CRM_Utils_System::theme($content, $this->_print);
 }
示例#6
0
/**
 * System Check API.
 *
 * @param array $params
 *
 * @return array
 *   API result descriptor; return items are alert codes/messages
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_system_check($params)
{
    // array(array('name'=> $, 'severity'=>$, ...))
    $id = 1;
    $returnValues = $fields = array();
    _civicrm_api3_system_check_spec($fields);
    // array(CRM_Utils_Check_Message)
    $messages = CRM_Utils_Check::checkAll();
    foreach ($messages as $msg) {
        $returnValues[] = $msg->toArray() + array('id' => $id++);
    }
    return _civicrm_api3_basic_array_get('systemCheck', $params, $returnValues, "id", array_keys($fields));
}
示例#7
0
 /**
  *  Common setup functions for all unit tests.
  */
 protected function setUp()
 {
     $session = CRM_Core_Session::singleton();
     $session->set('userID', NULL);
     $this->errorScope = CRM_Core_TemporaryErrorScope::useException();
     // REVERT
     //  Use a temporary file for STDIN
     $GLOBALS['stdin'] = tmpfile();
     if ($GLOBALS['stdin'] === FALSE) {
         echo "Couldn't open temporary file\n";
         exit(1);
     }
     //  Get and save a connection to the database
     $this->_dbconn = $this->getConnection();
     // reload database before each test
     //        $this->_populateDB();
     // "initialize" CiviCRM to avoid problems when running single tests
     // FIXME: look at it closer in second stage
     $GLOBALS['civicrm_setting']['domain']['fatalErrorHandler'] = 'CiviUnitTestCase_fatalErrorHandler';
     $GLOBALS['civicrm_setting']['domain']['backtrace'] = 1;
     // disable any left-over test extensions
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"');
     // reset all the caches
     CRM_Utils_System::flushCache();
     // initialize the object once db is loaded
     \Civi::reset();
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
     // ugh, performance
     // when running unit tests, use mockup user framework
     $this->hookClass = CRM_Utils_Hook::singleton();
     // Make sure the DB connection is setup properly
     $config->userSystem->setMySQLTimeZone();
     $env = new CRM_Utils_Check_Component_Env();
     CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
     // clear permissions stub to not check permissions
     $config->userPermissionClass->permissions = NULL;
     //flush component settings
     CRM_Core_Component::getEnabledComponents(TRUE);
     error_reporting(E_ALL);
     $this->_sethtmlGlobals();
 }
示例#8
0
 /**
  * Show status in the footer (admin only)
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check('administer CiviCRM')) {
         return;
     }
     // always use cached results - they will be refreshed by the session timer
     $status = Civi::settings()->get('systemStatusCheckResult');
     $template->assign('footer_status_severity', $status);
     $template->assign('footer_status_message', CRM_Utils_Check::toStatusLabel($status));
 }
示例#9
0
 /**
  * Checks if extensions are set up properly
  * @return array
  */
 public function checkExtensions()
 {
     $messages = array();
     $extensionSystem = CRM_Extension_System::singleton();
     $mapper = $extensionSystem->getMapper();
     $manager = $extensionSystem->getManager();
     if ($extensionSystem->getDefaultContainer()) {
         $basedir = $extensionSystem->getDefaultContainer()->baseDir;
     }
     if (empty($basedir)) {
         // no extension directory
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Your extensions directory is not set.  Click <a href="%1">here</a> to set the extensions directory.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/path', 'reset=1'))), ts('Extensions directory not writable'), \Psr\Log\LogLevel::NOTICE, 'fa-plug');
         return $messages;
     }
     if (!is_dir($basedir)) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Your extensions directory path points to %1, which is not a directory.  Please check your file system.', array(1 => $basedir)), ts('Extensions directory incorrect'), \Psr\Log\LogLevel::ERROR, 'fa-plug');
         return $messages;
     } elseif (!is_writable($basedir)) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Your extensions directory, %1, is not writable.  Please change your file permissions.', array(1 => $basedir)), ts('Extensions directory not writable'), \Psr\Log\LogLevel::ERROR, 'fa-plug');
         return $messages;
     }
     if (empty($extensionSystem->getDefaultContainer()->baseUrl)) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('The extensions URL is not properly set. Please go to the <a href="%1">URL setting page</a> and correct it.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'))), ts('Extensions url missing'), \Psr\Log\LogLevel::ERROR, 'fa-plug');
         return $messages;
     }
     if (!$extensionSystem->getBrowser()->isEnabled()) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Not checking remote URL for extensions since ext_repo_url is set to false.'), ts('Extensions check disabled'), \Psr\Log\LogLevel::NOTICE, 'fa-plug');
         return $messages;
     }
     try {
         $remotes = $extensionSystem->getBrowser()->getExtensions();
     } catch (CRM_Extension_Exception $e) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, $e->getMessage(), ts('Extension download error'), \Psr\Log\LogLevel::ERROR, 'fa-plug');
         return $messages;
     }
     if (!$remotes) {
         // CRM-13141 There may not be any compatible extensions available for the requested CiviCRM version + CMS. If so, $extdir is empty so just return a notice.
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('There are currently no extensions on the CiviCRM public extension directory which are compatible with version %1. If you want to install an extension which is not marked as compatible, you may be able to <a %2>download and install extensions manually</a> (depending on access to your web server).', array(1 => CRM_Utils_System::majorVersion(), 2 => 'href="http://wiki.civicrm.org/confluence/display/CRMDOC/Extensions"')), ts('No Extensions Available for this Version'), \Psr\Log\LogLevel::NOTICE, 'fa-plug');
         return $messages;
     }
     $keys = array_keys($manager->getStatuses());
     sort($keys);
     $severity = 1;
     $msgArray = $okextensions = array();
     foreach ($keys as $key) {
         try {
             $obj = $mapper->keyToInfo($key);
         } catch (CRM_Extension_Exception $ex) {
             $severity = 4;
             $msgArray[] = 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;
                 $msgArray[] = 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 (CRM_Utils_Array::value($key, $remotes)) {
                     if (version_compare($row['version'], $remotes[$key]->version, '<')) {
                         $severity = $severity < 3 ? 3 : $severity;
                         $msgArray[] = ts('%1 extension (%2) is upgradeable to version %3.', array(1 => CRM_Utils_Array::value('label', $row), 2 => $key, 3 => $remotes[$key]->version));
                     } else {
                         $okextensions[] = CRM_Utils_Array::value('label', $row) ? "{$row['label']} ({$key})" : $key;
                     }
                 } else {
                     $okextensions[] = CRM_Utils_Array::value('label', $row) ? "{$row['label']} ({$key})" : $key;
                 }
                 break;
             case CRM_Extension_Manager::STATUS_UNINSTALLED:
             case CRM_Extension_Manager::STATUS_DISABLED:
             case CRM_Extension_Manager::STATUS_DISABLED_MISSING:
             default:
         }
     }
     $msg = implode('  ', $msgArray);
     if (empty($msgArray)) {
         $msg = empty($okextensions) ? ts('No extensions installed.') : ts('Extensions are up-to-date:') . ' ' . implode(', ', $okextensions);
     } elseif (!empty($okextensions)) {
         $msg .= '  ' . ts('Other extensions are up-to-date:') . ' ' . implode(', ', $okextensions);
     }
     // OK, return several data rows
     $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, $msg, ts('Extension Updates'), CRM_Utils_Check::severityMap($severity, TRUE), 'fa-plug');
     return $messages;
 }
示例#10
0
 /**
  * Set severity level
  *
  * @param string|int $level
  * @throws \CRM_Core_Exception
  */
 public function setLevel($level)
 {
     // Convert level to integer
     if (!CRM_Utils_Rule::positiveInteger($level)) {
         $level = CRM_Utils_Check::severityMap($level);
     } else {
         // Validate numeric input - this will throw an exception if invalid
         CRM_Utils_Check::severityMap($level, TRUE);
     }
     $this->level = $level;
     // Clear internal caches
     unset($this->isVisible, $this->hiddenUntil);
 }
示例#11
0
 /**
  * Checks if extensions are set up properly
  * @return array
  */
 public function checkExtensions()
 {
     $messages = array();
     $extensionSystem = CRM_Extension_System::singleton();
     $mapper = $extensionSystem->getMapper();
     $manager = $extensionSystem->getManager();
     $remotes = $extensionSystem->getBrowser()->getExtensions();
     if ($extensionSystem->getDefaultContainer()) {
         $basedir = $extensionSystem->getDefaultContainer()->baseDir;
     }
     if (empty($basedir)) {
         // no extension directory
         $messages[] = new CRM_Utils_Check_Message('checkExtensions', ts('Your extensions directory is not set.  Click <a href="%1">here</a> to set the extensions directory.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/path', 'reset=1'))), ts('Extensions directory not writable'), \Psr\Log\LogLevel::NOTICE);
         return $messages;
     }
     if (!is_dir($basedir)) {
         $messages[] = new CRM_Utils_Check_Message('checkExtensions', ts('Your extensions directory path points to %1, which is not a directory.  Please check your file system.', array(1 => $basedir)), ts('Extensions directory incorrect'), \Psr\Log\LogLevel::ERROR);
         return $messages;
     } elseif (!is_writable($basedir)) {
         $messages[] = new CRM_Utils_Check_Message('checkExtensions', ts('Your extensions directory, %1, is not writable.  Please change your file permissions.', array(1 => $basedir)), ts('Extensions directory not writable'), \Psr\Log\LogLevel::ERROR);
         return $messages;
     }
     if (empty($extensionSystem->getDefaultContainer()->baseUrl)) {
         $messages[] = new CRM_Utils_Check_Message('checkExtensions', ts('The extensions URL is not properly set. Please go to the <a href="%1">URL setting page</a> and correct it.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'))), ts('Extensions directory not writable'), \Psr\Log\LogLevel::ERROR);
         return $messages;
     }
     $keys = array_keys($manager->getStatuses());
     sort($keys);
     $severity = 1;
     $msgArray = $okextensions = array();
     foreach ($keys as $key) {
         try {
             $obj = $mapper->keyToInfo($key);
         } catch (CRM_Extension_Exception $ex) {
             $severity = 4;
             $msgArray[] = 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;
                 $msgArray[] = 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 (CRM_Utils_Array::value($key, $remotes)) {
                     if (version_compare($row['version'], $remotes[$key]->version, '<')) {
                         $severity = $severity < 3 ? 3 : $severity;
                         $msgArray[] = ts('%1 extension (%2) is upgradeable to version %3.', array(1 => CRM_Utils_Array::value('label', $row), 2 => $key, 3 => $remotes[$key]->version));
                     } else {
                         $okextensions[] = CRM_Utils_Array::value('label', $row) ? "{$row['label']} ({$key})" : $key;
                     }
                 } else {
                     $okextensions[] = CRM_Utils_Array::value('label', $row) ? "{$row['label']} ({$key})" : $key;
                 }
                 break;
             case CRM_Extension_Manager::STATUS_UNINSTALLED:
             case CRM_Extension_Manager::STATUS_DISABLED:
             case CRM_Extension_Manager::STATUS_DISABLED_MISSING:
             default:
         }
     }
     $msg = implode('  ', $msgArray);
     if (empty($msgArray)) {
         $msg = empty($okextensions) ? ts('No extensions installed.') : ts('Extensions are up-to-date:') . ' ' . implode(', ', $okextensions);
     } elseif (!empty($okextensions)) {
         $msg .= '  ' . ts('Other extensions are up-to-date:') . ' ' . implode(', ', $okextensions);
     }
     // OK, return several data rows
     // $returnValues = array(
     //   array('status' => $return, 'message' => $msg),
     // );
     $messages[] = new CRM_Utils_Check_Message('checkExtensions', $msg, ts('Extension Updates'), CRM_Utils_Check::severityMap($severity, TRUE));
     return $messages;
 }
示例#12
0
文件: Page.php 项目: hguru/224Civi
 /**
  * This function takes care of all the things common to all
  * pages. This typically involves assigning the appropriate
  * smarty variable :)
  *
  * @return string The content generated by running this page
  */
 function run()
 {
     if ($this->_embedded) {
         return;
     }
     self::$_template->assign('mode', $this->_mode);
     $pageTemplateFile = $this->getHookedTemplateFileName();
     self::$_template->assign('tplFile', $pageTemplateFile);
     // invoke the pagRun hook, CRM-3906
     CRM_Utils_Hook::pageRun($this);
     if ($this->_print) {
         if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM))) {
             $content = self::$_template->fetch('CRM/common/snippet.tpl');
         } else {
             $content = self::$_template->fetch('CRM/common/print.tpl');
         }
         CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName());
         //its time to call the hook.
         CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
         if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
             CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
         } else {
             echo $content;
         }
         CRM_Utils_System::civiExit();
     }
     $config = CRM_Core_Config::singleton();
     // TODO: Is there a better way to ensure these actions don't happen during AJAX requests?
     if (empty($_GET['snippet'])) {
         // Version check and intermittent alert to admins
         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', 3600)) {
             $msg = ts('Warning: Debug is enabled in <a href="%1">system settings</a>. 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'));
         }
     }
     $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
     // Render page header
     if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
         CRM_Utils_System::addHTMLHead($region->render(''));
     }
     CRM_Utils_System::appendTPLFile($pageTemplateFile, $content);
     //its time to call the hook.
     CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
     echo CRM_Utils_System::theme($content, $this->_print);
     return;
 }
 public static function setUpBeforeClass()
 {
     static::_populateDB(TRUE);
     // also set this global hack
     $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
     $env = new CRM_Utils_Check_Env();
     CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
 }
示例#14
0
/**
 * System Check API.
 *
 * @param array $params
 *
 * @return array
 *   API result descriptor; return items are alert codes/messages
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_system_check($params)
{
    // array(array('name'=> $, 'severity'=>$, ...))
    $id = 1;
    $returnValues = array();
    // array(CRM_Utils_Check_Message)
    $messages = CRM_Utils_Check::singleton()->checkAll();
    foreach ($messages as $msg) {
        $returnValues[] = $msg->toArray() + array('id' => $id++);
    }
    return _civicrm_api3_basic_array_get('systemCheck', $params, $returnValues, "id", array('id', 'name', 'message', 'title', 'severity', 'is_visible'));
}
示例#15
0
 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     //  check date of last cache and compare to today's date
     $systemCheckDate = Civi::cache()->get('systemCheckDate');
     if ($systemCheckDate > strtotime("one day ago")) {
         $statusSeverity = Civi::cache()->get('systemCheckSeverity');
     }
     //  calls helper function in CRM_Utils_Check
     if (empty($statusSeverity)) {
         $statusSeverity = CRM_Utils_Check::checkAll(TRUE);
     }
     switch ($statusSeverity) {
         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');
     }
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }