diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-11-24 15:10:36 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-11-24 15:10:36 +0000 |
commit | eb7c5f60b965bb1385a4b209041ae99181fae3f5 (patch) | |
tree | da0ac82db614621e62fc07a5c1ba0db76476f83f /modules/book.module | |
parent | cd40123540f6b76e93fe3e4d87edba5aafc05018 (diff) | |
download | brdo-eb7c5f60b965bb1385a4b209041ae99181fae3f5.tar.gz brdo-eb7c5f60b965bb1385a4b209041ae99181fae3f5.tar.bz2 |
- Bugfix: when updating a book page, the name of the author did not change.
- Bugfix: the "Edit comments" part of the node administration pages did not
display the correct comments.
- Bugfix: somethimes, update in a book page would mess up the book.
- Improvement: when "node administrators" update a book page through the
"update this book page"-link (like regular users do), their update will
be subject to moderation.
- Improvement: made some intermediate changes to the filter mechanism. Needs
more work.
Diffstat (limited to 'modules/book.module')
-rw-r--r-- | modules/book.module | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/modules/book.module b/modules/book.module index 0073ca449..ea48b56fd 100644 --- a/modules/book.module +++ b/modules/book.module @@ -24,7 +24,7 @@ function book_access($op, $node) { return $node->status; } - if ($op == "create") { + if ($op == "create") { return 1; } @@ -36,12 +36,12 @@ function book_access($op, $node) { ** revision"-bit is set; that is, only updates that don't overwrite ** the current or pending information are allowed. */ - return !$node->moderate && $node->revision; } } function book_save($op, $node) { + global $user, $REQUEST_URI; if ($op == "approve") { return array("status" => 1); @@ -56,22 +56,25 @@ function book_save($op, $node) { } if ($op == "update") { - if (user_access("administer nodes")) { + if (strstr($REQUEST_URI, "module.php?mod=node&op=edit")) { /* - ** If a node administrator updates a book page, we don't create a - ** new revision unless we are explicitly instructed to. + ** If a regular user updates a book page, we always create a new + ** revision. All new revisions have to be approved (moderation) + ** and are not promoted by derault. See also: book_load(). */ - return array("parent", "weight"); + return array("created" => time(), "moderate" => 1, "name" => $user->name, "parent", "promote" => 0, "score" => 0, "status" => 1, "uid" => $user->uid, "users" => "", "revisions", "votes" => 0, "weight"); } - else { + else if (user_access("adminster nodes")) { /* - ** If a regular user updates a book page, we always create a new - ** revision. All new revisions have to be approved (moderation) - ** and are not promoted by derault. + ** If a node administrator updates a book page, we don't create a + ** new revision unless we are explicitly instructed to. If a node + ** administrator updates a book page using the "update this book + ** page"-link (like regular users do) then he'll be treated as a + ** regular user. */ - return array("created" => time(), "moderate" => 1, "parent", "promote" => 0, "score" => 0, "status" => 1, "users" => "", "revisions", "votes" => 0, "weight"); + return array("parent", "weight"); } } @@ -90,7 +93,29 @@ function book_link($type) { } function book_load($node) { - $book = db_fetch_object(db_query("SELECT parent, weight, revision FROM book WHERE nid = '$node->nid'")); + global $user, $REQUEST_URI; + + $book = db_fetch_object(db_query("SELECT parent, weight FROM book WHERE nid = '$node->nid'")); + + if (strstr($REQUEST_URI, "module.php?mod=node&op=edit")) { + /* + ** If a user is about to update a book page, we overload some + ** fields to reflect the changes. We use the $REQUEST_URI to + ** dectect this as we don't want to interfer with updating a + ** book page through the admin pages. See also: book_save(). + */ + + $book->name = $user->name; + $book->uid = $user->uid; + } + + /* + ** We set the revision field to indicate that we have to create + ** a new revision when updating this book page. + */ + + $book->revision = 1; + return $book; } @@ -125,7 +150,6 @@ function book_form($node, $help, $error) { $help = book_node("description"); - /* ** If a regular user updates a book page, we create a new revision ** authored by that user: |