// How often to run checks and notify admins about issues.
const CHECK_TIMER = 86400;
+ /**
+ * @var array
+ * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
+ */
+ public static $severityMap = array(
+ \Psr\Log\LogLevel::DEBUG,
+ \Psr\Log\LogLevel::INFO,
+ \Psr\Log\LogLevel::NOTICE,
+ \Psr\Log\LogLevel::WARNING,
+ \Psr\Log\LogLevel::ERROR,
+ \Psr\Log\LogLevel::CRITICAL,
+ \Psr\Log\LogLevel::ALERT,
+ \Psr\Log\LogLevel::EMERGENCY,
+ );
+
/**
* We only need one instance of this object, so we use the
* singleton pattern and cache the instance in this variable
$severity = strtolower($severity);
}
- // See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
- $levels = array(
- \Psr\Log\LogLevel::EMERGENCY => 7,
- \Psr\Log\LogLevel::ALERT => 6,
- \Psr\Log\LogLevel::CRITICAL => 5,
- \Psr\Log\LogLevel::ERROR => 4,
- \Psr\Log\LogLevel::WARNING => 3,
- \Psr\Log\LogLevel::NOTICE => 2,
- \Psr\Log\LogLevel::INFO => 1,
- \Psr\Log\LogLevel::DEBUG => 0,
- );
- return ($reverse) ? array_search($severity, $levels) : $levels[$severity];
+ return ($reverse) ? self::$severityMap[$severity] : array_search($severity, self::$severityMap);
}
/**
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
*/
function _civicrm_api3_system_check_spec(&$spec) {
- // $spec['magicword']['api.required'] = 1;
+ $spec['id'] = array(
+ 'title' => 'ID',
+ 'description' => 'Not a real identifier - do not use',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ $spec['name'] = array(
+ 'title' => 'Name',
+ 'description' => 'Unique identifier',
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $spec['title'] = array(
+ 'title' => 'Title',
+ 'description' => 'Short title text',
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $spec['message'] = array(
+ 'title' => 'Message',
+ 'description' => 'Long description html',
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $spec['help'] = array(
+ 'title' => 'Help',
+ 'description' => 'Optional extra help (html string)',
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $spec['severity'] = array(
+ 'title' => 'Severity',
+ 'description' => 'Integer representation of Psr\Log\LogLevel',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'options' => CRM_Utils_Check::$severityMap,
+ );
$spec['is_visible'] = array(
'title' => 'is visible',
+ 'description' => '0 if message has been hidden by the user',
'type' => CRM_Utils_Type::T_BOOLEAN,
);
+ $spec['hidden_until'] = array(
+ 'title' => 'Hidden_until',
+ 'description' => 'When will hidden message be visible again?',
+ 'type' => CRM_Utils_Type::T_DATE,
+ );
}
/**
function civicrm_api3_system_check($params) {
// array(array('name'=> $, 'severity'=>$, ...))
$id = 1;
- $returnValues = array();
+ $returnValues = $fields = array();
+ _civicrm_api3_system_check_spec($fields);
// array(CRM_Utils_Check_Message)
- $messages = CRM_Utils_Check::singleton()->checkAll();
+ $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('id', 'name', 'message', 'title', 'severity', 'is_visible'));
+ return _civicrm_api3_basic_array_get('systemCheck', $params, $returnValues, "id", array_keys($fields));
}
/**