function userpoints_get_current_points in User Points 7
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_get_current_points()
- 5 userpoints.module \userpoints_get_current_points()
- 5.2 userpoints.module \userpoints_get_current_points()
- 6 userpoints.module \userpoints_get_current_points()
- 7.2 userpoints.module \userpoints_get_current_points()
Get current points of a user.
Parameters
$uid: User ID of the user to get or lose the points.
$tid: Term ID to get points for, or 'all'.
Return value
Number of current points in that user's account.
13 calls to userpoints_get_current_points()
- UserpointsAdminTestCase::testAddEditPoints in tests/
userpoints_api.test - UserpointsAPITestCase::testBasicCall in tests/
userpoints_api.test - Call userpoints_userpointsapi() with just points.
- UserpointsBaseTestCase::addPoints in tests/
userpoints_api.test - Add points through the admin form.
- UserpointsBaseTestCase::verifyPoints in tests/
userpoints_api.test - Verify the current and optionally max points in a specific category.
- UserpointsServiceTestCase::testAddRetrievePoints in ./
userpoints_service.test - Basic tests for granting and retreiving points through a service.
1 string reference to 'userpoints_get_current_points'
- userpoints_userpointsapi in ./
userpoints.module - Save userpoints changes and call hooks.
File
- ./
userpoints.module, line 726
Code
function userpoints_get_current_points($uid = NULL, $tid = NULL) {
$points = drupal_static(__FUNCTION__, array());
if (!$uid) {
global $user;
$uid = $user->uid;
}
// 0 is a valid value for the Uncategorized category.
if (!isset($tid)) {
$tid = userpoints_get_default_tid();
}
if (!isset($points[$uid][$tid])) {
if ($tid === 'all') {
$points[$uid][$tid] = (int) db_query('SELECT points FROM {userpoints_total} WHERE uid = :uid', array(
':uid' => $uid,
))
->fetchField();
}
else {
$points[$uid][$tid] = (int) db_query('SELECT points FROM {userpoints} WHERE uid = :uid AND tid = :tid', array(
':uid' => $uid,
':tid' => $tid,
))
->fetchField();
}
}
return $points[$uid][$tid];
}