function _prod_check_search_config in Production check & Production monitor 7
Same name and namespace in other branches
- 6 prod_check.module \_prod_check_search_config()
File
- ./
prod_check.module, line 1565
Code
function _prod_check_search_config($caller = 'internal') {
if (!module_exists('search')) {
return;
}
$check = array();
$error = FALSE;
$title = 'Search config';
$path = 'admin/people/permissions';
$fragment = 'module-search_config';
$str_anonymous_content = $severity = $value_nok = $msg_nok = $msg_ok = '';
if ($caller != 'internal') {
$path = PRODCHECK_BASEURL . $path;
}
if (!module_exists('search_config')) {
$error = TRUE;
$severity = $caller == 'nagios' ? NAGIOS_STATUS_WARNING : PROD_CHECK_REQUIREMENT_WARNING;
$value_nok = t('Disabled');
$msg_nok = t('You have not enabled the !link module. Please double check if you need this module or not, to be able to hide certain content types from being searched by users.', prod_check_link_array($title, 'http://drupal.org/project/search_config'));
}
else {
$check_anonymous_search_all = db_query("SELECT rid, permission, module FROM {role_permission} WHERE rid = 1 AND module = 'search_config' AND permission = 'search all content'")
->fetchField();
$check_anonymous_content_types = db_query("SELECT permission, module FROM {role_permission} WHERE rid = 1 AND module = 'search_config'")
->fetchCol();
if ($check_anonymous_search_all == 1) {
$error = TRUE;
$msg_nok = t('You have enabled the !link module, but anonymous users can search every content type!', prod_check_link_array($title, $path, $fragment));
}
else {
$error = FALSE;
$str_anonymous_content = implode(', ', $check_anonymous_content_types);
$msg_ok = t('You have enabled the !link module, anonymous users can search for "!content_types" -content type(s).', array(
'!link' => implode(prod_check_link_array($title, $path, $fragment)),
'!content_types' => $str_anonymous_content,
));
}
if ($error) {
$severity = $caller == 'nagios' ? NAGIOS_STATUS_CRITICAL : PROD_CHECK_REQUIREMENT_ERROR;
$value_nok = t('Not properly configured.');
}
}
$check['prod_check_search_config'] = array(
'#title' => t($title),
'#state' => !$error,
'#severity' => $severity,
'#value_ok' => t('Enabled'),
'#value_nok' => $value_nok,
'#description_ok' => $msg_ok,
'#description_nok' => $msg_nok,
'#nagios_key' => 'SRCH',
'#nagios_type' => 'state',
);
return prod_check_execute_check($check, $caller);
}