function user_badges_for_uid in User Badges 7.3
Same name and namespace in other branches
- 5 user_badges.module \user_badges_for_uid()
- 6.2 user_badges.module \user_badges_for_uid()
- 6 user_badges.module \user_badges_for_uid()
- 7 user_badges.module \user_badges_for_uid()
- 7.2 user_badges.module \user_badges_for_uid()
Returns HTML representation of user badges for given uid
Parameters
$uid the user id:
$refresh (FALSE) when TRUE, refreshes the cache for $uid:
Return value
string html representation of userbadges
1 call to user_badges_for_uid()
- views_handler_field_user_badges_user_uid::render in includes/
views/ views_handler_field_user_badges_user_uid.inc - Render the field.
File
- ./
user_badges.module, line 1182 - @brief User Badges module file
Code
function user_badges_for_uid($uid, $refresh = FALSE) {
static $cache;
if ($uid) {
if (isset($cache[$uid]) && !$refresh) {
return $cache[$uid];
}
else {
// TODO: User can also have role badges.
$user_badges = user_badges_get_badges($uid);
$account = user_load($uid);
foreach ($user_badges as $badge) {
$badges[] = theme('user_badge', array(
'badge' => $badge,
'account' => $account,
));
}
$cache[$uid] = isset($badges) ? theme('user_badge_group', array(
'badgeimages' => $badges,
)) : '';
return $cache[$uid];
}
}
}