function search_autocomplete_form_configure_submit in Search Autocomplete 7.3
Same name and namespace in other branches
- 6.4 search_autocomplete.form.configure.inc \search_autocomplete_form_configure_submit()
- 6.2 search_autocomplete.form.configure.inc \search_autocomplete_form_configure_submit()
- 7.4 search_autocomplete.form.configure.inc \search_autocomplete_form_configure_submit()
- 7.2 search_autocomplete.form.configure.inc \search_autocomplete_form_configure_submit()
Implements hook_submit(). Save the changes in the database
File
- ./
search_autocomplete.form.configure.inc, line 205 - Search Autocomplete Helper functions to retrive suggestions from database
Code
function search_autocomplete_form_configure_submit($form, &$form_state) {
global $base_url;
$ok_query = TRUE;
// so far so good!
// get form submission values
$values = $form_state['values'];
//Update the database with the new values
$what = '';
$sids = '';
$weights = '';
// analyse incoming callback
$callback = $values['callback_textfield'];
$data_type = 2;
// if static resource => type = 2
if ($callback != '') {
if (url_is_external($callback)) {
// if path is absolute:
if (strcmp(substr($callback, 0, strlen($base_url)), $base_url) === 0) {
// if path is internal:
$callback = str_replace($base_url . "/", "", $callback);
// get it relative
$data_type = 1;
// type = 1
}
else {
// if external: type = 0
$data_type = 0;
}
}
else {
// if path is not absolute:
$data_type = 1;
}
}
if ($values['suggestions'] == 2) {
$data_type = 2;
}
// ###
// UPDATE THE FORM
// -> update form
db_update('search_autocomplete_forms')
->fields(array(
'min_char' => $values['min_char'],
'max_sug' => $values['max_sug'],
'auto_submit' => $values['auto_submit'],
'auto_redirect' => $values['auto_redirect'],
'no_results' => $values['no_results'],
'selector' => $values['selector'],
'data_source' => $data_type,
'data_callback' => $callback,
'data_static' => $values['staticresource_textfield'],
'theme' => $values['theme'],
))
->condition('fid', $values['fid'])
->execute();
// ###
// UPDATE CHILD LIST BUT NOT THE ADVANCED OPTIONS
$fids = _search_autocomplete_get_all_children($values['fid']);
// update the settings for this form + every children form
foreach ($fids as $fid) {
// -> update form
db_update('search_autocomplete_forms')
->fields(array(
'min_char' => $values['min_char'],
'max_sug' => $values['max_sug'],
'no_results' => $values['no_results'],
'auto_submit' => $values['auto_submit'],
'auto_redirect' => $values['auto_redirect'],
'theme' => $values['theme'],
))
->condition('fid', $fid)
->execute();
}
// ###
drupal_clear_css_cache();
$form_state['redirect'] = 'admin/config/search/search_autocomplete';
$ok_query ? drupal_set_message(t("Configuration success !")) : drupal_set_message(t("An error has occured while saving the settings. Please, double check your settings!"), 'error');
}