You are here

function _prod_check_search_config in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 prod_check.module \_prod_check_search_config()

File

./prod_check.module, line 1491

Code

function _prod_check_search_config($caller = 'internal') {
  if (!module_exists('search')) {
    return;
  }
  $check = array();
  $error = FALSE;
  $title = 'Search config';
  $path = 'admin/settings/search';
  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 {
    $search_config = variable_get('search_config_disable_type', array());
    $error = TRUE;
    foreach ($search_config as $key => $value) {
      if (is_string($value)) {
        $error = FALSE;
        break;
      }
    }
    if ($error) {
      $severity = $caller == 'nagios' ? NAGIOS_STATUS_CRITICAL : PROD_CHECK_REQUIREMENT_ERROR;
      $value_nok = t('Not properly configured.');
      $msg_nok = t('You have enabled the !link module, but no content types are excluded from being searched!', prod_check_link_array($title, $path));
    }
  }
  $check['prod_check_search_config'] = array(
    '#title' => t($title),
    '#state' => !$error,
    '#severity' => $severity,
    '#value_ok' => t('Enabled'),
    '#value_nok' => $value_nok,
    '#description_ok' => prod_check_ok_title($title, $path),
    '#description_nok' => $msg_nok,
    '#nagios_key' => 'SRCH',
    '#nagios_type' => 'state',
  );
  return prod_check_execute_check($check, $caller);
}