MDL-8096 - added proper trimming of usernames; site:config capability is now neede...
[moodle.git] / user / edit_form_common.php
CommitLineData
ad6226fb 1<?php //$Id$
2
d8734783 3 if (!defined('MOODLE_INTERNAL')) {
4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
5 }
6
7 $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
8 $mform->addRule('firstname', $strrequired, 'required', null, 'client');
9 $mform->setType('firstname', PARAM_NOTAGS);
10
11 $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
12 $mform->addRule('lastname', $strrequired, 'required', null, 'client');
13 $mform->setType('lastname', PARAM_NOTAGS);
14
15 $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
16 $mform->addRule('email', $strrequired, 'required', null, 'client');
17
18 $choices = array();
19 $choices['0'] = get_string('emaildisplayno');
20 $choices['1'] = get_string('emaildisplayyes');
21 $choices['2'] = get_string('emaildisplaycourse');
22 $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
23 $mform->setDefault('emaildisplay', 2);
24
25 $choices = array();
26 $choices['0'] = get_string('emailenable');
27 $choices['1'] = get_string('emaildisable');
28 $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
29 $mform->setDefault('emailenable', 1);
30
31 $choices = array();
32 $choices['0'] = get_string('textformat');
33 $choices['1'] = get_string('htmlformat');
34 $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
35 $mform->setDefault('mailformat', 1);
36 $mform->setAdvanced('mailformat');
37
38 if (!empty($CFG->allowusermailcharset)) {
ad6226fb 39 $choices = array();
d8734783 40 $charsets = get_list_of_charsets();
41 if (!empty($CFG->sitemailcharset)) {
42 $choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
43 } else {
44 $choices['0'] = get_string('site').' ('.current_charset().')';
ad6226fb 45 }
d8734783 46 $choices = array_merge($choices, $charsets);
47 $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
48 $mform->setAdvanced('preference_mailcharset');
49 }
50
51 $choices = array();
52 $choices['0'] = get_string('emaildigestoff');
53 $choices['1'] = get_string('emaildigestcomplete');
54 $choices['2'] = get_string('emaildigestsubjects');
55 $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
56 $mform->setDefault('maildigest', 0);
57 $mform->setAdvanced('maildigest');
58
59 $choices = array();
60 $choices['1'] = get_string('autosubscribeyes');
61 $choices['0'] = get_string('autosubscribeno');
62 $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
63 $mform->setDefault('autosubscribe', 0);
64 $mform->setAdvanced('autosubscribe');
65
66 if (!empty($CFG->forum_trackreadposts)) {
ad6226fb 67 $choices = array();
d8734783 68 $choices['0'] = get_string('trackforumsno');
69 $choices['1'] = get_string('trackforumsyes');
70 $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
71 $mform->setDefault('trackforums', 0);
72 $mform->setAdvanced('trackforums');
73 }
74
75 if ($CFG->htmleditor) {
ad6226fb 76 $choices = array();
d8734783 77 $choices['0'] = get_string('texteditor');
78 $choices['1'] = get_string('htmleditor');
79 $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
80 $mform->setDefault('htmleditor', 1);
81 $mform->setAdvanced('htmleditor');
82 }
83
84 if (empty($CFG->enableajax)) {
85 $mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
86 $mform->setAdvanced('ajaxdisabled');
87 } else {
ad6226fb 88 $choices = array();
d8734783 89 $choices['0'] = get_string('ajaxno');
90 $choices['1'] = get_string('ajaxyes');
91 $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
92 $mform->setDefault('ajax', 0);
93 $mform->setAdvanced('ajax');
94 }
95
96 $choices = array();
97 $choices['0'] = get_string('screenreaderno');
98 $choices['1'] = get_string('screenreaderyes');
99 $mform->addElement('select', 'screenreader', get_string('screenreaderuse'), $choices);
100 $mform->setDefault('screenreader', 0);
101 $mform->setAdvanced('screenreader');
102
103 $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
104 $mform->setType('city', PARAM_MULTILANG);
105 $mform->addRule('city', $strrequired, 'required', null, 'client');
106
107
108 $choices = get_list_of_countries();
109 $choices= array(''=>get_string('selectacountry').'...') + $choices;
110 $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
111 $mform->addRule('country', $strrequired, 'required', null, 'client');
112 if (!empty($CFG->country)) {
113 $mform->setDefault('country', $CFG->country);
114 }
115
116 $choices = get_list_of_timezones();
117 $choices['99'] = get_string('serverlocaltime');
118 if ($CFG->forcetimezone != 99) {
119 $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
120 } else {
121 $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
122 $mform->setDefault('timezone', '99');
123 }
124
125 $choices = array();
126 if ($choices = get_list_of_languages()) {
127 $mform->addElement('select', 'lang', get_string('preferredlanguage'), $choices);
128 $mform->setDefault('lang', $CFG->lang);
129 }
130
131 if (!empty($CFG->allowuserthemes)) {
ad6226fb 132 $choices = array();
d8734783 133 $choices[''] = get_string('default');
134 $choices += get_list_of_themes();
135 $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
136 $mform->setAdvanced('theme');
137 }
ad6226fb 138
d8734783 139 $mform->addElement('htmleditor', 'description', get_string('userdescription'));
140 $mform->setType('description', PARAM_CLEAN);
141 $mform->setHelpButton('description', array('text', get_string('helptext')));
ad6226fb 142
d8734783 143 if (!empty($CFG->gdversion)) {
144 $mform->addElement('header', 'moodle_picture', get_string('pictureof'));//TODO: Accessibility fix fieldset legend
ad6226fb 145
d8734783 146 $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
ad6226fb 147
d8734783 148 $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
149 $mform->setDefault('deletepicture',false);
ad6226fb 150
d8734783 151 $mform->addElement('file', 'imagefile', get_string('newpicture'));
152 $mform->setHelpButton('imagefile', array('picture', get_string('helppicture')));
ad6226fb 153
d8734783 154 $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
155 $mform->setType('imagealt', PARAM_MULTILANG);
ad6226fb 156
d8734783 157 }
ad6226fb 158
d8734783 159 /// Moodle optional fields
160 $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
161 $mform->setAdvanced('moodle_optional');
ad6226fb 162
d8734783 163 $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
164 $mform->setType('url', PARAM_URL);
ad6226fb 165
d8734783 166 $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
167 $mform->setType('icq', PARAM_CLEAN);
ad6226fb 168
d8734783 169 $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
170 $mform->setType('skype', PARAM_CLEAN);
ad6226fb 171
d8734783 172 $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
173 $mform->setType('aim', PARAM_CLEAN);
ad6226fb 174
d8734783 175 $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
176 $mform->setType('yahoo', PARAM_CLEAN);
ad6226fb 177
d8734783 178 $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
179 $mform->setType('msn', PARAM_CLEAN);
ad6226fb 180
d8734783 181 $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
182 $mform->setType('idnumber', PARAM_RAW);
ad6226fb 183
d8734783 184 $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
185 $mform->setType('institution', PARAM_MULTILANG);
ad6226fb 186
d8734783 187 $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
188 $mform->setType('department', PARAM_MULTILANG);
ad6226fb 189
d8734783 190 $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
191 $mform->setType('phone1', PARAM_CLEAN);
ad6226fb 192
d8734783 193 $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
194 $mform->setType('phone2', PARAM_CLEAN);
ad6226fb 195
d8734783 196 $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
197 $mform->setType('address', PARAM_MULTILANG);
ad6226fb 198
199
200?>