function user_badges_user_view in User Badges 7.3
Same name and namespace in other branches
- 7 user_badges.module \user_badges_user_view()
- 7.2 user_badges.module \user_badges_user_view()
Implements hook_user_view().
File
- ./
user_badges.module, line 262 - @brief User Badges module file
Code
function user_badges_user_view($account, $view_mode) {
// Check if the user's badges are to be shown.
if ($account->uid > 1 && user_access('suppress badges in user profile', $account)) {
return;
}
// @TODO: Show role badges separately?
$account->content['user_badges'] = array(
'#title' => t('Badges'),
'#type' => 'user_profile_category',
'#attributes' => array(
'class' => array(
'badges',
),
),
);
if (isset($account->badges) && count($account->badges)) {
$badgeimgs = array();
foreach ($account->badges as $badge) {
$badgeimgs[] = theme('user_badge', array(
'badge' => $badge,
'account' => $account,
));
}
$account->content['user_badges']['badges'] = array(
'#type' => 'user_profile_item',
'#title' => '',
'#markup' => theme('user_badge_group', array(
'badgeimages' => $badgeimgs,
)),
'#attributes' => array(
'class' => array(
'badges',
),
),
);
}
else {
// They don't have any badges, so show the "no badges" message.
$account->content['user_badges']['badges'] = array(
'#type' => 'user_profile_item',
'#title' => '',
'#markup' => variable_get('user_badges_nobadges', ''),
'#attributes' => array(
'class' => array(
'badges',
),
),
);
}
}