2 require_once $CFG->libdir
.'/formslib.php';
4 class admin_uploaduser_form
extends moodleform
{
5 function definition (){
7 $templateuser = $this->_customdata
;
8 if(empty($templateuser)) {
9 if (!$templateuser = get_admin()) {
10 error('Could not find site admin');
14 $mform =& $this->_form
;
16 $mform->addElement('file', 'userfile', get_string('file'));
17 $mform->addRule('userfile', null, 'required');
19 $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
20 $mform->addElement('text', 'username', get_string('username'), 'size="20"');
22 $modules = get_list_of_plugins('auth');
23 $auth_options = array();
24 foreach ($modules as $module) {
25 $auth_options[$module] = get_string("auth_$module"."title", "auth");
27 $mform->addElement('select', 'auth', get_string('chooseauthmethod','auth'), $auth_options);
28 $mform->setDefault('auth', $templateuser->auth
);
29 $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod','auth')));
31 $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
33 get_string('emaildisplayno'),
34 get_string('emaildisplayyes'),
35 get_string('emaildisplaycourse'),
37 $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
38 $mform->setDefault('maildisplay', 2);
41 get_string('emailenable'),
42 get_string('emaildisable'),
44 $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
47 get_string('textformat'),
48 get_string('htmlformat'),
50 $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
51 $mform->setDefault('mailformat', 1);
54 get_string('autosubscribeyes'),
55 get_string('autosubscribeno'),
57 $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
58 $mform->setDefault('autosubscribe', 1);
60 if ($CFG->htmleditor
) {
62 get_string('texteditor'),
63 get_string('htmleditor'),
65 $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
66 $mform->setDefault('htmleditor', 1);
69 $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
70 $mform->setType('city', PARAM_MULTILANG
);
71 $mform->setDefault('city', $templateuser->city
);
73 $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries());
74 $mform->setDefault('country', $templateuser->country
);
76 $choices = get_list_of_timezones();
77 $choices['99'] = get_string('serverlocaltime');
78 $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
79 $mform->setDefault('timezone', $templateuser->timezone
);
81 $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
82 $mform->setDefault('lang', $templateuser->lang
);
84 $mform->addElement('htmleditor', 'description', get_string('userdescription'));
85 $mform->setType('description', PARAM_CLEAN
);
86 $mform->setHelpButton('description', array('text', get_string('helptext')));
88 $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
90 $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
91 $mform->setType('institution', PARAM_MULTILANG
);
92 $mform->setDefault('institution', $templateuser->institution
);
94 $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
95 $mform->setType('department', PARAM_MULTILANG
);
96 $mform->setDefault('department', $templateuser->department
);
98 $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
99 $mform->setType('phone1', PARAM_CLEAN
);
101 $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
102 $mform->setType('phone2', PARAM_CLEAN
);
104 $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
105 $mform->setType('address', PARAM_MULTILANG
);
107 $mform->addElement('header', 'settingsheader', get_string('settings'));
110 get_string('infilefield', 'auth'),
111 get_string('createpasswordifneeded', 'auth'),
113 $mform->addElement('select', 'createpassword', get_string('passwordhandling', 'auth'), $choices);
115 $mform->addElement('selectyesno', 'updateaccounts', get_string('updateaccounts', 'admin'));
116 $mform->addElement('selectyesno', 'allowrenames', get_string('allowrenames', 'admin'));
119 get_string('addcounter', 'admin'),
120 get_string('skipuser', 'admin'),
122 $mform->addElement('select', 'duplicatehandling', get_string('newusernamehandling', 'admin'), $choices);
124 $this->add_action_buttons(false, get_string('uploadusers'));
127 function get_userfile_name(){
128 if ($this->is_submitted() and $this->is_validated()) {
129 // return the temporary filename to process
130 return $this->_upload_manager
->files
['userfile']['tmp_name'];