function sbp_paths_edit_form_submit in Search by Page 6
Same name and namespace in other branches
- 7 sbp_paths.module \sbp_paths_edit_form_submit()
Submit callback for sbp_paths_edit_form().
Adds/edits the path to be indexed, and updates database of paths.
File
- ./
sbp_paths.module, line 430 - Module file for Search by Page Paths, a sub-module for Search by Page.
Code
function sbp_paths_edit_form_submit($form, &$form_state) {
$vals = $form_state['values'];
$langs = serialize($vals['languages']);
$envid = intval($vals['environment']);
// Save the new information
if (isset($vals['pid']) && $vals['pid']) {
db_query("UPDATE {sbpp_path} SET environment=%d, page_path='%s', title='%s', page_type='%s', snippet='%s', role=%d, languages='%s' WHERE pid='%d'", $envid, $vals['path'], $vals['title'], $vals['type'], $vals['snippet'], $vals['role'], $langs, $vals['pid']);
// Force this to be reindexed
search_by_page_force_reindex('sbp_paths', $vals['pid'], $envid);
}
else {
db_query("INSERT INTO {sbpp_path} (environment, page_path, title, page_type, snippet, role, languages) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $envid, $vals['path'], $vals['title'], $vals['type'], $vals['snippet'], $vals['role'], $langs);
$vals['pid'] = db_last_insert_id('sbpp_path', 'pid');
}
// Update the translation strings
_sbp_paths_update_translation($vals);
// Go back to the paths list
drupal_set_message(t('The page to index has been saved'));
$form_state['redirect'] = 'admin/settings/search_by_page/edit/' . $envid . '/paths';
}