| 1 |
<?php |
<?php |
| 2 |
// $Id: user_stats.module,v 1.2.2.16.2.22 2009/06/26 07:22:37 liammcdermott Exp $ |
// $Id: user_stats.module,v 1.2.2.16.2.23 2009/07/01 07:08:23 liammcdermott Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 83 |
* counted types) then 'n/a' is returned. |
* counted types) then 'n/a' is returned. |
| 84 |
*/ |
*/ |
| 85 |
function user_stats_get_stats($type, $uid) { |
function user_stats_get_stats($type, $uid) { |
| 86 |
|
// Bug [#479394] - Anonymous User Comment preview causes 'UID is not a number' |
| 87 |
|
// errors. User Stats always expects UIDs to be numeric. Since this is a bit |
| 88 |
|
// of a hack/workaround, we only fix the specific case of an anonymous user |
| 89 |
|
// comment preview, everything should (and will) generate an error. These can |
| 90 |
|
// be dealt with on a case-by-case basis. |
| 91 |
|
$item = menu_get_item(); |
| 92 |
|
if ($uid == NULL && $item['path'] == 'comment/reply/%') { |
| 93 |
|
$uid = 0; |
| 94 |
|
} |
| 95 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 96 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 97 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 98 |
|
return; |
| 99 |
} |
} |
| 100 |
|
|
| 101 |
// IP address is really a bit of feature creep. |
// IP address is really a bit of feature creep. |
| 205 |
function user_stats_cache_get($type, $uid) { |
function user_stats_cache_get($type, $uid) { |
| 206 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 207 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 208 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 209 |
|
return; |
| 210 |
} |
} |
| 211 |
|
|
| 212 |
$user_stats_cache = user_stats_cache_set(); |
$user_stats_cache = user_stats_cache_set(); |
| 247 |
function user_stats_cache_set($type = NULL, $uid = 0, $data = NULL) { |
function user_stats_cache_set($type = NULL, $uid = 0, $data = NULL) { |
| 248 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 249 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 250 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 251 |
|
return; |
| 252 |
} |
} |
| 253 |
|
|
| 254 |
static $user_stats_cache = array(); |
static $user_stats_cache = array(); |
| 578 |
|
|
| 579 |
/** |
/** |
| 580 |
* Implementation of hook_user_stats(). |
* Implementation of hook_user_stats(). |
| 581 |
* For invoking rules module. |
* |
| 582 |
|
* Invoke the Rules module. |
| 583 |
*/ |
*/ |
| 584 |
function user_stats_user_stats($type, $op, $uid, $value) { |
function user_stats_user_stats($type, $op, $uid, $value) { |
| 585 |
if (module_exists('rules')) { |
if (module_exists('rules')) { |
| 645 |
function user_stats_isset($statistic, $uid) { |
function user_stats_isset($statistic, $uid) { |
| 646 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 647 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 648 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 649 |
|
return; |
| 650 |
} |
} |
| 651 |
|
|
| 652 |
$result = db_result(db_query("SELECT COUNT(*) FROM {user_stats_values} |
$result = db_result(db_query("SELECT COUNT(*) FROM {user_stats_values} |
| 667 |
* @param $op |
* @param $op |
| 668 |
* Whether the user login count should be incremented, decremented, or reset. |
* Whether the user login count should be incremented, decremented, or reset. |
| 669 |
* Possible values are: |
* Possible values are: |
| 670 |
* 'increment' |
* - 'increment' |
| 671 |
* 'decrement' |
* - 'decrement' |
| 672 |
* 'reset' |
* - 'reset' |
| 673 |
*/ |
*/ |
| 674 |
function user_stats_login_count_update($op, $uid) { |
function user_stats_login_count_update($op, $uid) { |
| 675 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 676 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 677 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 678 |
|
return; |
| 679 |
} |
} |
| 680 |
|
|
| 681 |
switch ($op) { |
switch ($op) { |
| 733 |
function user_stats_post_count_update($op, $uid) { |
function user_stats_post_count_update($op, $uid) { |
| 734 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 735 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 736 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 737 |
|
return; |
| 738 |
} |
} |
| 739 |
|
|
| 740 |
switch ($op) { |
switch ($op) { |
| 817 |
function user_stats_ip_address_update($uid, $ip_address) { |
function user_stats_ip_address_update($uid, $ip_address) { |
| 818 |
// Dirt simple error checking. |
// Dirt simple error checking. |
| 819 |
if (!is_numeric($uid)) { |
if (!is_numeric($uid)) { |
| 820 |
trigger_error('UID is not a number.', E_USER_WARNING); |
trigger_error('UID is not a number', E_USER_WARNING); |
| 821 |
|
return; |
| 822 |
} |
} |
| 823 |
|
|
| 824 |
// Don't bother recording IPs of anonymous users, and don't record any |
// Don't bother recording IPs of anonymous users, and don't record any |