From 32b4c92952d3061073c3f7f66b1cd68a10c20c88 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 5 Jun 2006 09:00:22 +0000 Subject: - Patch #67229 by chx: cleaned up book_load(). --- modules/book.module | 22 ++++------------------ modules/book/book.module | 22 ++++------------------ 2 files changed, 8 insertions(+), 36 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 04b76f882..e94cfb50b 100644 --- a/modules/book.module +++ b/modules/book.module @@ -178,24 +178,7 @@ function book_block($op = 'list', $delta = 0) { * Implementation of hook_load(). */ function book_load($node) { - global $user; - - $book = db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); - - if (arg(2) == 'edit' && !user_access('administer nodes')) { - // If a user is about to update a book page, we overload some - // fields to reflect the changes. - if ($user->uid) { - $book->uid = $user->uid; - $book->name = $user->name; - } - else { - $book->uid = 0; - $book->name = ''; - } - } - - return $book; + return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); } /** @@ -228,10 +211,13 @@ function book_delete(&$node) { * Implementation of hook_submit(). */ function book_submit(&$node) { + global $user; // Set default values for non-administrators. if (!user_access('administer nodes')) { $node->weight = 0; $node->revision = 1; + $book->uid = $user->uid; + $book->name = $user->uid ? $user->name : ''; } } diff --git a/modules/book/book.module b/modules/book/book.module index 04b76f882..e94cfb50b 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -178,24 +178,7 @@ function book_block($op = 'list', $delta = 0) { * Implementation of hook_load(). */ function book_load($node) { - global $user; - - $book = db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); - - if (arg(2) == 'edit' && !user_access('administer nodes')) { - // If a user is about to update a book page, we overload some - // fields to reflect the changes. - if ($user->uid) { - $book->uid = $user->uid; - $book->name = $user->name; - } - else { - $book->uid = 0; - $book->name = ''; - } - } - - return $book; + return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); } /** @@ -228,10 +211,13 @@ function book_delete(&$node) { * Implementation of hook_submit(). */ function book_submit(&$node) { + global $user; // Set default values for non-administrators. if (!user_access('administer nodes')) { $node->weight = 0; $node->revision = 1; + $book->uid = $user->uid; + $book->name = $user->uid ? $user->name : ''; } } -- cgit v1.2.3