function user_badges_roles_form_validate in User Badges 7.4
Same name and namespace in other branches
- 6.2 user_badges.admin.inc \user_badges_roles_form_validate()
- 6 user_badges.admin.inc \user_badges_roles_form_validate()
- 7 user_badges.admin.inc \user_badges_roles_form_validate()
- 7.2 user_badges.admin.inc \user_badges_roles_form_validate()
- 7.3 user_badges.admin.inc \user_badges_roles_form_validate()
Validation function for user_badges_roles_form.
File
- includes/
user_badges.admin.inc, line 227 - Contains administrative UI for User Badge.
Code
function user_badges_roles_form_validate($form, &$form_state) {
$array = array(
'user_badges_blocked_badge' => $form_state['values']['user_badges_blocked_badge'],
) + $form_state['values']['user_badges_role'];
$errors = FALSE;
foreach (array_count_values($array) as $key => $count) {
if ($key && $count > 1) {
form_set_error('', t("You shouldn't use same badge for more than one role (or for blocked user and one role)"));
$errors = TRUE;
break;
}
}
if (!$errors && variable_get('user_badges_selector_type', 1)) {
$values =& $form_state['values'];
if ($values['user_badges_blocked_badge']) {
$parts = explode('(', $values['user_badges_blocked_badge']);
$values['user_badges_blocked_badge'] = substr(end($parts), 0, -1);
}
foreach ($values['user_badges_role'] as $key => &$value) {
$parts = explode('(', $value);
$value = substr(end($parts), 0, -1);
}
}
}