". t("user ratings") .""; } return $links ? $links : array(); } 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 => "Never"); $output .= form_select("Update interval", "rating_cron_time" , variable_get("rating_cron_time", 86400), $period, "The update interval for the user ratings. Requires crontab."); $weight = array("Disabled", 1, 2, 3, 4, 5, 6, 7, 9, 10); foreach (module_list() as $name) { if (module_hook($name, "user")) { $output .= form_select("Weight of a $name", "rating_weight_$name", variable_get("rating_weight_$name", 0), $weight, "The weight of a $name."); } } return $output; } function rating_cron() { // 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)) { db_query("UPDATE users SET rating = '". rating_gravity($account->uid) ."' WHERE uid = '$account->uid'"); $rating[$account->uid] = ++$i; } db_query("DELETE FROM rating"); $r2 = db_query("SELECT uid FROM users ORDER BY rating DESC"); 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.

\n"; while ($account = db_fetch_object($result)) { $ranking = $account->old - $account->new; $output .= "". ++$i .".". format_name($account) ."". check_output($account->rating) ."(". ($ranking < 0 ? "" : "+") ."$ranking)"; } $output .= "\n"; return $output; } function rating_page() { global $user, $theme; $theme->header(); if (user_access("access user ratings")) { $theme->box(t("Top 100 users"), rating_list(100)); } else { $theme->box(t("Access denied"), message_access()); } $theme->footer(); } function rating_block() { $block[0]["subject"] = "Top 10:
users"; $block[0]["content"] = rating_list(10); $block[0]["info"] = "Top 10: users"; return $block; } ?>