function nodeorder_taxonomy_form_vocabulary_submit in Node Order 5
Same name and namespace in other branches
- 6 nodeorder.module \nodeorder_taxonomy_form_vocabulary_submit()
- 7 nodeorder.module \nodeorder_taxonomy_form_vocabulary_submit()
Accept the form submission for a vocabulary and save the results.
File
- ./
nodeorder.module, line 35
Code
function nodeorder_taxonomy_form_vocabulary_submit($form_id, $form_values) {
$vid = $form_values['vid'];
if ($form_values['orderable']) {
if ($form_values['module'] != 'nodeorder') {
// Switching from non-orderable to orderable...
// Set weight_in_tid to nid for all rows in term_node where
// the tid is in this vocabulary...
$tree = taxonomy_get_tree($vid);
$tids = array();
foreach ($tree as $term) {
$tids[] = $term->tid;
}
if (count($tids) > 0) {
db_query("UPDATE {term_node} SET weight_in_tid = nid WHERE tid IN (" . implode(',', $tids) . ")");
}
db_query("UPDATE {vocabulary} SET module = '%s' WHERE vid = %d", 'nodeorder', $vid);
drupal_set_message(t('You may now order nodes within this vocabulary.'));
}
}
else {
if ($form_values['module'] == 'nodeorder') {
// Switching from orderable to non-orderable...
db_query("UPDATE {vocabulary} SET module = '%s' WHERE vid = %d", 'taxonomy', $vid);
// Set weight_in_tid to 0 for all rows in term_node where
// the tid is in this vocabulary...
$tree = taxonomy_get_tree($vid);
$tids = array();
foreach ($tree as $term) {
$tids[] = $term->tid;
}
if (count($tids) > 0) {
db_query("UPDATE {term_node} SET weight_in_tid = 0 WHERE tid IN (" . implode(',', $tids) . ")");
}
drupal_set_message(t('You may no longer order nodes within this vocabulary.'));
}
}
}