/[drupal]/contributions/modules/user_stats/user_stats.module
ViewVC logotype

Diff of /contributions/modules/user_stats/user_stats.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.16.2.23, Wed Jul 1 07:08:23 2009 UTC revision 1.2.2.16.2.24, Sun Jul 5 02:41:03 2009 UTC
# Line 1  Line 1 
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
# Line 83  function user_stats_menu() { Line 83  function user_stats_menu() {
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.
# Line 195  function user_stats_get_stats($type, $ui Line 205  function user_stats_get_stats($type, $ui
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();
# Line 236  function user_stats_cache_get($type, $ui Line 247  function user_stats_cache_get($type, $ui
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();
# Line 566  function user_stats_login_count_reset_ac Line 578  function user_stats_login_count_reset_ac
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')) {
# Line 632  function user_stats_token_list($type = ' Line 645  function user_stats_token_list($type = '
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}
# Line 653  function user_stats_isset($statistic, $u Line 667  function user_stats_isset($statistic, $u
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) {
# Line 718  function user_stats_login_count_update($ Line 733  function user_stats_login_count_update($
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) {
# Line 801  function user_stats_post_count_update($o Line 817  function user_stats_post_count_update($o
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

Legend:
Removed from v.1.2.2.16.2.23  
changed lines
  Added in v.1.2.2.16.2.24

  ViewVC Help
Powered by ViewVC 1.1.2