function flag_user_view in Flag 7.2
Same name and namespace in other branches
- 7.3 flag.module \flag_user_view()
Implements hook_user_view().
File
- ./
flag.module, line 857 - The Flag module.
Code
function flag_user_view($account, $view_mode) {
$flags = flag_get_flags('user');
$flag_items = array();
foreach ($flags as $flag) {
if (!$flag
->access($account->uid)) {
// User has no permission to use this flag.
continue;
}
if (!$flag->show_on_profile) {
// Flag not set to appear on profile.
continue;
}
$flag_items[$flag->name] = array(
'#type' => 'user_profile_item',
'#title' => $flag
->get_title($account->uid),
'#markup' => $flag
->theme($flag
->is_flagged($account->uid) ? 'unflag' : 'flag', $account->uid),
'#attributes' => array(
'class' => array(
'flag-profile-' . $flag->name,
),
),
);
}
if (!empty($flag_items)) {
$account->content['flags'] = $flag_items;
$account->content['flags'] += array(
'#type' => 'user_profile_category',
'#title' => t('Actions'),
'#attributes' => array(
'class' => array(
'flag-profile',
),
),
);
}
}