diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-11-07 07:01:05 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-11-07 07:01:05 +0000 |
commit | 3a5d412efb950ab64308b6523c180b0c0f09510d (patch) | |
tree | c063f684f3bb7e01fc179bc1bb1ed757e85d36ef | |
parent | a0deec8c454ff58014f44b0e5dafde61322035df (diff) | |
download | brdo-3a5d412efb950ab64308b6523c180b0c0f09510d.tar.gz brdo-3a5d412efb950ab64308b6523c180b0c0f09510d.tar.bz2 |
#90395 by joshk, mj2308, and kkaefer. Fix book outline saving.
-rw-r--r-- | modules/book/book.module | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/modules/book/book.module b/modules/book/book.module index 9f633d907..891b2975a 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -181,13 +181,6 @@ function book_block($op = 'list', $delta = 0) { } /** - * Implementation of hook_load(). - */ -function book_load($node) { - return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); -} - -/** * Implementation of hook_insert(). */ function book_insert($node) { @@ -195,25 +188,6 @@ function book_insert($node) { } /** - * Implementation of hook_update(). - */ -function book_update($node) { - if ($node->revision) { - db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight); - } - else { - db_query("UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d", $node->parent, $node->weight, $node->vid); - } -} - -/** - * Implementation of hook_delete(). - */ -function book_delete(&$node) { - db_query('DELETE FROM {book} WHERE nid = %d', $node->nid); -} - -/** * Implementation of hook_submit(). */ function book_submit(&$node) { @@ -292,17 +266,16 @@ function book_form(&$node) { */ function book_outline($nid) { $node = node_load($nid); - $page = book_load($node); $form['parent'] = array('#type' => 'select', '#title' => t('Parent'), - '#default_value' => $page->parent, + '#default_value' => $node->parent, '#options' => book_toc($node->nid), '#description' => t('The parent page in the book.'), ); $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), - '#default_value' => $page->weight, + '#default_value' => $node->weight, '#delta' => 15, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), ); @@ -312,7 +285,7 @@ function book_outline($nid) { ); $form['nid'] = array('#type' => 'value', '#value' => $nid); - if ($page->nid) { + if ($node->parent) { $form['update'] = array('#type' => 'submit', '#value' => t('Update book outline'), ); @@ -462,14 +435,12 @@ function book_content($node, $teaser = FALSE) { */ function book_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { + case 'load': + return db_fetch_array(db_query('SELECT parent, weight FROM {book} WHERE vid = %d', $node->vid)); + break; case 'view': if (!$teaser) { - $book = db_fetch_array(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); - if ($book) { - foreach ($book as $key => $value) { - $node->$key = $value; - } - + if (isset($node->parent)) { $path = book_location($node); // Construct the breadcrumb: $node->breadcrumb = array(); // Overwrite the trail with a book trail. @@ -489,6 +460,16 @@ function book_nodeapi(&$node, $op, $teaser, $page) { } } break; + case 'update': + if (isset($node->parent)) { + if ($node->revision) { + db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight); + } + else { + db_query("UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d", $node->parent, $node->weight, $node->vid); + } + } + break; case 'delete revision': db_query('DELETE FROM {book} WHERE vid = %d', $node->vid); break; |