You are here

function user_badges_for_uid in User Badges 6.2

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_for_uid()
  2. 6 user_badges.module \user_badges_for_uid()
  3. 7 user_badges.module \user_badges_for_uid()
  4. 7.2 user_badges.module \user_badges_for_uid()
  5. 7.3 user_badges.module \user_badges_for_uid()

Returns HTML representation of user badges for given uid

Parameters

$uid the user id: @param $refresh (FALSE) when TRUE, refreshes the cache for $uid

@return string html representation of userbadges

1 call to user_badges_for_uid()
views_handler_field_user_badges_user_uid::render in ./views_handler_field_user_badges_user_uid.inc

File

./user_badges.module, line 1002
@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 {
      $user_badges = user_badges_get_badges($uid);
      foreach ((array) $user_badges as $badge) {
        $badges[] = theme('user_badge', $badge, user_load($uid));
      }
      $cache[$uid] = isset($badges) ? theme('user_badge_group', $badges) : '';
      return $cache[$uid];
    }
  }
}