function user_badges_change_form_submit in User Badges 6.2
Same name and namespace in other branches
- 6 user_badges.module \user_badges_change_form_submit()
- 7.4 user_badges.module \user_badges_change_form_submit()
- 7 user_badges.module \user_badges_change_form_submit()
- 7.2 user_badges.module \user_badges_change_form_submit()
- 7.3 user_badges.module \user_badges_change_form_submit()
Process user_badges_remove_form form submissions.
Add the named badge. Remove the checked badges.
File
- ./
user_badges.module, line 651 - @brief User Badges module file
Code
function user_badges_change_form_submit($form, &$form_state) {
$uid = $form_state['values']['uid'];
//Add badges for non-empty fields
for ($i = 1; $i <= 5; $i++) {
if (!empty($form_state['values']['add' . $i])) {
$validation = user_badges_badge_autocomplete_validation($form_state['values']['add' . $i]);
user_badges_user_add_badge($uid, $validation[0], 'user');
}
}
//Remove any checked badges
$badges_to_go = array();
foreach ($form_state['values'] as $bid => $value) {
if (is_numeric($bid) && $value == 1) {
$badges_to_go[] = $bid;
}
}
if (count($badges_to_go)) {
foreach ($badges_to_go as $bid) {
user_badges_user_remove_badge($uid, $bid);
}
drupal_set_message(t('!removalcount badge(s) removed.', array(
'!removalcount' => count($badges_to_go),
)));
}
}