3 // This file defines settingpages and externalpages under the "users" category
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')));
9 or has_capability('moodle/user:create', $systemcontext)
10 or has_capability('moodle/user:update', $systemcontext)
11 or has_capability('moodle/user:delete', $systemcontext)
12 or has_capability('moodle/role:manage', $systemcontext)
13 or has_capability('moodle/role:assign', $systemcontext)
14 or has_capability('moodle/cohort:manage', $systemcontext)
15 or has_capability('moodle/cohort:view', $systemcontext)) { // speedup for non-admins, add all caps used on this page
18 if (empty($CFG->loginhttps)) {
19 $securewwwroot = $CFG->wwwroot;
21 $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
23 // stuff under the "accounts" subcategory
24 $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')));
25 $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')));
26 $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
28 // "User default preferences" settingpage.
29 $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin'));
30 if ($ADMIN->fulltree) {
32 $choices['0'] = new lang_string('emaildisplayno');
33 $choices['1'] = new lang_string('emaildisplayyes');
34 $choices['2'] = new lang_string('emaildisplaycourse');
35 $temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
39 $choices['0'] = new lang_string('textformat');
40 $choices['1'] = new lang_string('htmlformat');
41 $temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices));
44 $choices['0'] = new lang_string('emaildigestoff');
45 $choices['1'] = new lang_string('emaildigestcomplete');
46 $choices['2'] = new lang_string('emaildigestsubjects');
47 $temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'),
48 new lang_string('emaildigest_help'), 0, $choices));
52 $choices['1'] = new lang_string('autosubscribeyes');
53 $choices['0'] = new lang_string('autosubscribeno');
54 $temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'),
58 $choices['0'] = new lang_string('trackforumsno');
59 $choices['1'] = new lang_string('trackforumsyes');
60 $temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'),
63 $ADMIN->add('accounts', $temp);
65 $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
66 $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
69 // stuff under the "roles" subcategory
71 // "userpolicies" settingpage
72 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
73 if ($ADMIN->fulltree) {
74 if (!during_initial_install()) {
75 $context = context_system::instance();
77 $otherroles = array();
78 $guestroles = array();
80 $creatornewroles = array();
82 $defaultteacherid = null;
83 $defaultuserid = null;
84 $defaultguestid = null;
86 $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
87 foreach ($roles as $role) {
88 $rolename = $role->localname;
89 switch ($role->archetype) {
91 $creatornewroles[$role->id] = $rolename;
95 case 'editingteacher':
96 $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
97 $creatornewroles[$role->id] = $rolename;
100 $creatornewroles[$role->id] = $rolename;
105 $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
106 $guestroles[$role->id] = $rolename;
109 $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
110 $userroles[$role->id] = $rolename;
115 $creatornewroles[$role->id] = $rolename;
116 $otherroles[$role->id] = $rolename;
121 if (empty($guestroles)) {
122 $guestroles[0] = new lang_string('none');
126 if (empty($userroles)) {
127 $userroles[0] = new lang_string('none');
131 $restorersnewrole = $creatornewroles;
132 $restorersnewrole[0] = new lang_string('none');
134 $temp->add(new admin_setting_configselect('notloggedinroleid', new lang_string('notloggedinroleid', 'admin'),
135 new lang_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
136 $temp->add(new admin_setting_configselect('guestroleid', new lang_string('guestroleid', 'admin'),
137 new lang_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
138 $temp->add(new admin_setting_configselect('defaultuserroleid', new lang_string('defaultuserroleid', 'admin'),
139 new lang_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
140 $temp->add(new admin_setting_configselect('creatornewroleid', new lang_string('creatornewroleid', 'admin'),
141 new lang_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
142 $temp->add(new admin_setting_configselect('restorernewroleid', new lang_string('restorernewroleid', 'admin'),
143 new lang_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole));
149 unset($creatornewroles);
150 unset($restorersnewrole);
153 $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0));
155 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'),
156 new lang_string('confighiddenuserfields', 'admin'), array(),
157 array('description' => new lang_string('description'),
158 'city' => new lang_string('city'),
159 'country' => new lang_string('country'),
160 'timezone' => new lang_string('timezone'),
161 'webpage' => new lang_string('webpage'),
162 'icqnumber' => new lang_string('icqnumber'),
163 'skypeid' => new lang_string('skypeid'),
164 'yahooid' => new lang_string('yahooid'),
165 'aimid' => new lang_string('aimid'),
166 'msnid' => new lang_string('msnid'),
167 'firstaccess' => new lang_string('firstaccess'),
168 'lastaccess' => new lang_string('lastaccess'),
169 'lastip' => new lang_string('lastip'),
170 'mycourses' => new lang_string('mycourses'),
171 'groups' => new lang_string('groups'),
172 'suspended' => new lang_string('suspended', 'auth'),
175 // Select fields to display as part of user identity (only to those
176 // with moodle/site:viewuseridentity).
177 // Options include fields from the user table that might be helpful to
178 // distinguish when adding or listing users ('I want to add the John
179 // Smith from Science faculty').
180 // Username is not included as an option because in some sites, it might
181 // be a security problem to reveal usernames even to trusted staff.
182 // Custom user profile fields are not currently supported.
183 $temp->add(new admin_setting_configmulticheckbox('showuseridentity',
184 new lang_string('showuseridentity', 'admin'),
185 new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
186 'idnumber' => new lang_string('idnumber'),
187 'email' => new lang_string('email'),
188 'phone1' => new lang_string('phone1'),
189 'phone2' => new lang_string('phone2'),
190 'department' => new lang_string('department'),
191 'institution' => new lang_string('institution'),
192 'city' => new lang_string('city'),
193 'country' => new lang_string('country'),
195 $setting = new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'),
196 new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50);
197 $setting->set_force_ltr(true);
198 $temp->add($setting);
199 $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'),
200 new lang_string('alternativefullnameformat_desc', 'admin'),
201 'language', PARAM_RAW, 50));
202 $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
203 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
204 $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
207 $ADMIN->add('roles', $temp);
209 if (is_siteadmin()) {
210 $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
212 $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
213 $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'));
214 $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')));