From 048664f2786fce9bd049f39eea39a2a7fe2868f0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 5 Apr 2001 20:33:36 +0000 Subject: - a bunch of various updates --- modules/book.module | 14 +++++++++++++- modules/book/book.module | 14 +++++++++++++- modules/moderation.module | 19 +++++++++++++------ modules/rating.module | 13 ++----------- modules/story.module | 14 +++++++++++++- modules/story/story.module | 14 +++++++++++++- modules/watchdog.module | 25 ++++++++++++++++++++++--- modules/watchdog/watchdog.module | 25 ++++++++++++++++++++++--- 8 files changed, 111 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 62662ee8f..4a8603ad8 100644 --- a/modules/book.module +++ b/modules/book.module @@ -17,6 +17,18 @@ class Book { } } +function book_post_threshold($node, $default) { + return $default; +} + +function book_dump_threshold($node, $default) { + return $default; +} + +function book_timout_threshold($node, $default) { + return $default; +} + function book_location($node, $nodes = array()) { $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'")); if ($parent->title) { @@ -216,7 +228,7 @@ function book_update($id) { return t("You can only update accepted pages: pages that are still queued or already expired can not be updated."); } else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) { - return t("There is already an update for this node queued: we can only process one update at the time."); + return t("There is already an update for this node in the queue: we can only process one update at once."); } else { return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent)); diff --git a/modules/book/book.module b/modules/book/book.module index 62662ee8f..4a8603ad8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -17,6 +17,18 @@ class Book { } } +function book_post_threshold($node, $default) { + return $default; +} + +function book_dump_threshold($node, $default) { + return $default; +} + +function book_timout_threshold($node, $default) { + return $default; +} + function book_location($node, $nodes = array()) { $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'")); if ($parent->title) { @@ -216,7 +228,7 @@ function book_update($id) { return t("You can only update accepted pages: pages that are still queued or already expired can not be updated."); } else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) { - return t("There is already an update for this node queued: we can only process one update at the time."); + return t("There is already an update for this node in the queue: we can only process one update at once."); } else { return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent)); diff --git a/modules/moderation.module b/modules/moderation.module index b322f2ed4..9f7a7049f 100644 --- a/modules/moderation.module +++ b/modules/moderation.module @@ -1,11 +1,18 @@ "+ 0", + "post it (+1)" => "+ 1", + "dump it (-1)" => "- 1"); + $module = array("menu" => "moderation_menu", "page" => "moderation_page"); -include_once "includes/common.inc"; -include_once "includes/node.inc"; - function moderation_menu() { return array("". t("moderation queue") ." (". moderation_count() .")"); } @@ -32,15 +39,15 @@ function moderation_vote($id, $vote) { $user = user_set($user, "history", "n$id", $vote); if ($node = node_get_object(nid, $id)) { - if (node_post_threshold($node) <= $node->score) { + if (variable_get("post_threshold", 4, $node) <= $node->score) { node_save(array(nid => $id, status => $status[posted])); watchdog("message", "node: posted '$node->title' - moderation"); } - else if (node_dump_threshold($node) >= $node->score) { + else if (variable_get("dump_threshold", -2, $node) >= $node->score) { node_save(array(nid => $id, status => $status[dumped])); watchdog("message", "node: dumped '$node->title' - moderation"); } - else if (node_timout_threshold($node) <= $node->votes) { + else if (variable_get("timout_threshold", 8, $node) <= $node->votes) { node_save(array(nid => $id, status => $status[expired])); watchdog("message", "node: expired '$node->title' - moderation"); } diff --git a/modules/rating.module b/modules/rating.module index a78df4ce3..0330422f4 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -15,17 +15,8 @@ function rating_cron() { function rating_help() { ?> -

User rating

-

The rating cron will periodically calculate an overall rating of each user's contributed value that is a time-weighted average of his or her comments ratings with an additional bonus for the nodes he or she contributed. The system can be best compared with SlashCode's karma and is - in fact - even more similar to Scoop's mojo implementation.

-

I won't elaborate on all the funny math involved and it suffices to say that the actual weighting is done in such a way:

-
    -
  1. that comments with a lot of votes count more then comments with only one or two votes.
  2. -
  3. that newer comments count for more then older comments.
  4. -
-

The idea of (1) is that it favors comments that more people voted on, and thus whose rating is more likely to be accurate or justified.

-

The latter (2) makes the user rating that comes out of the calulations temporary, based on users' most recent activity and responsive to their current state. This is accomplished by taking each user's last 30 comments, or however many he or she posted in the last 60 days - whatever comes first.

-

Additionally, users that posted one or more succesful nodes in the last 60 days gain extra bonus points which will boost up their overall rating.

- The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.

+ header(); - comment_preview(check_input($pid), check_input($id), ($subject ? check_output($subject) : ""), ($comment ? check_output($comment) : "")); + comment_preview(check_input($pid), check_input($id), $subject, $comment); $theme->footer(); break; case t("Post comment"): diff --git a/modules/story/story.module b/modules/story/story.module index fbe8a12f4..d83557456 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -19,6 +19,18 @@ class Story { } } +function story_post_threshold($node, $default) { + return $default; +} + +function story_dump_threshold($node, $default) { + return $default; +} + +function story_timout_threshold($node, $default) { + return $default; +} + function story_find($keys) { global $status, $user; $find = array(); @@ -44,7 +56,7 @@ function story_view($node, $page = 1) { switch($op) { case t("Preview comment"): $theme->header(); - comment_preview(check_input($pid), check_input($id), ($subject ? check_output($subject) : ""), ($comment ? check_output($comment) : "")); + comment_preview(check_input($pid), check_input($id), $subject, $comment); $theme->footer(); break; case t("Post comment"): diff --git a/modules/watchdog.module b/modules/watchdog.module index 0252d5105..c912ee85b 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -2,6 +2,7 @@ $module = array("help" => "watchdog_help", "cron" => "watchdog_cron", + "conf" => "watchdog_conf", "admin" => "watchdog_admin"); function watchdog_help() { @@ -15,7 +16,7 @@ function watchdog_cron() { watchdog_clean(); } -function watchdog_display($order = "date") { +function watchdog_overview($order = "date") { $colors = array("#D8BFD8", "#6495ED", "#6A5ADF", "#FFFFFF", "#FFA500", "#FF3C3C"); $fields = array("date" => "id DESC", "username" => "user", "location" => "location", "message" => "message DESC", "level" => "level DESC"); @@ -68,6 +69,24 @@ function watchdog_view($id) { } } +function watchdog_conf() { + global $conf; + + $rate = array(1 => "maximum 1 every second", 5 => "maximum 1 every 5 seconds", 15 => "maximum 1 every 15 seconds", 30 => "maximum 1 every 30 seconds", 60 => "maximum 1 every minute", 300 => "maximum 1 every 5 minutes", 900 => "maximum 1 every 15 minutes", 1800 => "maximum 1 every 30 minutes", 3600 => "maximum 1 every hour", 21600 => "maximum 1 every 6 hour", 43200 => "maximum 1 every 12 hour"); + + $output .= "Maximum node rate:
\n"; + foreach ($rate as $key=>$value) $options1 .= " \n"; + $output .= "
\n"; + $output .= "The maximum submission rate for nodes. Its purpose is to stop denial of service attacks.

\n"; + + $output .= "Maximum comment rate:
\n"; + foreach ($rate as $key=>$value) $options2 .= " \n"; + $output .= "$options1
\n"; + $output .= "The maximum submission rate for nodes. Its purpose is to stop denial of service attacks.

\n"; + + $output .= "Maximum comment rate:
\n"; + foreach ($rate as $key=>$value) $options2 .= " \n"; + $output .= "