From a95c2a68aaededb5538da3df4d40c88879c4c45d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 30 Dec 2001 16:16:38 +0000 Subject: - import.module: + Improved input filtering; this should make the news items look more consistent in terms of mark-up. + Quoted all array indices: converted all instances of $foo[bar] to $foo["bar"]. Made various other changes to make the import module compliant with the coding style. - theme.inc: + Fixed small XHTML glitch - comment system: + Made it possible for users to edit their comments (when certain criteria are matched). + Renamed the SQL table field "lid" to "nid" and updated the code to reflect this change: this is a rather /annoying/ change that has been asked for a few times. It will impact the contributed BBS/forum modules and requires a tiny SQL update: sql> ALTER TABLE comments CHANGE lid nid int(10) NOT NULL; + Moved most (all?) of the comment related logic from node.php to comment.module where it belongs. This also marks a first step towards removing/reducing "node.php". + Added a delete button to the comment admin form and made it so that Drupal prompts for confirmation prior to deleting a comment from the database. This behavior is similar to that of deleting nodes. + Disabled comment moderation for now. + Some of the above changes will make it easier to integrate the upcomcing mail-to-web and web-to-mail gateways. They are part of a bigger plan. ;) - node system: + Made it so that updating nodes (like for instance updating blog entries) won't trigger the submission rate throttle. + Fixed a small glitch where a node's title wasn't always passed to the $theme->header() function. + Made "node_array()" and "node_object()" more generic and named them "object2array()" and "array2object()". + Moved most (all?) of the comment related logic from node.php to comment.module where it belongs. This also marks a first step towards removing/reducing "node.php". - misc: + Applied three patches by Foxen. One to improve performance of the book module, and two other patches to fix small glitches in common.inc. Thanks Foxen! --- modules/node.module | 58 ++++++++++++----------------------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) (limited to 'modules/node.module') diff --git a/modules/node.module b/modules/node.module index 60c9af813..52e6a3d48 100644 --- a/modules/node.module +++ b/modules/node.module @@ -19,7 +19,7 @@ function node_index() { } function node_get_comments($nid) { - $comment = db_fetch_object(db_query("SELECT COUNT(c.lid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.lid WHERE n.nid = '$nid' GROUP BY n.nid")); + $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '$nid' GROUP BY n.nid")); return $comment->number ? $comment->number : 0; } @@ -67,34 +67,6 @@ function node_invoke($node, $name, $arg = 0) { } } -function node_object($node) { - - if (is_array($node)) { - foreach ($node as $key => $value) { - $object->$key = $value; - } - } - else { - $object = $node; - } - - return $object; -} - -function node_array($node) { - - if (is_object($node)) { - foreach ($node as $key => $value) { - $array[$key] = $value; - } - } - else { - $array = $node; - } - - return $array; -} - function node_load($conditions) { /* @@ -232,9 +204,7 @@ function node_save($node, $filter) { function node_view($node, $main = 0) { global $theme; - if (is_array($node)) { - $node = node_object($node); - } + $node = array2object($node); /* ** The "view" hook can be implemented to overwrite the default function @@ -265,9 +235,7 @@ function node_access($op, $node = 0) { ** Convert the node to an object if necessary: */ - if (is_array($node)) { - $node = node_object($node); - } + $node = array2object($node); /* ** Construct a function: @@ -720,7 +688,7 @@ function node_validate($node, &$error) { ** Convert the node to an object if necessary: */ - $node = node_object($node); + $node = array2object($node); /* ** Validate the title field: @@ -950,7 +918,7 @@ function node_preview($node) { ** Convert the array to an object: */ - $node = node_object($node); + $node = array2object($node); /* ** Load the user's name when needed: @@ -1007,13 +975,6 @@ function node_submit($node) { if (user_access("post content")) { - /* - ** Verify a user's submission rate and avoid duplicate nodes being - ** inserted: - */ - - throttle("node", variable_get("max_node_rate", 900)); - /* ** Fixup the node when required: */ @@ -1067,6 +1028,13 @@ function node_submit($node) { if (node_access("create", $node)) { + /* + ** Verify a user's submission rate and avoid duplicate nodes being + ** inserted: + */ + + throttle("node", variable_get("max_node_rate", 900)); + /* ** Compile a list of the node fields and their default values that users ** and administrators are allowed to save when inserting a new node. @@ -1135,7 +1103,7 @@ function node_delete($edit) { */ db_query("DELETE FROM node WHERE nid = '$node->nid'"); - db_query("DELETE FROM comments WHERE lid = '$node->nid'"); + db_query("DELETE FROM comments WHERE nid = '$node->nid'"); /* ** Call the node specific callback (if any): -- cgit v1.2.3