You are here

function realname_admin_settings_submit in Real Name 5

Form submit handler.

File

./realname.module, line 604
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_settings_submit($form_id, $form_values) {
  $i = 0;
  $fields = array();

  // Run the form values to get all the fields they want.
  while (isset($form_values['field_select_' . $i])) {
    if ($form_values['field_select_' . $i]) {
      $fields[] = array(
        'title' => $form_values['field_name_' . $i],
        'weight' => $form_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_values['realname_pattern']);
  variable_set('realname_theme', $form_values['realname_theme']);
  variable_set('realname_max_username', $form_values['realname_max_username']);
  variable_set('realname_nodeapi', $form_values['realname_nodeapi']);
  variable_set('realname_notver', $form_values['realname_notver']);
  variable_set('realname_nofollow', $form_values['realname_nofollow']);
  variable_set('realname_homepage', $form_values['realname_homepage']);
  drupal_set_message(t('Configuration has been updated.'), 'status');
}