Merge branch 'MDL-62277-master' of git://github.com/bmbrands/moodle
[moodle.git] / admin / settings / users.php
CommitLineData
11b749ca 1<?php
50999a0b 2
3// This file defines settingpages and externalpages under the "users" category
4
e106013f
SH
5$ADMIN->add('users', new admin_category('accounts', new lang_string('accounts', 'admin')));
6$ADMIN->add('users', new admin_category('roles', new lang_string('permissions', 'role')));
a97af76c 7$ADMIN->add('users', new admin_category('privacy', new lang_string('privacyandpolicies', 'admin')));
d86f4473 8
fc4069d6 9if ($hassiteconfig
fc4069d6 10 or has_capability('moodle/user:create', $systemcontext)
11 or has_capability('moodle/user:update', $systemcontext)
61d04bcc 12 or has_capability('moodle/user:delete', $systemcontext)
13 or has_capability('moodle/role:manage', $systemcontext)
864e2805
PS
14 or has_capability('moodle/role:assign', $systemcontext)
15 or has_capability('moodle/cohort:manage', $systemcontext)
16 or has_capability('moodle/cohort:view', $systemcontext)) { // speedup for non-admins, add all caps used on this page
7d0c81b3 17
50999a0b 18
220a90c5 19 // stuff under the "accounts" subcategory
e106013f
SH
20 $ADMIN->add('accounts', new admin_externalpage('editusers', new lang_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
21 $ADMIN->add('accounts', new admin_externalpage('userbulk', new lang_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete')));
b58764ff 22 $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$CFG->wwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
747dac69
MG
23
24 // "User default preferences" settingpage.
25 $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin'));
26 if ($ADMIN->fulltree) {
27 $choices = array();
28 $choices['0'] = new lang_string('emaildisplayno');
29 $choices['1'] = new lang_string('emaildisplayyes');
30 $choices['2'] = new lang_string('emaildisplaycourse');
31 $temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
d2bba97d 32 new lang_string('emaildisplay_help'), 2, $choices));
747dac69
MG
33
34 $choices = array();
35 $choices['0'] = new lang_string('textformat');
36 $choices['1'] = new lang_string('htmlformat');
37 $temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices));
38
39 $choices = array();
40 $choices['0'] = new lang_string('emaildigestoff');
41 $choices['1'] = new lang_string('emaildigestcomplete');
42 $choices['2'] = new lang_string('emaildigestsubjects');
43 $temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'),
44 new lang_string('emaildigest_help'), 0, $choices));
45
46
47 $choices = array();
48 $choices['1'] = new lang_string('autosubscribeyes');
49 $choices['0'] = new lang_string('autosubscribeno');
50 $temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'),
51 '', 1, $choices));
52
d9b60e31
PS
53 $choices = array();
54 $choices['0'] = new lang_string('trackforumsno');
55 $choices['1'] = new lang_string('trackforumsyes');
56 $temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'),
57 '', 0, $choices));
747dac69
MG
58 }
59 $ADMIN->add('accounts', $temp);
60
e106013f
SH
61 $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
62 $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
220a90c5 63
64
65 // stuff under the "roles" subcategory
220a90c5 66
67 // "userpolicies" settingpage
e106013f 68 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
220a90c5 69 if ($ADMIN->fulltree) {
31a99877 70 if (!during_initial_install()) {
bf006d2c 71 $context = context_system::instance();
82053cb1
PS
72
73 $otherroles = array();
4f0c2d00
PS
74 $guestroles = array();
75 $userroles = array();
4f0c2d00 76 $creatornewroles = array();
df997f84 77
82053cb1
PS
78 $defaultteacherid = null;
79 $defaultuserid = null;
80 $defaultguestid = null;
81
c52551dc
PS
82 $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
83 foreach ($roles as $role) {
84 $rolename = $role->localname;
4f0c2d00
PS
85 switch ($role->archetype) {
86 case 'manager':
87 $creatornewroles[$role->id] = $rolename;
88 break;
89 case 'coursecreator':
90 break;
91 case 'editingteacher':
82053cb1 92 $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
4f0c2d00
PS
93 $creatornewroles[$role->id] = $rolename;
94 break;
95 case 'teacher':
96 $creatornewroles[$role->id] = $rolename;
97 break;
98 case 'student':
4f0c2d00
PS
99 break;
100 case 'guest':
82053cb1 101 $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
4f0c2d00
PS
102 $guestroles[$role->id] = $rolename;
103 break;
104 case 'user':
82053cb1 105 $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
4f0c2d00
PS
106 $userroles[$role->id] = $rolename;
107 break;
108 case 'frontpage':
109 break;
110 default:
111 $creatornewroles[$role->id] = $rolename;
82053cb1 112 $otherroles[$role->id] = $rolename;
4f0c2d00 113 break;
220a90c5 114 }
115 }
11b749ca 116
82053cb1 117 if (empty($guestroles)) {
e106013f 118 $guestroles[0] = new lang_string('none');
82053cb1
PS
119 $defaultguestid = 0;
120 }
121
122 if (empty($userroles)) {
e106013f 123 $userroles[0] = new lang_string('none');
4f0c2d00 124 $defaultuserid = 0;
220a90c5 125 }
126
73d000f3 127 $restorersnewrole = $creatornewroles;
e106013f
SH
128 $restorersnewrole[0] = new lang_string('none');
129
130 $temp->add(new admin_setting_configselect('notloggedinroleid', new lang_string('notloggedinroleid', 'admin'),
131 new lang_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
132 $temp->add(new admin_setting_configselect('guestroleid', new lang_string('guestroleid', 'admin'),
133 new lang_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
134 $temp->add(new admin_setting_configselect('defaultuserroleid', new lang_string('defaultuserroleid', 'admin'),
135 new lang_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
136 $temp->add(new admin_setting_configselect('creatornewroleid', new lang_string('creatornewroleid', 'admin'),
137 new lang_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
138 $temp->add(new admin_setting_configselect('restorernewroleid', new lang_string('restorernewroleid', 'admin'),
139 new lang_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole));
82053cb1
PS
140
141 // release memory
142 unset($otherroles);
143 unset($guestroles);
144 unset($userroles);
145 unset($creatornewroles);
73d000f3 146 unset($restorersnewrole);
220a90c5 147 }
69833712 148
e106013f
SH
149 $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0));
150
151 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'),
152 new lang_string('confighiddenuserfields', 'admin'), array(),
153 array('description' => new lang_string('description'),
565f3f25 154 'email' => new lang_string('email'),
e106013f
SH
155 'city' => new lang_string('city'),
156 'country' => new lang_string('country'),
d6e7a63d 157 'timezone' => new lang_string('timezone'),
e106013f
SH
158 'webpage' => new lang_string('webpage'),
159 'icqnumber' => new lang_string('icqnumber'),
160 'skypeid' => new lang_string('skypeid'),
161 'yahooid' => new lang_string('yahooid'),
162 'aimid' => new lang_string('aimid'),
163 'msnid' => new lang_string('msnid'),
164 'firstaccess' => new lang_string('firstaccess'),
165 'lastaccess' => new lang_string('lastaccess'),
9d9361e8 166 'lastip' => new lang_string('lastip'),
e106013f 167 'mycourses' => new lang_string('mycourses'),
44d5c138
SH
168 'groups' => new lang_string('groups'),
169 'suspended' => new lang_string('suspended', 'auth'),
4ad72c28 170 )));
99cd2f77 171
5c60a847 172 // Select fields to display as part of user identity (only to those
173 // with moodle/site:viewuseridentity).
174 // Options include fields from the user table that might be helpful to
175 // distinguish when adding or listing users ('I want to add the John
176 // Smith from Science faculty').
177 // Username is not included as an option because in some sites, it might
178 // be a security problem to reveal usernames even to trusted staff.
179 // Custom user profile fields are not currently supported.
180 $temp->add(new admin_setting_configmulticheckbox('showuseridentity',
e106013f
SH
181 new lang_string('showuseridentity', 'admin'),
182 new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
183 'idnumber' => new lang_string('idnumber'),
184 'email' => new lang_string('email'),
70fb46c8 185 'phone1' => new lang_string('phone1'),
e106013f
SH
186 'phone2' => new lang_string('phone2'),
187 'department' => new lang_string('department'),
188 'institution' => new lang_string('institution'),
7a22e49e
JP
189 'city' => new lang_string('city'),
190 'country' => new lang_string('country'),
5c60a847 191 )));
113efed5
FM
192 $setting = new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'),
193 new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50);
194 $setting->set_force_ltr(true);
195 $temp->add($setting);
b3d5f7bc
AG
196 $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'),
197 new lang_string('alternativefullnameformat_desc', 'admin'),
198 'language', PARAM_RAW, 50));
9a51c3d9 199 $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
e106013f 200 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
f127b1a5 201 $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
c785d40a 202 }
4766a50c 203
220a90c5 204 $ADMIN->add('roles', $temp);
8f8ed475 205
4f0c2d00 206 if (is_siteadmin()) {
e106013f 207 $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
4f0c2d00 208 }
e106013f
SH
209 $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
210 $ADMIN->add('roles', new admin_externalpage('assignroles', new lang_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
211 $ADMIN->add('roles', new admin_externalpage('checkpermissions', new lang_string('checkglobalpermissions', 'role'), "$CFG->wwwroot/$CFG->admin/roles/check.php?contextid=".$systemcontext->id, array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage')));
8a8272b0 212
a559f630 213} // end of speedup
a97af76c
SA
214
215// Privacy settings.
216if ($hassiteconfig) {
217 $temp = new admin_settingpage('privacysettings', new lang_string('privacysettings', 'admin'));
218
219 $options = array(
220 0 => get_string('no'),
221 1 => get_string('yes')
222 );
223 $url = new moodle_url('/admin/settings.php?section=supportcontact');
224 $url = $url->out();
225 $setting = new admin_setting_configselect('agedigitalconsentverification',
226 new lang_string('agedigitalconsentverification', 'admin'),
227 new lang_string('agedigitalconsentverification_desc', 'admin', $url), 0, $options);
228 $setting->set_force_ltr(true);
229 $temp->add($setting);
230
b1f1bd2e
SA
231 // See {@link https://gdpr-info.eu/art-8-gdpr/}.
232 $ageofdigitalconsentmap = implode(PHP_EOL, [
233 '*, 16',
234 'AT, 14',
235 'ES, 14',
236 'SI, 14',
237 'US, 13'
238 ]);
a97af76c
SA
239 $setting = new admin_setting_agedigitalconsentmap('agedigitalconsentmap',
240 new lang_string('ageofdigitalconsentmap', 'admin'),
241 new lang_string('ageofdigitalconsentmap_desc', 'admin'),
b1f1bd2e 242 $ageofdigitalconsentmap,
a97af76c
SA
243 PARAM_RAW
244 );
245 $temp->add($setting);
246
247 $ADMIN->add('privacy', $temp);
248
249 // Policy settings.
250 $temp = new admin_settingpage('policysettings', new lang_string('policysettings', 'admin'));
251 $temp->add(new admin_settings_sitepolicy_handler_select('sitepolicyhandler', new lang_string('sitepolicyhandler', 'core_admin'),
252 new lang_string('sitepolicyhandler_desc', 'core_admin')));
253 $temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'core_admin'),
254 new lang_string('sitepolicy_help', 'core_admin'), '', PARAM_RAW));
255 $temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'core_admin'),
256 new lang_string('sitepolicyguest_help', 'core_admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW));
257
258 $ADMIN->add('privacy', $temp);
259}