function faq_order_settings_reorder_form_submit in Frequently Asked Questions 6
Same name and namespace in other branches
- 7.2 faq.admin.inc \faq_order_settings_reorder_form_submit()
- 7 faq.admin.inc \faq_order_settings_reorder_form_submit()
Save the options set by the user in the FAQ Settings - Weight tab.
Parameters
$form: Array, containing the form structure.
&$form_state: $form_state['values'] stores the submitted values from the form.
1 string reference to 'faq_order_settings_reorder_form_submit'
- faq_order_settings_form in ./
faq.admin.inc - Define the elements for the FAQ Settings page - order tab.
File
- ./
faq.admin.inc, line 501 - Administrative page callbacks for the faq module.
Code
function faq_order_settings_reorder_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Save order') && !empty($form_state['values']['order_no_cats'])) {
foreach ($form_state['values']['order_no_cats'] as $i => $faq) {
$nid = $faq['nid'];
$index = $faq['sort'];
$result = db_query("DELETE FROM {faq_weights} WHERE tid = %d AND nid = %d", $form_state['values']['faq_category'], $nid);
$result = db_query("INSERT INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_state['values']['faq_category'], $nid, $index);
// If node translation module enabled, update order of the translation
// node counterparts.
if (module_exists('translation')) {
$node = node_load($nid);
if ($node->tnid) {
$translations = translation_node_get_translations($node->tnid);
if (!empty($translations)) {
foreach ($translations as $language => $tnode) {
$result = db_query("DELETE FROM {faq_weights} WHERE tid = %d AND nid = %d", $form_state['values']['faq_category'], $tnode->nid);
$result = db_query("INSERT INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_state['values']['faq_category'], $tnode->nid, $index);
}
}
}
}
}
drupal_set_message(t('Configuration has been updated.'));
}
}