You are here

function user_badges_roles_form_submit in User Badges 7.3

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_roles_form_submit()
  2. 6.2 user_badges.admin.inc \user_badges_roles_form_submit()
  3. 6 user_badges.admin.inc \user_badges_roles_form_submit()
  4. 7 user_badges.admin.inc \user_badges_roles_form_submit()
  5. 7.2 user_badges.admin.inc \user_badges_roles_form_submit()

Submission function for user_badges_roles_form.

File

./user_badges.admin.inc, line 790
@brief User Badges admin functions

Code

function user_badges_roles_form_submit($form, &$form_state) {
  $array = $form_state['values']['roles'] + $form_state['values']['blocked'];

  //If the selectory type used to enter badges was the autocomplete, then, extract the bid from the text
  if (variable_get('user_badges_selector_type', 1) == 1) {
    foreach ($array as $field => &$value) {

      // We now have a string as our badge, so just extract the bid.
      preg_match('/\\(' . t('Badge ID') . ' (\\d+)\\)/', $value, $matches);

      // Transform our value into just the bid.
      if (!empty($matches)) {
        $value = $matches[1];
      }
    }
  }
  user_badges_save_roles($array);
}