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

Diff of /contributions/modules/userpoints/userpoints.module

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

revision 1.67.2.46, Mon Sep 7 23:11:57 2009 UTC revision 1.67.2.47, Thu Oct 1 20:22:30 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  //$Id: userpoints.module,v 1.67.2.45 2009/07/18 21:50:12 kbahey Exp $  //$Id: userpoints.module,v 1.67.2.46 2009/09/07 23:11:57 kbahey Exp $
3    
4  // Copyright 2005-2007 Khalid Baheyeldin http://2bits.com  // Copyright 2005-2007 Khalid Baheyeldin http://2bits.com
5    
# Line 494  function userpoints_get_current_points($ Line 494  function userpoints_get_current_points($
494   * @return number of max points in that user's account   * @return number of max points in that user's account
495   */   */
496  function userpoints_get_max_points($uid = NULL, $tid = NULL) {  function userpoints_get_max_points($uid = NULL, $tid = NULL) {
497      static $max = array();
498    
499      // Check if uid is passed as a parameter
500    if (!$uid) {    if (!$uid) {
501        // It is not, so we use the currently logged in user's uid
502      global $user;      global $user;
503      $uid = $user->uid;      $uid = $user->uid;
504    }    }
505    
506      // Check if a term id is passed as a parameter
507    if (!$tid) {    if (!$tid) {
508        // It is not, so get the default term id
509      $tid = userpoints_get_default_tid();      $tid = userpoints_get_default_tid();
510    }    }
511    elseif ($tid == 'all') {  
512      return (int)db_result(db_query('SELECT SUM(max_points) FROM {userpoints} WHERE uid = %d',  $uid));    // Check if we have already cached the maximum for the user/term combination on previous calls
513      if (!isset($max[$uid][$tid])) {
514        // We did not cache it
515        if ($tid == 'all') {
516          // There is no term id, so we use "all"
517          $max[$uid][$tid] = db_result(db_query('SELECT SUM(max_points) FROM {userpoints} WHERE uid = %d',  $uid));
518        }
519        else {
520          // A term ID is specified, so fetch its maximum points
521          $max[$uid][$tid] = db_result(db_query('SELECT max_points FROM {userpoints} WHERE uid = %d AND tid = %d', $uid, $tid));
522        }
523    }    }
524    return (int)db_result(db_query('SELECT max_points FROM {userpoints} WHERE uid = %d AND tid = %d', $uid, $tid));    // Return
525      return $max[$uid][$tid];
526  }  }
527    
528  /**  /**

Legend:
Removed from v.1.67.2.46  
changed lines
  Added in v.1.67.2.47

  ViewVC Help
Powered by ViewVC 1.1.2