function _prod_check_contact in Production check & Production monitor 6
Same name and namespace in other branches
- 7 prod_check.module \_prod_check_contact()
File
- ./
prod_check.module, line 1395
Code
function _prod_check_contact($caller = 'internal') {
if (!module_exists('contact')) {
return;
}
$check = array();
$error = FALSE;
$title = 'Contact';
$path = 'admin/structure/contact';
if ($caller != 'internal') {
$path = PRODCHECK_BASEURL . $path;
}
// Check all mails in the contact table.
$prod_check_sitemail = preg_quote(variable_get('prod_check_sitemail', ''));
$categories = array();
$result = db_query('SELECT category, recipients FROM {contact}');
while ($row = db_fetch_object($result)) {
$recipients = explode(',', $row->recipients);
foreach ($recipients as $mail) {
if (preg_match('/' . $prod_check_sitemail . '/i', $mail)) {
$categories[] = $row->category . ': ' . $mail;
$error = TRUE;
}
}
}
$arguments = array(
'!contact' => $title,
'%categories' => implode(', ', $categories),
);
$check['prod_check_contact'] = array(
'#title' => t($title),
'#state' => !$error,
'#severity' => $caller == 'nagios' ? NAGIOS_STATUS_CRITICAL : PROD_CHECK_REQUIREMENT_ERROR,
'#value_ok' => t('!contact e-mail addresses are OK.', $arguments),
'#value_nok' => t('!contact e-mail addresses are %categories', $arguments),
'#description_ok' => prod_check_ok_title($title, $path),
'#description_nok' => t('The !link recepient e-mail addresses should not be development addresses on production sites!', prod_check_link_array($title, $path)),
'#nagios_key' => 'CNT',
'#nagios_type' => 'state',
);
return prod_check_execute_check($check, $caller);
}