function book_outline_submit in Drupal 5
Same name and namespace in other branches
- 4 modules/book.module \book_outline_submit()
Handles book outline form submissions.
File
- modules/
book/ book.module, line 298 - Allows users to collaboratively author a book.
Code
function book_outline_submit($form_id, $form_values) {
$op = $form_values['op'];
$node = node_load($form_values['nid']);
switch ($op) {
case t('Add to book outline'):
db_query('INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)', $node->nid, $node->vid, $form_values['parent'], $form_values['weight']);
db_query("UPDATE {node_revisions} SET log = '%s' WHERE vid = %d", $form_values['log'], $node->vid);
drupal_set_message(t('The post has been added to the book.'));
break;
case t('Update book outline'):
db_query('UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d', $form_values['parent'], $form_values['weight'], $node->vid);
db_query("UPDATE {node_revisions} SET log = '%s' WHERE vid = %d", $form_values['log'], $node->vid);
drupal_set_message(t('The book outline has been updated.'));
break;
case t('Remove from book outline'):
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
drupal_set_message(t('The post has been removed from the book.'));
break;
}
return "node/{$node->nid}";
}