function support_search_validate in Support Ticketing System 7
Same name and namespace in other branches
- 6 support.module \support_search_validate()
Form API callback for the search form. Registered in support_form_alter().
1 string reference to 'support_search_validate'
- support_form_alter in ./
support.module - Customize comment form for ticket followups.
File
- ./
support.module, line 2245 - support.module
Code
function support_search_validate($form, &$form_state) {
// Initialise using any existing basic search keywords.
$keys = $form_state['values']['processed_keys'];
// Insert extra restrictions into the search keywords string.
if (isset($form_state['values']['client']) && is_array($form_state['values']['client'])) {
if (count($form_state['values']['client'])) {
$keys = search_expression_insert($keys, 'client', implode(',', array_keys($form_state['values']['client'])));
}
}
if (isset($form_state['values']['state']) && is_array($form_state['values']['state'])) {
if (count($form_state['values']['state'])) {
$keys = search_expression_insert($keys, 'state', implode(',', array_keys($form_state['values']['state'])));
}
}
if (isset($form_state['values']['priority']) && is_array($form_state['values']['priority'])) {
if (count($form_state['values']['priority'])) {
$keys = search_expression_insert($keys, 'priority', implode(',', array_keys($form_state['values']['priority'])));
}
}
if ($form_state['values']['negative'] != '') {
if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['negative'], $matches)) {
$keys .= ' -' . implode(' -', $matches[1]);
}
}
if ($form_state['values']['phrase'] != '') {
$keys .= ' "' . str_replace('"', ' ', $form_state['values']['phrase']) . '"';
}
if (!empty($keys)) {
form_set_value($form['basic']['processed_keys'], trim($keys), $form_state);
}
}