| 1 |
<?php |
<?php |
| 2 |
// $Id: userpoints_retroactive.module,v 1.5.2.1 2009/03/31 17:03:52 kbahey Exp $ |
// $Id: userpoints_retroactive.module,v 1.5.2.2 2009/04/15 12:38:02 kbahey Exp $ |
| 3 |
|
|
| 4 |
// Based on a script by Miguel Figueiredo <elmig@debianpt.org>, 2006 |
// Based on a script by Miguel Figueiredo <elmig@debianpt.org>, 2006 |
| 5 |
|
|
| 61 |
} |
} |
| 62 |
|
|
| 63 |
function userpoints_retroactive_do() { |
function userpoints_retroactive_do() { |
|
userpoints_retroactive_nodes(); |
|
|
userpoints_retroactive_comments(); |
|
|
|
|
|
|
|
| 64 |
set_time_limit(240); |
set_time_limit(240); |
| 65 |
timer_start('up_retro'); |
timer_start('up_retro'); |
| 66 |
$num = userpoints_retroactive_nodes(); |
$num = userpoints_retroactive_nodes(); |
| 67 |
$num += userpoints_retroactive_comments(); |
$num += userpoints_retroactive_comments(); |
| 68 |
$num += userpoints_retroactive_votingapi(); |
$num += userpoints_retroactive_votingapi(); |
| 69 |
$ms = timer_read('up_retro'); |
$ms = timer_read('up_retro'); |
| 70 |
|
|
| 71 |
watchdog('userpoints', t('Userpoints retroactive processed %count items in %ms milliseconds'), array('%ms' => $ms, '%count' => $num)); |
watchdog('userpoints', t('Userpoints retroactive processed %count items in %ms milliseconds'), array('%ms' => $ms, '%count' => $num)); |
| 72 |
} |
} |
| 73 |
|
|
| 74 |
function userpoints_retroactive_nodes() { |
function userpoints_retroactive_nodes() { |
| 75 |
|
$num = 0; |
| 76 |
$result = db_query("SELECT uid, type, COUNT(uid) AS val FROM {node} WHERE uid > 0 GROUP BY uid, type"); |
$result = db_query("SELECT uid, type, COUNT(uid) AS val FROM {node} WHERE uid > 0 GROUP BY uid, type"); |
| 77 |
while($node = db_fetch_object($result)) { |
while($node = db_fetch_object($result)) { |
| 78 |
$weight = variable_get(USERPOINTS_POST . $node->type, 0); |
$weight = variable_get(USERPOINTS_POST . $node->type, 0); |
| 90 |
} |
} |
| 91 |
|
|
| 92 |
function userpoints_retroactive_comments() { |
function userpoints_retroactive_comments() { |
| 93 |
|
$num = 0; |
| 94 |
$weight = variable_get(USERPOINTS_POST_COMMENT, 0); |
$weight = variable_get(USERPOINTS_POST_COMMENT, 0); |
| 95 |
$result = db_query('SELECT uid, COUNT(uid) AS val FROM {comments} WHERE uid > 0 GROUP BY uid'); |
$result = db_query('SELECT uid, COUNT(uid) AS val FROM {comments} WHERE uid > 0 GROUP BY uid'); |
| 96 |
while($comment = db_fetch_object($result)) { |
while($comment = db_fetch_object($result)) { |
| 108 |
} |
} |
| 109 |
|
|
| 110 |
function userpoints_retroactive_votingapi() { |
function userpoints_retroactive_votingapi() { |
| 111 |
|
$num = 0; |
| 112 |
$weight = variable_get('userpoints_votingapi_vote', 0); |
$weight = variable_get('userpoints_votingapi_vote', 0); |
| 113 |
$result = db_query('SELECT uid, COUNT(*) AS val from {votingapi_vote} GROUP BY uid'); |
$result = db_query('SELECT uid, COUNT(*) AS val from {votingapi_vote} GROUP BY uid'); |
| 114 |
while($u = db_fetch_object($result)) { |
while($u = db_fetch_object($result)) { |