Projet

Général

Profil

Paste
Télécharger (1,31 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / cas / cas.user.inc @ 6e9292aa

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Provides CAS user registration administrative pages.
6
 */
7
8
/**
9
 * Creates a CAS user registration page.
10
 */
11
function cas_add_user_form() {
12
  $form = array();
13
14
  $form['account']['cas_name'] = array(
15 e9f59589 Assos Assos
    '#type' => 'textarea',
16
    '#title' => t('CAS username(s)'),
17 85ad3d82 Assos Assos
    '#required' => TRUE,
18
    '#default_value' => '',
19 e9f59589 Assos Assos
    '#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 85ad3d82 Assos Assos
    '#element_validate' => array('_cas_name_element_validate'),
21
    '#weight' => -10,
22
  );
23
24
  $form['actions'] = array('#type' => 'actions');
25
  $form['actions']['submit'] = array(
26
    '#type' => 'submit',
27 e9f59589 Assos Assos
    '#value' => t('Create new account(s)'),
28 85ad3d82 Assos Assos
  );
29
  return $form;
30
}
31
32
function cas_add_user_form_submit($form, &$form_state) {
33 e9f59589 Assos Assos
  $cas_names = preg_split('/[\n\r|\r|\n]+/', $form_state['values']['cas_name']);
34 85ad3d82 Assos Assos
35 e9f59589 Assos Assos
  foreach ($cas_names as $cas_name) {
36
    $operations[] = array('cas_batch_user_add', array($cas_name));
37 85ad3d82 Assos Assos
  }
38
39 e9f59589 Assos Assos
  $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
  );
46 85ad3d82 Assos Assos
47 e9f59589 Assos Assos
  batch_set($batch);
48 85ad3d82 Assos Assos
}