summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-19 19:59:48 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-19 19:59:48 +0000
commit3f1979aa3cfa2d50789e88bd0a857dec6babb44b (patch)
tree00a5170b8db220163950343292e0e7f966c80549 /includes
parenta6e6dfb9219ebea34331ad46c9c43d53f7c3ca6f (diff)
downloadbrdo-3f1979aa3cfa2d50789e88bd0a857dec6babb44b.tar.gz
brdo-3f1979aa3cfa2d50789e88bd0a857dec6babb44b.tar.bz2
- Addition: made it so that comments can be enabled/disabled on
a node per node basis, rather then on a category per category basis. The default settings for each individual category can be changed though. Example: it can be setup so that - by default - all stories posted to the category "article" will have comments enabled but stories submitted to "announcement" not. Different configuration schemes can easily be added later. Requires a SQL update, see 2.00-to-x.xx.sql/database.mysql. - Addition: made submit.php only use categories that users can actually submit new content to.
Diffstat (limited to 'includes')
-rw-r--r--includes/comment.inc5
-rw-r--r--includes/node.inc6
-rw-r--r--includes/structure.inc6
3 files changed, 14 insertions, 3 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index 0d1003530..6d6290f1e 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -145,6 +145,11 @@ function comment_post($pid, $id, $subject, $comment) {
}
}
+function comment_status($index = -1) {
+ $status = array("disabled", "enabled");
+ return $index < 0 ? $status : $status[$index];
+}
+
function comment_score($comment) {
$value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0);
return ((strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00");
diff --git a/includes/node.inc b/includes/node.inc
index 9a8b9f020..733c38da0 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, 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");
+ return db_query("SELECT n.*, l.*, 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 WHERE n.$field = '$value' ORDER BY n.timestamp DESC");
}
}
@@ -39,7 +39,7 @@ function node_get_comments($nid) {
function node_save($node) {
global $user, $status;
- $rows = array(nid, pid, lid, cid, tid, log, type, title, score, votes, author, status, timestamp);
+ $rows = array(nid, pid, lid, cid, tid, log, type, title, score, votes, author, status, comment, timestamp);
if ($node[nid] > 0) {
$n = node_get_object("nid", $node[nid]);
@@ -74,7 +74,7 @@ function node_save($node) {
throttle("post node", variable_get(max_node_rate, 900));
// setup default values:
- $node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, cid => 0, tid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, timestamp => time()), $node);
+ $node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, cid => 0, tid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, comment => 1, timestamp => time()), $node);
// prepare queries:
$f1 = array();
diff --git a/includes/structure.inc b/includes/structure.inc
index 6d6655a3e..94c14ad6d 100644
--- a/includes/structure.inc
+++ b/includes/structure.inc
@@ -47,6 +47,12 @@ function category_expire_threshold($cid) {
return $category->threshold;
}
+// return default comment status of category $cid:
+function category_comment($cid) {
+ $category = category_get_object("cid", $cid);
+ return $category->comment;
+}
+
// return linked string with name of category $cid:
function category_name($cid) {
$category = category_get_object("cid", $cid);