diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/comment.inc | 14 | ||||
-rw-r--r-- | includes/node.inc | 8 | ||||
-rw-r--r-- | includes/structure.inc | 12 | ||||
-rw-r--r-- | includes/variable.inc | 9 |
4 files changed, 24 insertions, 19 deletions
diff --git a/includes/comment.inc b/includes/comment.inc index 1a25c11c2..0d1003530 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -32,10 +32,10 @@ function comment_moderate($moderate) { foreach ($moderate as $id=>$vote) { if ($vote != $comment_votes[$none] && !user_get($user, "history", "c$id")) { - // Update the comment's score: + // update the comment's score: $result = db_query("UPDATE comments SET score = score ". check_input($vote) .", votes = votes + 1 WHERE cid = '". check_input($id) ."'"); - // Update the user's history: + // update the user's history: $user = user_set($user, "history", "c$id", $vote); } } @@ -124,22 +124,23 @@ function comment_preview($pid, $id, $subject, $comment) { function comment_post($pid, $id, $subject, $comment) { global $theme, $user; + // check comment submission rate: throttle("post comment", variable_get(max_comment_rate, 60)); - // Check for duplicate comments: + // check for duplicate comments: $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0); if ($duplicate != 0) { watchdog("warning", "comment: duplicate '$subject'"); } else { - // Validate subject: + // validate subject: $subject = ($subject) ? $subject : substr($comment, 0, 29); - // Add watchdog entry: + // add watchdog entry: watchdog("special", "comment: added '$subject'"); - // Add comment to database: + // add comment to database: db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('$id', '$pid', '$user->id', '$subject', '$comment', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')"); } } @@ -191,6 +192,7 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) { $output .= comment_order(($user->id ? $user->sort : $order)); $output .= comment_threshold(($user->id ? $user->threshold : $threshold)); $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Update settings") ."\">\n"; + $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Add comment") ."\">\n"; $output .= "</FORM>\n"; return $output; } diff --git a/includes/node.inc b/includes/node.inc index 9fc42a120..9a8b9f020 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -6,7 +6,7 @@ $rstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted); function _node_get($field, $value) { $result = db_query("SELECT lid, type FROM node WHERE $field = '$value'"); if ($node = db_fetch_object($result)) { - return db_query("SELECT n.*, l.*, c.name AS category, t.name AS topic, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid LEFT JOIN topic t ON n.tid = t.tid WHERE n.$field = '$value' ORDER BY n.timestamp DESC"); + return db_query("SELECT n.*, l.*, c.name AS category, c.comment, t.name AS topic, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid LEFT JOIN topic t ON n.tid = t.tid WHERE n.$field = '$value' ORDER BY n.timestamp DESC"); } } @@ -131,11 +131,11 @@ function node_save($node) { function node_invoke($node, $name, $arg = 0) { if ($node[type]) $function = $node[type] ."_$name"; if ($node->type) $function = $node->type ."_$name"; - if ($function) return ($arg ? $function($node) : $function($node, $arg)); + if ($function) return ($arg ? $function($node, $arg) : $function($node)); } -function node_view($node, $page = 0) { - return node_invoke($node, "view", $page); +function node_view($node, $main = 0) { + return node_invoke($node, "view", $main); } function node_form($node) { diff --git a/includes/structure.inc b/includes/structure.inc index 4326e092e..ff05b36d2 100644 --- a/includes/structure.inc +++ b/includes/structure.inc @@ -28,19 +28,19 @@ function category_del($cid) { db_query("UPDATE node SET cid = 0 WHERE cid = '". check_input($cid) ."'"); } -function category_post_threshold($cid, $default) { +function category_post_threshold($cid) { $category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); - return $category->threshold ? $category->threshold : $default; + return $category->threshold; } -function category_dump_threshold($cid, $default) { +function category_dump_threshold($cid) { $category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); - return $category->threshold ? $category->threshold : $default; + return $category->threshold; } -function category_expire_threshold($cid, $default) { +function category_expire_threshold($cid) { $category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); - return $category->threshold ? $category->threshold : $default; + return $category->threshold; } function category_form_select($type, $edit = array(), $size = 1) { diff --git a/includes/variable.inc b/includes/variable.inc index 083f7d492..fa389e511 100644 --- a/includes/variable.inc +++ b/includes/variable.inc @@ -7,15 +7,18 @@ function variable_init($conf = array()) { } function handler_post_threshold($node, $default) { - return ($threshold = category_post_threshold($node->cid) ? $threshold : $default); + $threshold = category_post_threshold($node->cid); + return $threshold ? $threshold : $default; } function handler_dump_threshold($node, $default) { - return ($threshold = category_dump_threshold($node->cid) ? $threshold : $default); + $threshold = category_dump_threshold($node->cid); + return $threshold ? $threshold : $default; } function handler_expire_threshold($node, $default) { - return ($threshold = category_expire_threshold($node->cid) ? $threshold : $default); + $threshold = category_expire_threshold($node->cid); + return $threshold ? $threshold : $default; } function variable_get($name, $default, $object = 0) { |