function user_badges_remove_badge_action in User Badges 7.4
Same name and namespace in other branches
- 6.2 user_badges.module \user_badges_remove_badge_action()
- 6 user_badges.module \user_badges_remove_badge_action()
- 7 user_badges.actions.inc \user_badges_remove_badge_action()
- 7.2 user_badges.actions.inc \user_badges_remove_badge_action()
- 7.3 user_badges.actions.inc \user_badges_remove_badge_action()
Implements a Drupal action.
File
- ./
user_badges.actions.inc, line 93 - Actions for User Badges module.
Code
function user_badges_remove_badge_action(&$account, $context = array()) {
if (isset($account->uid)) {
$uid = $account->uid;
}
elseif (isset($context['uid'])) {
$uid = $context['uid'];
}
else {
global $user;
$uid = $user->uid;
}
$success = TRUE;
$badges = user_badges_get_badges('all');
foreach ($context['badges'] as $bid) {
$success = (bool) user_badges_user_remove_badge($uid, $bid, 'uid');
if ($success) {
watchdog('action', 'Removed user badge %badge to user %name.', array(
'%name' => check_plain($user->name),
'%badge' => check_plain($badges[$bid]->name),
));
}
else {
watchdog('action', 'Unable to remove user badge %badge to user %name.', array(
'%name' => check_plain($user->name),
'%badge' => check_plain($badges[$bid]->name),
), WATCHDOG_WARNING);
}
}
}