summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-11-24 15:10:36 +0000
committerDries Buytaert <dries@buytaert.net>2001-11-24 15:10:36 +0000
commiteb7c5f60b965bb1385a4b209041ae99181fae3f5 (patch)
treeda0ac82db614621e62fc07a5c1ba0db76476f83f /modules
parentcd40123540f6b76e93fe3e4d87edba5aafc05018 (diff)
downloadbrdo-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')
-rw-r--r--modules/book.module50
-rw-r--r--modules/book/book.module50
-rw-r--r--modules/node.module13
-rw-r--r--modules/node/node.module13
-rw-r--r--modules/system.module2
-rw-r--r--modules/system/system.module2
6 files changed, 96 insertions, 34 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:
diff --git a/modules/book/book.module b/modules/book/book.module
index 0073ca449..ea48b56fd 100644
--- a/modules/book/book.module
+++ b/modules/book/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:
diff --git a/modules/node.module b/modules/node.module
index 6b0dd88fe..b0e587a8b 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -150,7 +150,7 @@ function node_link($type, $node = 0, $main = 0) {
if (module_invoke($node->type, "access", "update", $node)) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\">". t("edit") ."</a>";
}
-
+
if (user_access("administer nodes")) {
$links[] = "<a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("administer") ."</a>";
}
@@ -232,7 +232,7 @@ function node_admin_edit($node) {
$output .= "<h3>". t("Edit comments") ."</h3>";
- $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '". $node["nid"] ."' ORDER BY c.timestamp");
+ $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '$node->nid' ORDER BY c.timestamp");
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>title</th><th>author</th><th colspan=\"3\">operations</th></tr>";
@@ -474,6 +474,7 @@ function node_validate($node, $error = array()) {
$node = node_object($node);
+
/*
** Validate the title field:
*/
@@ -756,6 +757,14 @@ function node_submit($node) {
$node = node_validate($node);
/*
+ ** Apply the filters:
+ */
+
+ $node->teaser = filter($node->teaser);
+ $node->title = filter($node->title);
+ $node->body = filter($node->body);
+
+ /*
** Create a new revision when required:
*/
diff --git a/modules/node/node.module b/modules/node/node.module
index 6b0dd88fe..b0e587a8b 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -150,7 +150,7 @@ function node_link($type, $node = 0, $main = 0) {
if (module_invoke($node->type, "access", "update", $node)) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\">". t("edit") ."</a>";
}
-
+
if (user_access("administer nodes")) {
$links[] = "<a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("administer") ."</a>";
}
@@ -232,7 +232,7 @@ function node_admin_edit($node) {
$output .= "<h3>". t("Edit comments") ."</h3>";
- $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '". $node["nid"] ."' ORDER BY c.timestamp");
+ $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '$node->nid' ORDER BY c.timestamp");
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>title</th><th>author</th><th colspan=\"3\">operations</th></tr>";
@@ -474,6 +474,7 @@ function node_validate($node, $error = array()) {
$node = node_object($node);
+
/*
** Validate the title field:
*/
@@ -756,6 +757,14 @@ function node_submit($node) {
$node = node_validate($node);
/*
+ ** Apply the filters:
+ */
+
+ $node->teaser = filter($node->teaser);
+ $node->title = filter($node->title);
+ $node->body = filter($node->body);
+
+ /*
** Create a new revision when required:
*/
diff --git a/modules/system.module b/modules/system.module
index 6a450eea9..70a28555f 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -50,8 +50,6 @@ function system_view_options() {
// submission settings:
$output .= "<h3>Submission settings</h3>\n";
- $size = array(1000 => "1.000 characters", 5000 => "5.000 characters", 10000 => "10.000 characters", 15000 => "15.000 characters", 30.000 => "30.000 characters", 50000 => "50.000 characters", 100000 => "100.000 characters");
- $output .= form_select("Maximum submission size", "max_input_size", variable_get("max_input_size", 10000), $size, "The maximum number of characters someone can enter in a form.");
$rate = array(1 => "Maximum 1 every second", 5 => "Maximum 1 every 5 seconds", 15 => "Maximum 1 every 15 seconds", 30 => "Maximum 1 every 30 seconds", 60 => "Maximum 1 every minute", 300 => "Maximum 1 every 5 minutes", 900 => "Maximum 1 every 15 minutes", 1800 => "Maximum 1 every 30 minutes", 3600 => "Maximum 1 every hour", 21600 => "Maximum 1 every 6 hours", 43200 => "Maximum 1 every 12 hours");
$output .= form_select("Maximum node rate", "max_node_rate", variable_get("max_node_rate", 900), $rate, "The maximum submission rate for nodes. Its purpose is to stop potential abuse or denial of service attacks.");
$output .= form_select("Maximum comment rate", "max_comment_rate", variable_get("max_comment_rate", 120), $rate, "The maximum submission rate for comments. Its purpose is to stop potential abuse or denial of service attacks.");
diff --git a/modules/system/system.module b/modules/system/system.module
index 6a450eea9..70a28555f 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -50,8 +50,6 @@ function system_view_options() {
// submission settings:
$output .= "<h3>Submission settings</h3>\n";
- $size = array(1000 => "1.000 characters", 5000 => "5.000 characters", 10000 => "10.000 characters", 15000 => "15.000 characters", 30.000 => "30.000 characters", 50000 => "50.000 characters", 100000 => "100.000 characters");
- $output .= form_select("Maximum submission size", "max_input_size", variable_get("max_input_size", 10000), $size, "The maximum number of characters someone can enter in a form.");
$rate = array(1 => "Maximum 1 every second", 5 => "Maximum 1 every 5 seconds", 15 => "Maximum 1 every 15 seconds", 30 => "Maximum 1 every 30 seconds", 60 => "Maximum 1 every minute", 300 => "Maximum 1 every 5 minutes", 900 => "Maximum 1 every 15 minutes", 1800 => "Maximum 1 every 30 minutes", 3600 => "Maximum 1 every hour", 21600 => "Maximum 1 every 6 hours", 43200 => "Maximum 1 every 12 hours");
$output .= form_select("Maximum node rate", "max_node_rate", variable_get("max_node_rate", 900), $rate, "The maximum submission rate for nodes. Its purpose is to stop potential abuse or denial of service attacks.");
$output .= form_select("Maximum comment rate", "max_comment_rate", variable_get("max_comment_rate", 120), $rate, "The maximum submission rate for comments. Its purpose is to stop potential abuse or denial of service attacks.");