Commit ebb14ab9 authored by Dries's avatar Dries

- A couple of new node updates
parent 84cdc3c6
......@@ -39,6 +39,26 @@ function blog_access($op, $node) {
}
function blog_save($op, $node) {
if ($op == "approve") {
return array("promote" => 1);
}
if ($op == "create") {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "decline") {
return array("promote" => 0);
}
if ($op == "update") {
return array("promote");
}
}
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog or diary. It provides easy-to-write and easy-to-read online diaries or journals that can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
......@@ -224,16 +244,6 @@ function blog_form($node, $help, $error) {
return $output;
}
function blog_save($node) {
if ($node->nid) {
return array();
}
else {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
}
function blog_page() {
global $theme, $id, $op, $date;
......
......@@ -39,6 +39,26 @@ function blog_access($op, $node) {
}
function blog_save($op, $node) {
if ($op == "approve") {
return array("promote" => 1);
}
if ($op == "create") {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "decline") {
return array("promote" => 0);
}
if ($op == "update") {
return array("promote");
}
}
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog or diary. It provides easy-to-write and easy-to-read online diaries or journals that can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
......@@ -224,16 +244,6 @@ function blog_form($node, $help, $error) {
return $output;
}
function blog_save($node) {
if ($node->nid) {
return array();
}
else {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
}
function blog_page() {
global $theme, $id, $op, $date;
......
......@@ -41,6 +41,42 @@ function book_access($op, $node) {
}
}
function book_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("moderate" => 1, "parent", "promote" => 0, "status" => 1, "weight");
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
if (user_access("administer nodes")) {
/*
** If a node administrator updates a book page, we don't create a
** new revision unless we are explicitly instructed to.
*/
return array("parent", "weight");
}
else {
/*
** 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.
*/
return array("created" => time(), "moderate" => 1, "parent", "promote" => 0, "score" => 0, "status" => 1, "users" => "", "revisions", "votes" => 0, "weight");
}
}
}
function book_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
......@@ -66,30 +102,6 @@ function book_delete($node) {
db_query("DELETE FROM book WHERE nid = '$node->nid'");
}
function book_save($node) {
if ($node->nid) {
if (user_access("administer nodes")) {
/*
** If a node administrator updates a book page, we don't create a
** new revision unless we are explicitly instructed to.
*/
return array("parent", "weight");
}
else {
/*
** 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.
*/
return array("created" => time(), "moderate" => 1, "parent", "promote" => 0, "score" => 0, "status" => 1, "users" => "", "revisions", "votes" => 0, "weight");
}
}
else {
return array("moderate" => 1, "parent", "promote" => 0, "status" => 1, "weight");
}
}
function book_form($node, $help, $error) {
global $user;
......
......@@ -41,6 +41,42 @@ function book_access($op, $node) {
}
}
function book_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("moderate" => 1, "parent", "promote" => 0, "status" => 1, "weight");
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
if (user_access("administer nodes")) {
/*
** If a node administrator updates a book page, we don't create a
** new revision unless we are explicitly instructed to.
*/
return array("parent", "weight");
}
else {
/*
** 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.
*/
return array("created" => time(), "moderate" => 1, "parent", "promote" => 0, "score" => 0, "status" => 1, "users" => "", "revisions", "votes" => 0, "weight");
}
}
}
function book_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
......@@ -66,30 +102,6 @@ function book_delete($node) {
db_query("DELETE FROM book WHERE nid = '$node->nid'");
}
function book_save($node) {
if ($node->nid) {
if (user_access("administer nodes")) {
/*
** If a node administrator updates a book page, we don't create a
** new revision unless we are explicitly instructed to.
*/
return array("parent", "weight");
}
else {
/*
** 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.
*/
return array("created" => time(), "moderate" => 1, "parent", "promote" => 0, "score" => 0, "status" => 1, "users" => "", "revisions", "votes" => 0, "weight");
}
}
else {
return array("moderate" => 1, "parent", "promote" => 0, "status" => 1, "weight");
}
}
function book_form($node, $help, $error) {
global $user;
......
......@@ -14,6 +14,24 @@ function forum_access($op, $node) {
}
}
function forum_save() {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "update") {
return array();
}
if ($op == "update") {
return array("status" => 0);
}
}
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
......@@ -34,14 +52,6 @@ function forum_form($node, $help, $error) {
return $output;
}
function forum_save() {
if ($node->nid) {
return array();
}
else {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
}
function forum_num_comments($nid) {
$value = db_fetch_object(db_query("SELECT COUNT(cid) AS count FROM comments WHERE lid = '$nid'"));
......
......@@ -14,6 +14,24 @@ function forum_access($op, $node) {
}
}
function forum_save() {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "update") {
return array();
}
if ($op == "update") {
return array("status" => 0);
}
}
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
......@@ -34,14 +52,6 @@ function forum_form($node, $help, $error) {
return $output;
}
function forum_save() {
if ($node->nid) {
return array();
}
else {
return array("promote" => 0, "moderate" => 0, "status" => 1);
}
}
function forum_num_comments($nid) {
$value = db_fetch_object(db_query("SELECT COUNT(cid) AS count FROM comments WHERE lid = '$nid'"));
......
......@@ -723,7 +723,7 @@ function node_submit($node) {
$fields = array("nid", "uid" => $user->uid, "body", "teaser", "title", "type" => $node->type);
}
node_save($node, array_merge($fields, module_invoke($node->type, "save", $node)));
node_save($node, array_merge($fields, module_invoke($node->type, "save", "update", $node)));
watchdog("special", "node: updated '$node->title'");
$output = t("The node has been updated.");
......@@ -755,7 +755,7 @@ function node_submit($node) {
$fields = array("uid" => $user->uid, "body", "comment" => 1, "teaser", "title", "type" => $node->type);
}
node_save($node, array_merge($fields, module_invoke($node->type, "save", $node)));
node_save($node, array_merge($fields, module_invoke($node->type, "save", "create", $node)));
watchdog("special", "node: added '$node->title'");
$output = t("Thanks for your submission.");
......
......@@ -723,7 +723,7 @@ function node_submit($node) {
$fields = array("nid", "uid" => $user->uid, "body", "teaser", "title", "type" => $node->type);
}
node_save($node, array_merge($fields, module_invoke($node->type, "save", $node)));
node_save($node, array_merge($fields, module_invoke($node->type, "save", "update", $node)));
watchdog("special", "node: updated '$node->title'");
$output = t("The node has been updated.");
......@@ -755,7 +755,7 @@ function node_submit($node) {
$fields = array("uid" => $user->uid, "body", "comment" => 1, "teaser", "title", "type" => $node->type);
}
node_save($node, array_merge($fields, module_invoke($node->type, "save", $node)));
node_save($node, array_merge($fields, module_invoke($node->type, "save", "create", $node)));
watchdog("special", "node: added '$node->title'");
$output = t("Thanks for your submission.");
......
......@@ -16,6 +16,24 @@ function page_access($op, $node) {
}
}
function page_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
return array("format", "link");
}
}
function page_insert($node) {
db_query("INSERT INTO page (nid, format, link) VALUES ('$node->nid', '$node->format', '$node->link')");
}
......@@ -73,15 +91,4 @@ function page_form($node, $help, $error) {
return $output;
}
function page_save() {
if ($node->nid) {
return array("format", "link");
}
else {
return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1);
}
}
?>
\ No newline at end of file
......@@ -16,6 +16,24 @@ function page_access($op, $node) {
}
}
function page_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
return array("format", "link");
}
}
function page_insert($node) {
db_query("INSERT INTO page (nid, format, link) VALUES ('$node->nid', '$node->format', '$node->link')");
}
......@@ -73,15 +91,4 @@ function page_form($node, $help, $error) {
return $output;
}
function page_save() {
if ($node->nid) {
return array("format", "link");
}
else {
return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1);
}
}
?>
\ No newline at end of file
......@@ -2,8 +2,15 @@
// $Id$
function queue_conf_options() {
$period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never"));
$output .= form_select(t("Discard entries older than"), "queue_clear", variable_get("queue_clear", 604800), $period, t("The time nodes should be kept in the submission queue. Older entries will be automatically discarded. Requires crontab."));
$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);
$output .= form_select(t("Post threshold"), "queue_threshold_post", variable_get("queue_threshold_post", 4), $threshold_post, t("If new submissions are subject to moderation, select a post threshold."));
$output .= form_select(t("Dump threshold"), "queue_threshold_dump", variable_get("queue_threshold_dump", -2), $threshold_dump, t("If new submissions are subject to moderation, select a dump threshold."));
$output .= form_select(t("Expiration threshold"),"queue_threshold_expire", variable_get("queue_threshold_expire", 8), $threshold_expire, t("If new submissions are subject to moderation, select an expiration threshold."));
return $output;
}
......@@ -13,16 +20,12 @@ function queue_perm() {
function queue_link($type) {
if ($type == "menu" && user_access("access submission queue")) {
$links[] = "<a href=\"module.php?mod=queue\">". t("submission queue") ."</a> (<FONT COLOR=\"red\">". queue_count() ."</FONT>)";
$links[] = "<a href=\"module.php?mod=queue\">". t("submission queue") ."</a> (<font color=\"red\">". queue_count() ."</font>)";
}
return $links ? $links : array();
}
function queue_cron() {
db_query("UPDATE node SET status = 0 WHERE moderate = 1 AND ". time() ." - timestamp > ". variable_get("queue_clear", 604800));
}
function queue_count() {
$result = db_query("SELECT COUNT(nid) FROM node WHERE moderate = 1");
return ($result) ? db_result($result, 0) : 0;
......@@ -39,32 +42,32 @@ function queue_vote($node, $vote) {
if (!field_get($node->users, $user->uid)) {
// Update submission's score- and votes-field:
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = $node->nid");
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = '$node->nid'");
// Reload the updated node from the database:
$node = node_load(array("nid" => $node->nid));
if (variable_get($node->type ."_post", 3) <= $node->score) {
node_save($node, array("nid", "status" => 1, "moderate" => 0));
if (variable_get("queue_threshold_post", 3) <= $node->score) {
node_save($node, array_merge(array("nid", "moderate" => 0), module_invoke($node->type, "save", "approve", $node)));
watchdog("special", "moderation: posted '$node->title'");
}
else if (variable_get($node->type ."_dump", -2) >= $node->score) {
else if (variable_get("queue_threshold_dump", -2) >= $node->score) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog("special", "moderation: dumped '$node->title' (rollback)");
}
else {
node_save($node, array("nid", "status" => 0, "moderate" => 0));
node_save($node, array_merge(array("nid", "moderate" => 0), module_invoke($node->type, "save", "decline", $node)));
watchdog("special", "moderation: dumped '$node->title'");
}
}
else if (variable_get($node->type ."_expire", 6) <= $node->votes) {
else if (variable_get("queue_threshold_expire", 6) <= $node->votes) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog("special", "moderation: expired '$node->title' (rollback)");
}
else {
node_save($node, array("nid", "status" => 0, "moderate" => 0));
node_save($node, array_merge(array("nid", "moderate" => 0), module_invoke($node->type, "save", "decline", $node)));
watchdog("special", "moderation: expired '$node->title'");
}
}
......@@ -119,7 +122,7 @@ function queue_view($nid) {
queue_vote($node, $edit["vote"]);
$output = t("Thanks for your vote.");
$output = t("Your vote has been recorded.");
}
else {
/*
......
......@@ -25,6 +25,26 @@ function story_access($op, $node) {
}
}
function story_save($op, $node) {
if ($op == "approve") {
return array("status" => 1, "promote" => 1);
}
if ($op == "create") {
return array("moderate" => 1);
}
if ($op == "decline") {
return array("status" => 0, "promote" => 0);
}
if ($op == "update") {
return array("status");
}
}
function story_help() {
?>
// TODO: update documentation, outdated
......@@ -63,13 +83,5 @@ function story_form($node, $help, $error) {
return $output;
}
function story_save($node) {
if ($node->nid) {
return array();
}
else {
return array("promote" => 1, "moderate" => 1);
}
}
?>
......@@ -25,6 +25,26 @@ function story_access($op, $node) {
}
}
function story_save($op, $node) {
if ($op == "approve") {
return array("status" => 1, "promote" => 1);
}
if ($op == "create") {
return array("moderate" => 1);
}
if ($op == "decline") {
return array("status" => 0, "promote" => 0);
}
if ($op == "update") {
return array("status");
}
}
function story_help() {
?>
// TODO: update documentation, outdated
......@@ -63,13 +83,5 @@ function story_form($node, $help, $error) {
return $output;
}
function story_save($node) {
if ($node->nid) {
return array();
}
else {
return array("promote" => 1, "moderate" => 1);
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment