diff options
-rw-r--r-- | includes/user.inc | 28 | ||||
-rw-r--r-- | modules/headline.module | 2 | ||||
-rw-r--r-- | modules/queue.module | 2 | ||||
-rw-r--r-- | modules/rating.module | 39 | ||||
-rw-r--r-- | modules/watchdog.module | 2 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 2 |
6 files changed, 41 insertions, 34 deletions
diff --git a/includes/user.inc b/includes/user.inc index 307a3f33c..0b99a6af5 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -63,32 +63,4 @@ function user_ban($mask, $type) { return db_fetch_object($result); } -function user_gravity($id) { - global $status; - - $period = 5184000; // maximum 60 days - $number = 30; // maximum 30 comments - - $r1 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'"); - if ($story = db_fetch_object($r1)) { - $bonus += $story->number; - } - - $r2 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'"); - if ($story = db_fetch_object($r2)) { - $bonus -= $story->number; - } - - $r3 = db_query("SELECT score, votes FROM comments WHERE author = '$id' AND votes > 0 AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number"); - while ($comment = db_fetch_object($r3)) { - $weight++; - $score += $weight * $comment->score; - $votes += $weight * $comment->votes; - } - - $bonus += $weight / 5; - - return ($votes ? ($score + $weight) / $votes + $bonus : $bonus); -} - ?>
\ No newline at end of file diff --git a/modules/headline.module b/modules/headline.module index 5c87ba286..7d30bae50 100644 --- a/modules/headline.module +++ b/modules/headline.module @@ -12,7 +12,7 @@ function headline_help() { } function headline_conf_options() { - $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 1000000000 => t("never")); + $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 1000000000 => t("Never")); $output .= form_select(t("Update interval"), "headline_cron_time" , variable_get("headline_cron_time", 86400), $period, t("The update interval indicating how often you want to update your headline channels. Requires crontab.")); return $output; } diff --git a/modules/queue.module b/modules/queue.module index 6beda85ab..137335854 100644 --- a/modules/queue.module +++ b/modules/queue.module @@ -1,7 +1,7 @@ <?php 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")); + $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 moderation queue. Older entries will be automatically discarded. Requires crontab.")); return $output; } diff --git a/modules/rating.module b/modules/rating.module index cc3a038b7..9f80d9c7a 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -1,8 +1,15 @@ <?php function rating_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), 1000000000 => t("never")); + $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), 1000000000 => t("Never")); $output .= form_select(t("Update interval"), "rating_cron_time" , variable_get("rating_cron_time", 86400), $period, t("The update interval for the user ratings. Requires crontab.")); + + $weight = array(t("Disabled"), 1, 2, 3, 4, 5, 6, 7, 9, 10); + foreach (module_list() as $name) { + if (module_hook($name, "status")) { + $output .= form_select(t("Weight of a $name"), "rating_weight_$name", variable_get("rating_weight_$name", 0), $weight, t("The weight of a $name.")); + } + } return $output; } @@ -12,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 = '". user_gravity($account->id) ."' WHERE id = '$account->id'"); + db_query("UPDATE users SET rating = '". rating_user($account->id) ."' WHERE id = '$account->id'"); $rating[$account->id] = ++$i; } @@ -31,6 +38,34 @@ function rating_help() { <? } +function rating_user($id) { + global $status; + + $period = 5184000; // maximum 60 days + $number = 30; // maximum 30 comments + + $r1 = db_query("SELECT nid, type FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'"); + while ($node = db_fetch_object($r1)) { + $bonus += variable_get("rating_weight_$node->type", 0); + } + + $r2 = db_query("SELECT nid, type FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'"); + while ($node = db_fetch_object($r1)) { + $bonus -= variable_get("rating_weight_$node->type", 0); + } + + $r3 = db_query("SELECT score, votes FROM comments WHERE author = '$id' AND votes > 0 AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number"); + while ($comment = db_fetch_object($r3)) { + $weight++; + $score += $weight * $comment->score; + $votes += $weight * $comment->votes; + } + + $bonus += $weight / 5; + + return ($votes ? ($score + $weight) / $votes + $bonus : $bonus); +} + function rating_list($limit) { $result = db_query("SELECT u.userid, u.rating, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit"); diff --git a/modules/watchdog.module b/modules/watchdog.module index fd7c4e9e8..9cf2ec908 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -8,7 +8,7 @@ function watchdog_help() { } function watchdog_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")); + $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"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); return $output; } diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index fd7c4e9e8..9cf2ec908 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -8,7 +8,7 @@ function watchdog_help() { } function watchdog_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")); + $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"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); return $output; } |