You are here

function realname_admin_fields_submit in Real Name 6

Form submit handler.

File

./realname.admin.inc, line 420
The RealName module allows the admin to choose fields from the user profile that will be used to add a "realname" element (method) to a user object. Hook_user is used to automatically add this to any user object that is loaded.

Code

function realname_admin_fields_submit($form, &$form_state) {
  $i = 0;
  $fields = array();

  // Run the form values to get all the fields they want.
  while (isset($form_state['values']['field_select_' . $i])) {
    if ($form_state['values']['field_select_' . $i]) {
      $fields[] = array(
        'title' => $form_state['values']['field_name_' . $i],
        'weight' => $form_state['values']['field_weight_' . $i],
      );
    }
    $i++;
  }

  // A little hoop jumping to sort right.
  uasort($fields, '_realname_sort');
  $realname_fields = array();
  foreach ($fields as $key => $values) {
    $realname_fields[$values['title']] = $values['weight'];
  }

  // Okay, save the stuff.
  variable_set('realname_fields', $realname_fields);
  variable_set('realname_pattern', $form_state['values']['realname_pattern']);
  variable_set('realname_homepage', $form_state['values']['realname_homepage']);
  variable_set('realname_nofollow', $form_state['values']['realname_nofollow']);

  // Mark form for realname recalculation.
  variable_set('realname_recalculate', TRUE);
  drupal_set_message(t('Configuration has been updated.'), 'status');
}