summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-11-25 15:30:03 +0000
committerDries Buytaert <dries@buytaert.net>2001-11-25 15:30:03 +0000
commitc4d228a4b5d6f09da068b668ce8c4d3186e261e0 (patch)
tree656c092149132fe86802f442fdfa127f36d205a5
parent8fa7c24d45fa80749503131ceba0ddcb74384f09 (diff)
downloadbrdo-c4d228a4b5d6f09da068b668ce8c4d3186e261e0.tar.gz
brdo-c4d228a4b5d6f09da068b668ce8c4d3186e261e0.tar.bz2
- rating module:
+ fixed the gravity math: it was broken due to the node system updates + XHMTL-ified the emited HTML code
-rw-r--r--modules/rating.module45
1 files changed, 18 insertions, 27 deletions
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() {
?>
- <P>The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.</P>
+ <p>The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.</p>
<?
}
function rating_gravity($uid) {
$period = 5184000; // maximum 60 days
- $number = 30; // maximum 30 comments
+ $number = 30; // maximum 30 nodes
- $r1 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND status = 1");
- while ($node = db_fetch_object($r1)) {
- $bonus += variable_get("rating_weight_$node->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 .= "<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
+ $output .= "<table cellpadding=\"1\" cellspacing=\"1\">\n";
while ($account = db_fetch_object($result)) {
$ranking = $account->old - $account->new;
- $output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_name($account) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
+ $output .= "<tr><td align=\"right\">". ++$i .".</td><td>". format_name($account) ."</td><td align=\"right\">". check_output($account->rating) ."</td><td>(". ($ranking < 0 ? "" : "+") ."$ranking)</td></tr>";
}
- $output .= "</TABLE>\n";
+ $output .= "</table>\n";
return $output;
}
@@ -107,9 +98,9 @@ function rating_page() {
}
function rating_block() {
- $block[0][subject] = "Top 10:<BR>users";
- $block[0][content] = rating_list(10);
- $block[0][info] = "Top 10: users";
+ $block[0]["subject"] = "Top 10:<br />users";
+ $block[0]["content"] = rating_list(10);
+ $block[0]["info"] = "Top 10: users";
return $block;
}