function search_config_validate in Search configuration 5
Same name and namespace in other branches
- 6 search_config.module \search_config_validate()
File
- ./
search_config.module, line 273 - Used to configure the advanced search form and other search behaviour.
Code
function search_config_validate($form_values) {
if ($form_values['#post']['form_id'] == 'search_admin_settings' && $form_values['#post']['op'] == 'Save configuration') {
$post_values = $form_values['#post'];
$node_types = node_get_types('names');
if (!isset($post_values['search_config_disable_index_type'])) {
return;
}
$index_types = $post_values['search_config_disable_index_type'];
if (!isset($post_values['search_config_disable_type'])) {
$post_values['search_config_disable_type'] = array();
}
$form_types = $post_values['search_config_disable_type'];
if (count($index_types) != 0 && count($index_types) == count($node_types)) {
form_set_error('search_config_disable_index_type', t('You can not set all node types to be not indexed by the search module. Disable the search module if that is what you want.'));
}
if (isset($post_values['search_config_disable_type']['all'])) {
return;
}
$type_diff = array_diff($index_types, $form_types);
if (count($type_diff)) {
$node_errors = array();
foreach ($type_diff as $type) {
$node_errors[] = $node_types[$type];
}
form_set_error('search_config_disable_type', t('Search index node types do not match form node types. Please check the setting for %nodes.', array(
'%nodes' => implode(', ', $node_errors),
)));
}
}
}