1
|
<?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
|
'#type' => 'textarea',
|
16
|
'#title' => t('CAS username(s)'),
|
17
|
'#required' => TRUE,
|
18
|
'#default_value' => '',
|
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
|
'#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
|
'#value' => t('Create new account(s)'),
|
28
|
);
|
29
|
return $form;
|
30
|
}
|
31
|
|
32
|
function cas_add_user_form_submit($form, &$form_state) {
|
33
|
$cas_names = preg_split('/[\n\r|\r|\n]+/', $form_state['values']['cas_name']);
|
34
|
|
35
|
foreach ($cas_names as $cas_name) {
|
36
|
$operations[] = array('cas_batch_user_add', array($cas_name));
|
37
|
}
|
38
|
|
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
|
);
|
46
|
|
47
|
batch_set($batch);
|
48
|
}
|