You are here

function realname_admin_module_submit in Real Name 6

File

./realname.admin.inc, line 261
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_module_submit($form, &$form_state) {
  if (isset($form_state['storage']['module_chosen'])) {
    variable_set('realname_profile_type', $form_state['values']['type']);
  }
  else {

    // First time here, so sav ethe chosen module and prepare types.
    $module = $form_state['values']['module'];
    variable_set('realname_profile_module', $module);
    $form_state['storage']['module_chosen'] = $module;
    $show_types = $form_state['values']['show_types'];
    if ($show_types[$module]) {
      $module_info = realname_supported_modules($module);
      if (isset($module_info['file'])) {
        $path = !empty($module_info['path']) ? $module_info['path'] : drupal_get_path('module', $module);
        require_once $path . '/' . $module_info['file'];
      }

      // This module uses types, so let's see what types are allowed.
      $types = (array) module_invoke($module, 'realname_get_types');
      if (count($types) > 1) {
        $form_state['storage']['types'] = $types;
        return;
      }
      else {
        variable_set('realname_profile_type', key($types));
      }
    }
  }

  // Mark form for realname recalculation.
  variable_set('realname_recalculate', TRUE);

  // We are done with types, so go pick fields.
  unset($form_state['storage']);
  $form_state['redirect'] = 'admin/user/realname/fields';

  // Go get the fields now.
  return;
}