From c4d228a4b5d6f09da068b668ce8c4d3186e261e0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 25 Nov 2001 15:30:03 +0000 Subject: - rating module: + fixed the gravity math: it was broken due to the node system updates + XHMTL-ified the emited HTML code --- modules/rating.module | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/rating.module b/modules/rating.module index e2b577247..32cc81003 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -27,8 +27,8 @@ function rating_conf_options() { } function rating_cron() { - if (time() - variable_get("rating_cron_last", 0) > variable_get("rating_cron_time", time())) { - variable_set("rating_cron_last", time()); +// if (time() - variable_get("rating_cron_last", 0) > variable_get("rating_cron_time", time())) { +// variable_set("rating_cron_last", time()); $r1 = db_query("SELECT uid FROM users ORDER BY rating DESC"); while ($account = db_fetch_object($r1)) { @@ -42,52 +42,43 @@ function rating_cron() { while ($account = db_fetch_object($r2)) { db_query("INSERT INTO rating (uid, new, old) VALUES ('$account->uid', '". ++$j ."', '". $rating[$account->uid] ."')"); } - } +// } } function rating_help() { ?> -

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

+

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

type", 0); - } + $gravity = 0; - $r2 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND status = 0"); + $r1 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND moderate = 0 AND promote = 1 AND status = 1 LIMIT $number"); while ($node = db_fetch_object($r1)) { - $bonus -= variable_get("rating_weight_$node->type", 0); + $gravity += 1; } -/* - $r3 = db_query("SELECT score, votes FROM comments WHERE uid = '$uid' AND votes > 0 AND (". time() ." - created < $period) ORDER BY created LIMIT $number"); - while ($comment = db_fetch_object($r3)) { - $weight++; - $score += $weight * $comment->score; - $votes += $weight * $comment->votes; + $r2 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND status = 0 LIMIT $number"); + while ($node = db_fetch_object($r1)) { + $gravity -= 1; } - $bonus += $weight / 5; -*/ - - return ($votes ? ($score + $weight) / $votes + $bonus : $bonus); + return $gravity; } function rating_list($limit) { $result = db_query("SELECT u.rating, u.name, u.uid, r.* FROM users u LEFT JOIN rating r ON u.uid = r.uid ORDER BY u.rating DESC LIMIT $limit"); - $output .= "\n"; + $output .= "
\n"; while ($account = db_fetch_object($result)) { $ranking = $account->old - $account->new; - $output .= ""; + $output .= ""; } - $output .= "
". ++$i .".". format_name($account) ."". check_output($account->rating) ."(". ($ranking < 0 ? "" : "+") ."$ranking)
". ++$i .".". format_name($account) ."". check_output($account->rating) ."(". ($ranking < 0 ? "" : "+") ."$ranking)
\n"; + $output .= "\n"; return $output; } @@ -107,9 +98,9 @@ function rating_page() { } function rating_block() { - $block[0][subject] = "Top 10:
users"; - $block[0][content] = rating_list(10); - $block[0][info] = "Top 10: users"; + $block[0]["subject"] = "Top 10:
users"; + $block[0]["content"] = rating_list(10); + $block[0]["info"] = "Top 10: users"; return $block; } -- cgit v1.2.3