}
/**
- * Show status in the footer
+ * Show status in the footer (admin only)
*
* @param CRM_Core_Smarty $template
*/
public static function statusCheck($template) {
- if (CRM_Core_Config::isUpgradeMode()) {
+ if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check('administer CiviCRM')) {
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) {
+ // 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;
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_severity', $status);
$template->assign('footer_status_message', $statusMessage);
}
* Set TRUE to show all messages.
*/
public function showPeriodicAlerts($messages = NULL, $filter = array(__CLASS__, 'severityMap')) {
- if (CRM_Core_Permission::check('administer CiviCRM')
- && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityAlert', NULL, TRUE)
- ) {
+ if (CRM_Core_Permission::check('administer CiviCRM')) {
$session = CRM_Core_Session::singleton();
if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) {
break;
}
- Civi::cache()->set('systemCheckSeverity', $maxSeverity);
- $timestamp = time();
- Civi::cache()->set('systemCheckDate', $timestamp);
+ Civi::settings()->set('systemStatusCheckResult', $maxSeverity);
return ($max) ? $maxSeverity : $messages;
}
'description' => NULL,
'help_text' => NULL,
),
+ 'systemStatusCheckResult' => array(
+ 'group_name' => 'CiviCRM Preferences',
+ 'group' => 'core',
+ 'name' => 'systemStatusCheckResult',
+ 'type' => 'Integer',
+ 'default' => 0,
+ 'add' => '4.7',
+ 'title' => NULL,
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'description' => NULL,
+ 'help_text' => NULL,
+ ),
);
<div class="crm-footer" id="civicrm-footer">
{crmVersion assign=version}
{ts 1=$version}Powered by CiviCRM %1.{/ts}
- {if $footer_status_severity}
+ {if !empty($footer_status_severity)}
<span class="status{if $footer_status_severity gt 3} crm-error{elseif $footer_status_severity gt 2} crm-warning{else} crm-ok{/if}">
<a href="{crmURL p='civicrm/a/#/status'}">{$footer_status_message}</a>
</span>