Projet

Général

Profil

Révision e9f59589

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/cas/cas.user.inc
12 12
  $form = array();
13 13

  
14 14
  $form['account']['cas_name'] = array(
15
    '#type' => 'textfield',
16
    '#title' => t('CAS username'),
15
    '#type' => 'textarea',
16
    '#title' => t('CAS username(s)'),
17 17
    '#required' => TRUE,
18 18
    '#default_value' => '',
19
    '#description' => t('Registration will proceed as if the user with the specified CAS username just logged in.'),
19
    '#description' => t('Enter a single username, or multiple usernames, one per line. Registration will proceed as if the user(s) with the specified CAS username just logged in.'),
20 20
    '#element_validate' => array('_cas_name_element_validate'),
21 21
    '#weight' => -10,
22 22
  );
......
24 24
  $form['actions'] = array('#type' => 'actions');
25 25
  $form['actions']['submit'] = array(
26 26
    '#type' => 'submit',
27
    '#value' => t('Create new account'),
27
    '#value' => t('Create new account(s)'),
28 28
  );
29 29
  return $form;
30 30
}
31 31

  
32 32
function cas_add_user_form_submit($form, &$form_state) {
33
  $options = array(
34
    'invoke_cas_user_presave' => TRUE,
35
  );
36
  $account = cas_user_register($form_state['values']['cas_name'], $options);
33
  $cas_names = preg_split('/[\n\r|\r|\n]+/', $form_state['values']['cas_name']);
37 34

  
38
  // Terminate if an error occurred while registering the user.
39
  if (!$account) {
40
    drupal_set_message(t("Error saving user account."), 'error');
41
    $form_state['redirect'] = '';
42
    return;
35
  foreach ($cas_names as $cas_name) {
36
    $operations[] = array('cas_batch_user_add', array($cas_name));
43 37
  }
44 38

  
45
  // Set these in case another module needs the values.
46
  $form_state['user'] = $account;
47
  $form_state['values']['uid'] = $account->uid;
39
  $batch = array(
40
    'title' => t('Creating users...'),
41
    'operations' => $operations,
42
    'finished' => 'cas_batch_user_finished',
43
    'progress_message' => t('Processed @current out of @total.'),
44
    'file' => drupal_get_path('module', 'cas') . '/cas.batch.inc',
45
  );
48 46

  
49
  $uri = entity_uri('user', $account);
50
  drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
47
  batch_set($batch);
51 48
}

Formats disponibles : Unified diff