summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-06-02 22:12:35 +0000
committerDries Buytaert <dries@buytaert.net>2001-06-02 22:12:35 +0000
commitb0c349e247b823e74d8c611cdc5d0931317e7757 (patch)
tree1eea57def39cd30e6c65051bdd349224ed3e929d
parent993f4d2eadcd29221bc8e81f3013b92a6e921bdd (diff)
downloadbrdo-b0c349e247b823e74d8c611cdc5d0931317e7757.tar.gz
brdo-b0c349e247b823e74d8c611cdc5d0931317e7757.tar.bz2
- Moved most of the options in structure.module to node.module. The
structure.module either needs work, or replacement by index.module: see "admin > node > node settings". It will do for now and it can always made better when we can think of a better solution; it is the best I could think of. Now what? index.module or structure.module? I'm currently pro index.module. - Drastically simplified "variable.inc". - Removed most dependecies on structure.module from all content related modules. Thus making our modules more modular. ;) - Fixed calculation glitch in queue.module. - Fixed potential function name clash/conflict in rating.module, and simplified some code on my way. - Started removing all global variables $status and $rstatus. Global variables are "yucky" so in near future, we will replace all global $status variables by a call to node_status(). Originally, $status was only introduced as a temporary hack and nothing is as permanent as a temporary hack so I took it out when still possible. - Changed the watchdog messages a bit.
-rw-r--r--account.php12
-rw-r--r--includes/node.inc27
-rw-r--r--includes/variable.inc27
-rw-r--r--index.php2
-rw-r--r--modules/book.module2
-rw-r--r--modules/book/book.module2
-rw-r--r--modules/conf.module2
-rw-r--r--modules/forum.module2
-rw-r--r--modules/forum/forum.module2
-rw-r--r--modules/moderate.module2
-rw-r--r--modules/node.module49
-rw-r--r--modules/node/node.module49
-rw-r--r--modules/page.module2
-rw-r--r--modules/page/page.module2
-rw-r--r--modules/poll.module4
-rw-r--r--modules/poll/poll.module4
-rw-r--r--modules/queue.module14
-rw-r--r--modules/rating.module6
-rw-r--r--modules/story.module2
-rw-r--r--modules/story/story.module2
-rw-r--r--updates/2.00-to-x.xx.sql2
21 files changed, 137 insertions, 79 deletions
diff --git a/account.php b/account.php
index b8f84533e..49f73b864 100644
--- a/account.php
+++ b/account.php
@@ -184,7 +184,7 @@ function account_content_save($edit) {
}
function account_user($uname) {
- global $user, $status, $theme;
+ global $user, $theme;
if ($user->id && $user->userid == $uname) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
@@ -363,9 +363,9 @@ function account_track_comments() {
}
function account_track_nodes() {
- global $status, $theme, $user;
+ global $theme, $user;
- $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25");
+ $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '". node_status("posted") ."' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25");
while ($node = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
@@ -382,13 +382,13 @@ function account_track_nodes() {
}
function account_track_site() {
- global $rstatus, $status, $theme, $user;
+ global $theme, $user;
$period = 259200; // 3 days
$theme->header();
- $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10");
+ $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE n.status = '". node_status("posted") ."' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10");
while ($node = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
@@ -409,7 +409,7 @@ function account_track_site() {
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$output .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Status") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". $rstatus[$node->status] ."</TD></TR>";
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>";
}
$output .= "</TABLE>";
diff --git a/includes/node.inc b/includes/node.inc
index 0be42e890..d1f8021c8 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -21,17 +21,17 @@ function _node_get($conditions) {
}
function node_comment_status($index = -1) {
- $status = array("disabled", "enabled");
+ $status = array("Disabled", "Enabled");
return $index < 0 ? $status : $status[$index];
}
function node_promote_status($index = -1) {
- $status = array("disabled", "enabled");
+ $status = array("Disabled", "Enabled");
return $index < 0 ? $status : $status[$index];
}
function node_submission_status($index = -1) {
- $status = array("auto-post new submissions", "moderate new submissions");
+ $status = array("Auto-post new submissions", "Moderate new submissions");
return $index < 0 ? $status : $status[$index];
}
@@ -88,8 +88,6 @@ function node_save($node, $filter) {
if ($u2 = implode(", ", $u2)) db_query("UPDATE $n->type SET $u2 WHERE nid = '$node[nid]'");
if ($n->pid && ($node[status] == $status[posted])) db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$n->pid'");
- watchdog("special", "node: modified '$n->title'");
-
return $node[nid];
}
else {
@@ -132,7 +130,6 @@ function node_save($node, $filter) {
if (($node[pid]) && ($node[status] == $status[posted])) {
db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'");
}
- watchdog("special", "node: added '$node[title]'");
}
else {
watchdog("warning", "node: added '$node[title]' - failed");
@@ -153,8 +150,9 @@ function node_save($node, $filter) {
}
function node_invoke($node, $name, $arg = 0) {
- if ($node[type]) $function = $node[type] ."_$name";
- if ($node->type) $function = $node->type ."_$name";
+ if (is_array($node)) $function = $node[type] ."_$name";
+ else if (is_object($node)) $function = $node->type ."_$name";
+ else if (is_string($node)) $function = $node ."_$name";
if (function_exists($function)) return ($arg ? $function($node, $arg) : $function($node));
}
@@ -166,9 +164,18 @@ function node_form($node) {
return node_invoke($node, "form");
}
-function node_status($node, $index = -1) {
+function node_status($value) {
$status = array(dumped, expired, queued, posted);
- return $index < 0 ? array_intersect($status, node_invoke($node, "status")) : $status[$index];
+ if (module_exist($value)) {
+ return array_intersect($status, node_invoke($value, "status"));
+ }
+ else if (strlen($value) > 3) {
+ $status = array_flip($status);
+ return $status[$value];
+ }
+ else {
+ return $status[$value];
+ }
}
function node_control($node) {
diff --git a/includes/variable.inc b/includes/variable.inc
index 86f1694b2..402d4457b 100644
--- a/includes/variable.inc
+++ b/includes/variable.inc
@@ -6,34 +6,9 @@ function variable_init($conf = array()) {
return $conf;
}
-function handler_post_threshold($node, $default) {
- $threshold = category_post_threshold($node->cid);
- return $threshold ? $threshold : $default;
-}
-
-function handler_dump_threshold($node, $default) {
- $threshold = category_dump_threshold($node->cid);
- return $threshold ? $threshold : $default;
-}
-
-function handler_expire_threshold($node, $default) {
- $threshold = category_expire_threshold($node->cid);
- return $threshold ? $threshold : $default;
-}
-
function variable_get($name, $default, $object = 0) {
global $conf;
-
- switch ($name) {
- case "post_threshold":
- return handler_post_threshold($object, $default);
- case "dump_threshold":
- return handler_dump_threshold($object, $default);
- case "expire_threshold":
- return handler_expire_threshold($object, $default);
- default:
- return $conf[$name] ? $conf[$name] : $default;
- }
+ return $conf[$name] ? $conf[$name] : $default;
}
function variable_set($name, $value) {
diff --git a/index.php b/index.php
index 82157ce3e..c8ea0b143 100644
--- a/index.php
+++ b/index.php
@@ -13,7 +13,7 @@ if ($topic) {
$t = "AND ($t tid = '". check_input($topic) ."')";
}
-$result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '$status[posted]' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' $c $t ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10)));
+$result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '". node_status("posted") ."' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' $c $t ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10)));
$theme->header();
while ($node = db_fetch_object($result)) {
diff --git a/modules/book.module b/modules/book.module
index 1c877b685..96dfef936 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -153,7 +153,7 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), log, moderate => topic_moderate($edit[tid]), parent, promote => category_promote($edit[cid]), score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access($user)) {
node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight));
diff --git a/modules/book/book.module b/modules/book/book.module
index 1c877b685..96dfef936 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -153,7 +153,7 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), log, moderate => topic_moderate($edit[tid]), parent, promote => category_promote($edit[cid]), score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access($user)) {
node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight));
diff --git a/modules/conf.module b/modules/conf.module
index a1d4eaaa2..665c2879c 100644
--- a/modules/conf.module
+++ b/modules/conf.module
@@ -111,7 +111,7 @@ function conf_view($type) {
function conf_admin() {
global $edit, $op, $type;
- print "<SMALL><A HREF=\"admin.php?mod=conf&type=system\">system settings</A> | <A HREF=\"admin.php?mod=conf&type=module\">module settings</A> | <A HREF=\"admin.php?mod=conf&type=filter\">filters</A> | <A HREF=\"admin.php?mod=conf&op=help\">help</A></SMALL><HR>\n";
+ print "<SMALL><A HREF=\"admin.php?mod=conf&type=system\">system settings</A> | <A HREF=\"admin.php?mod=conf&type=module\">module settings</A> | <A HREF=\"admin.php?mod=conf&type=filter\">content filters</A> | <A HREF=\"admin.php?mod=conf&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "help":
diff --git a/modules/forum.module b/modules/forum.module
index 7556d4315..cf307f441 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -26,7 +26,7 @@ function forum_save($edit) {
global $user, $status;
if (user_access($user)) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
}
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 7556d4315..cf307f441 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -26,7 +26,7 @@ function forum_save($edit) {
global $user, $status;
if (user_access($user)) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
}
}
diff --git a/modules/moderate.module b/modules/moderate.module
index c284df522..ceef124e5 100644
--- a/modules/moderate.module
+++ b/modules/moderate.module
@@ -16,7 +16,7 @@ function moderate_overview($query = array()) {
$r1 = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 30");
while ($node = db_fetch_object($r1)) {
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". category_name($node->cid) ." / ". topic_name($node->tid) ."</TD><TD>". node_status($node, $node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n";
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". category_name($node->cid) ." / ". topic_name($node->tid) ."</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n";
$r2 = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$node->nid' ORDER BY c.timestamp DESC");
while ($comment = db_fetch_object($r2)) {
diff --git a/modules/node.module b/modules/node.module
index 33142a454..e7e983e35 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -48,7 +48,7 @@ function node_overview($query = array()) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>title</TH><TH>category</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($node = db_fetch_object($result)) {
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node, $node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
}
$output .= "</TABLE>\n";
@@ -60,7 +60,7 @@ function node_admin_view($id) {
$form .= form_item("Title", check_output($node->title));
$form .= form_item("Author", format_username($node->userid));
- $form .= form_item("Status", node_status($node, $node->status));
+ $form .= form_item("Status", node_status($node->status));
$form .= form_item("Comment", node_comment_status($node->comment));
$form .= form_item("Promote", node_promote_status($node->promote));
$form .= form_item("Moderate", check_output($node->moderate));
@@ -78,14 +78,14 @@ function node_admin_edit($id) {
$form .= form_item("Title", check_output($node->title));
$form .= form_select("Author", "author", $node->author, array($node->author => $node->userid, $user->id => $user->userid));
- $form .= form_select("Status", "status", $node->status, node_status($node));
+ $form .= form_select("Status", "status", $node->status, node_status($node->type));
$form .= form_select("Comment", "comment", $node->comment, node_comment_status());
$form .= form_select("Promote", "promote", $node->promote, node_promote_status());
$form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("Provide a comma-seperated list of the moderators their usernames."));
$form .= form_select("Date", "timestamp", $node->timestamp, array($node->timestamp => format_date($node->timestamp) ." (original)", time() => format_date(time()) ." (current)"));
$form .= form_hidden("nid", $node->nid);
- $form .= form_submit("View node");
$form .= form_submit("Save node");
+ $form .= form_submit("View node");
return form("admin.php?mod=node&id=$node->nid", $form);
}
@@ -108,10 +108,36 @@ function node_listing($queries) {
return "<OL>$output</OL>\n";
}
+function node_setting() {
+ global $REQUEST_URI;
+
+ $threshold_post = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100);
+ $threshold_dump = array(-1 => -1, -2 => -2, -3 => -3, -4 => -4, -5 => -5, -6 => -6, -7 => -7, -8 => -8, -9 => -9, -10 => -10, -11 => -11, -12 => -12, -13 => -13, -14 => -14, -15 => -15, -20 => -20, -25 => -25, -30 => -30);
+ $threshold_expire = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100);
+
+ foreach (module_list() as $name) {
+ if (module_hook($name, "user")) {
+ $form .= "<H3>Default settings for $name nodes</H3>";
+ $form .= form_select(t("Comment"), $name ."_comment", variable_get($name ."_comment", 0), node_comment_status(), t("By default, allow or dissallow users to post comments in this category."));
+ $form .= form_select(t("Promote"), $name ."_promote", variable_get($name ."_promote", 0), node_promote_status(), t("By default, promote new submissions in this category to the front page."));
+ $form .= form_select(t("Status"), $name ."_status", variable_get($name ."_status", node_status("queued")), node_status($name), t("What to do with new submissions in this category?"));
+ $form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, t("If new submissions are subject to moderation, select a post threshold."));
+ $form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, t("If new submissions are subject to moderation, select a dump threshold."));
+ $form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, t("If new submissions are subject to moderation, select a expiration threshold."));
+ $form .= form_textfield("Moderate", $name ."_moderate", variable_get($name ."_moderate", ""), 35, 255, t("Provide a comma-seperated list of the moderators' usernames."));
+ }
+ }
+
+ $form .= form_submit("Save settings");
+ $form .= form_submit("Reset to defaults");
+
+ return form($REQUEST_URI, $form);
+}
+
function node_admin() {
global $op, $id, $edit, $type;
- print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
+ print "<SMALL><A HREF=\"admin.php?mod=node&op=default\">node settings</A> | <A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
$id = check_input($edit[nid] ? $edit[nid] : $id);
$type = ($type ? $type : 0);
@@ -121,6 +147,9 @@ function node_admin() {
case "edit":
print node_admin_edit($id);
break;
+ case "default":
+ print node_setting();
+ break;
case "Delete node":
print status(node_delete($id));
print node_overview();
@@ -128,8 +157,16 @@ function node_admin() {
case "listing":
print node_listing(node_query());
break;
+ case "Save defaults":
+ print status(conf_save($edit));
+ print node_default();
+ break;
+ case "Reset to defaults":
+ print status(conf_default($edit));
+ print node_default();
+ break;
case "Save node":
- node_save($edit, array(uthor, comment, moderate, promote, status, timestamp));
+ node_save($edit, array(author, comment, moderate, promote, status, timestamp));
print node_admin_view($id);
break;
case "View node":
diff --git a/modules/node/node.module b/modules/node/node.module
index 33142a454..e7e983e35 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -48,7 +48,7 @@ function node_overview($query = array()) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>title</TH><TH>category</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($node = db_fetch_object($result)) {
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node, $node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
}
$output .= "</TABLE>\n";
@@ -60,7 +60,7 @@ function node_admin_view($id) {
$form .= form_item("Title", check_output($node->title));
$form .= form_item("Author", format_username($node->userid));
- $form .= form_item("Status", node_status($node, $node->status));
+ $form .= form_item("Status", node_status($node->status));
$form .= form_item("Comment", node_comment_status($node->comment));
$form .= form_item("Promote", node_promote_status($node->promote));
$form .= form_item("Moderate", check_output($node->moderate));
@@ -78,14 +78,14 @@ function node_admin_edit($id) {
$form .= form_item("Title", check_output($node->title));
$form .= form_select("Author", "author", $node->author, array($node->author => $node->userid, $user->id => $user->userid));
- $form .= form_select("Status", "status", $node->status, node_status($node));
+ $form .= form_select("Status", "status", $node->status, node_status($node->type));
$form .= form_select("Comment", "comment", $node->comment, node_comment_status());
$form .= form_select("Promote", "promote", $node->promote, node_promote_status());
$form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("Provide a comma-seperated list of the moderators their usernames."));
$form .= form_select("Date", "timestamp", $node->timestamp, array($node->timestamp => format_date($node->timestamp) ." (original)", time() => format_date(time()) ." (current)"));
$form .= form_hidden("nid", $node->nid);
- $form .= form_submit("View node");
$form .= form_submit("Save node");
+ $form .= form_submit("View node");
return form("admin.php?mod=node&id=$node->nid", $form);
}
@@ -108,10 +108,36 @@ function node_listing($queries) {
return "<OL>$output</OL>\n";
}
+function node_setting() {
+ global $REQUEST_URI;
+
+ $threshold_post = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100);
+ $threshold_dump = array(-1 => -1, -2 => -2, -3 => -3, -4 => -4, -5 => -5, -6 => -6, -7 => -7, -8 => -8, -9 => -9, -10 => -10, -11 => -11, -12 => -12, -13 => -13, -14 => -14, -15 => -15, -20 => -20, -25 => -25, -30 => -30);
+ $threshold_expire = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100);
+
+ foreach (module_list() as $name) {
+ if (module_hook($name, "user")) {
+ $form .= "<H3>Default settings for $name nodes</H3>";
+ $form .= form_select(t("Comment"), $name ."_comment", variable_get($name ."_comment", 0), node_comment_status(), t("By default, allow or dissallow users to post comments in this category."));
+ $form .= form_select(t("Promote"), $name ."_promote", variable_get($name ."_promote", 0), node_promote_status(), t("By default, promote new submissions in this category to the front page."));
+ $form .= form_select(t("Status"), $name ."_status", variable_get($name ."_status", node_status("queued")), node_status($name), t("What to do with new submissions in this category?"));
+ $form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, t("If new submissions are subject to moderation, select a post threshold."));
+ $form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, t("If new submissions are subject to moderation, select a dump threshold."));
+ $form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, t("If new submissions are subject to moderation, select a expiration threshold."));
+ $form .= form_textfield("Moderate", $name ."_moderate", variable_get($name ."_moderate", ""), 35, 255, t("Provide a comma-seperated list of the moderators' usernames."));
+ }
+ }
+
+ $form .= form_submit("Save settings");
+ $form .= form_submit("Reset to defaults");
+
+ return form($REQUEST_URI, $form);
+}
+
function node_admin() {
global $op, $id, $edit, $type;
- print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
+ print "<SMALL><A HREF=\"admin.php?mod=node&op=default\">node settings</A> | <A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
$id = check_input($edit[nid] ? $edit[nid] : $id);
$type = ($type ? $type : 0);
@@ -121,6 +147,9 @@ function node_admin() {
case "edit":
print node_admin_edit($id);
break;
+ case "default":
+ print node_setting();
+ break;
case "Delete node":
print status(node_delete($id));
print node_overview();
@@ -128,8 +157,16 @@ function node_admin() {
case "listing":
print node_listing(node_query());
break;
+ case "Save defaults":
+ print status(conf_save($edit));
+ print node_default();
+ break;
+ case "Reset to defaults":
+ print status(conf_default($edit));
+ print node_default();
+ break;
case "Save node":
- node_save($edit, array(uthor, comment, moderate, promote, status, timestamp));
+ node_save($edit, array(author, comment, moderate, promote, status, timestamp));
print node_admin_view($id);
break;
case "View node":
diff --git a/modules/page.module b/modules/page.module
index 91ef7b8fc..9af1b2c9c 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -40,7 +40,7 @@ function page_save($edit) {
global $status, $user;
if (user_access($user)) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), format, moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "page", votes => 0));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "page", votes => 0));
}
}
diff --git a/modules/page/page.module b/modules/page/page.module
index 91ef7b8fc..9af1b2c9c 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -40,7 +40,7 @@ function page_save($edit) {
global $status, $user;
if (user_access($user)) {
- node_save($edit, array(author => $user->id, body, cid, comment => category_comment($edit[cid]), format, moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "page", votes => 0));
+ node_save($edit, array(author => $user->id, body, cid, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "page", votes => 0));
}
}
diff --git a/modules/poll.module b/modules/poll.module
index 5ed349a8a..0ae5c7ff0 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -142,7 +142,7 @@ function poll_view($node, $main = 0, $block = 0) {
if ($block) {
$output .= "</td></tr></table><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div>";
} else {
- $output .= "</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align=\"center\"><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div></td></tr></table>";
+ $output .= "</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align=\"center\"><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div></td></tr></table>";
}
$output = form($REQUEST_URI, $output);
}
@@ -215,7 +215,7 @@ function poll_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), runtime, score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => ""));
+ $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => ""));
}
else if (user_access($user)) {
$nid = node_save($edit, array(active, cid, tid, runtime, title, type => "poll"));
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 5ed349a8a..0ae5c7ff0 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -142,7 +142,7 @@ function poll_view($node, $main = 0, $block = 0) {
if ($block) {
$output .= "</td></tr></table><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div>";
} else {
- $output .= "</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align=\"center\"><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div></td></tr></table>";
+ $output .= "</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align=\"center\"><br><div align=\"center\">" . form_submit("Vote") . "<br>" . $footer . "</div></td></tr></table>";
}
$output = form($REQUEST_URI, $output);
}
@@ -215,7 +215,7 @@ function poll_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), runtime, score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => ""));
+ $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => ""));
}
else if (user_access($user)) {
$nid = node_save($edit, array(active, cid, tid, runtime, title, type => "poll"));
diff --git a/modules/queue.module b/modules/queue.module
index d427ff95c..05f43b739 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -36,17 +36,19 @@ function queue_vote($id, $vote) {
// Update submission's score- and votes-field:
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->userid, $vote) ."' WHERE nid = $id");
- if (variable_get("post_threshold", 4, $node) < $node->score + $vote) {
+ $node = node_get_object(array(nid => $id, type => $node->type));
+
+ if (variable_get($node->type ."_post", 4) <= $node->score) {
node_save(array(nid => $id, status => $status[posted]), array(status));
- watchdog("message", "node: posted '$node->title' - moderation");
+ watchdog("special", "node: posted '$node->title' - moderation");
}
- else if (variable_get("dump_threshold", -2, $node) > $node->score + $vote) {
+ else if (variable_get($node->type ."_dump", -2) >= $node->score) {
node_save(array(nid => $id, status => $status[dumped]), array(status));
- watchdog("message", "node: dumped '$node->title' - moderation");
+ watchdog("special", "node: dumped '$node->title' - moderation");
}
- else if (variable_get("expire_threshold", 8, $node) < $node->votes + $vote) {
+ else if (variable_get($node->type ."_expire", 8) <= $node->votes) {
node_save(array(nid => $id, status => $status[expired]), array(status));
- watchdog("message", "node: expired '$node->title' - moderation");
+ watchdog("special", "node: expired '$node->title' - moderation");
}
}
}
diff --git a/modules/rating.module b/modules/rating.module
index 9f80d9c7a..e4abb066d 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -6,7 +6,7 @@ function rating_conf_options() {
$weight = array(t("Disabled"), 1, 2, 3, 4, 5, 6, 7, 9, 10);
foreach (module_list() as $name) {
- if (module_hook($name, "status")) {
+ if (module_hook($name, "user")) {
$output .= form_select(t("Weight of a $name"), "rating_weight_$name", variable_get("rating_weight_$name", 0), $weight, t("The weight of a $name."));
}
}
@@ -19,7 +19,7 @@ function rating_cron() {
$r1 = db_query("SELECT id FROM users ORDER BY rating DESC");
while ($account = db_fetch_object($r1)) {
- db_query("UPDATE users SET rating = '". rating_user($account->id) ."' WHERE id = '$account->id'");
+ db_query("UPDATE users SET rating = '". rating_gravity($account->id) ."' WHERE id = '$account->id'");
$rating[$account->id] = ++$i;
}
@@ -38,7 +38,7 @@ function rating_help() {
<?
}
-function rating_user($id) {
+function rating_gravity($id) {
global $status;
$period = 5184000; // maximum 60 days
diff --git a/modules/story.module b/modules/story.module
index 939edd94d..e6f48b5d3 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -72,7 +72,7 @@ function story_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- node_save($edit, array(abstract, author => $user->id, body, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "story", votes => 0));
+ node_save($edit, array(abstract, author => $user->id, body, cid, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), tid, timestamp => time(), title, type => "story", votes => 0));
}
else if (user_access($user)) {
node_save($edit, array(abstract, body, cid, tid, title, type => "story"));
diff --git a/modules/story/story.module b/modules/story/story.module
index 939edd94d..e6f48b5d3 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -72,7 +72,7 @@ function story_save($edit) {
global $status, $user;
if (!$edit[nid]) {
- node_save($edit, array(abstract, author => $user->id, body, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "story", votes => 0));
+ node_save($edit, array(abstract, author => $user->id, body, cid, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), tid, timestamp => time(), title, type => "story", votes => 0));
}
else if (user_access($user)) {
node_save($edit, array(abstract, body, cid, tid, title, type => "story"));
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index cc7f83f7c..4879a6780 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -189,7 +189,7 @@ CREATE TABLE item (
PRIMARY KEY (iid)
);
-# 31/05/01
+# 31/05/01
CREATE TABLE poll (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,