Commit | Line | Data |
---|---|---|
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'))); | |
d86f4473 | 7 | |
fc4069d6 | 8 | if ($hassiteconfig |
fc4069d6 | 9 | or has_capability('moodle/user:create', $systemcontext) |
10 | or has_capability('moodle/user:update', $systemcontext) | |
61d04bcc | 11 | or has_capability('moodle/user:delete', $systemcontext) |
12 | or has_capability('moodle/role:manage', $systemcontext) | |
864e2805 PS |
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 | |
7d0c81b3 | 16 | |
50999a0b | 17 | |
1caea91e | 18 | if (empty($CFG->loginhttps)) { |
220a90c5 | 19 | $securewwwroot = $CFG->wwwroot; |
20 | } else { | |
21 | $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); | |
22 | } | |
23 | // stuff under the "accounts" subcategory | |
e106013f SH |
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')); | |
747dac69 MG |
27 | |
28 | // "User default preferences" settingpage. | |
29 | $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin')); | |
30 | if ($ADMIN->fulltree) { | |
31 | $choices = array(); | |
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'), | |
36 | '', 2, $choices)); | |
37 | ||
38 | $choices = array(); | |
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)); | |
42 | ||
43 | $choices = array(); | |
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)); | |
49 | ||
50 | ||
51 | $choices = array(); | |
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'), | |
55 | '', 1, $choices)); | |
56 | ||
d9b60e31 PS |
57 | $choices = array(); |
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'), | |
61 | '', 0, $choices)); | |
747dac69 MG |
62 | } |
63 | $ADMIN->add('accounts', $temp); | |
64 | ||
e106013f SH |
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'))); | |
220a90c5 | 67 | |
68 | ||
69 | // stuff under the "roles" subcategory | |
220a90c5 | 70 | |
71 | // "userpolicies" settingpage | |
e106013f | 72 | $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin')); |
220a90c5 | 73 | if ($ADMIN->fulltree) { |
31a99877 | 74 | if (!during_initial_install()) { |
bf006d2c | 75 | $context = context_system::instance(); |
82053cb1 PS |
76 | |
77 | $otherroles = array(); | |
4f0c2d00 PS |
78 | $guestroles = array(); |
79 | $userroles = array(); | |
4f0c2d00 | 80 | $creatornewroles = array(); |
df997f84 | 81 | |
82053cb1 PS |
82 | $defaultteacherid = null; |
83 | $defaultuserid = null; | |
84 | $defaultguestid = null; | |
85 | ||
c52551dc PS |
86 | $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT); |
87 | foreach ($roles as $role) { | |
88 | $rolename = $role->localname; | |
4f0c2d00 PS |
89 | switch ($role->archetype) { |
90 | case 'manager': | |
91 | $creatornewroles[$role->id] = $rolename; | |
92 | break; | |
93 | case 'coursecreator': | |
94 | break; | |
95 | case 'editingteacher': | |
82053cb1 | 96 | $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id; |
4f0c2d00 PS |
97 | $creatornewroles[$role->id] = $rolename; |
98 | break; | |
99 | case 'teacher': | |
100 | $creatornewroles[$role->id] = $rolename; | |
101 | break; | |
102 | case 'student': | |
4f0c2d00 PS |
103 | break; |
104 | case 'guest': | |
82053cb1 | 105 | $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id; |
4f0c2d00 PS |
106 | $guestroles[$role->id] = $rolename; |
107 | break; | |
108 | case 'user': | |
82053cb1 | 109 | $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id; |
4f0c2d00 PS |
110 | $userroles[$role->id] = $rolename; |
111 | break; | |
112 | case 'frontpage': | |
113 | break; | |
114 | default: | |
115 | $creatornewroles[$role->id] = $rolename; | |
82053cb1 | 116 | $otherroles[$role->id] = $rolename; |
4f0c2d00 | 117 | break; |
220a90c5 | 118 | } |
119 | } | |
11b749ca | 120 | |
82053cb1 | 121 | if (empty($guestroles)) { |
e106013f | 122 | $guestroles[0] = new lang_string('none'); |
82053cb1 PS |
123 | $defaultguestid = 0; |
124 | } | |
125 | ||
126 | if (empty($userroles)) { | |
e106013f | 127 | $userroles[0] = new lang_string('none'); |
4f0c2d00 | 128 | $defaultuserid = 0; |
220a90c5 | 129 | } |
130 | ||
73d000f3 | 131 | $restorersnewrole = $creatornewroles; |
e106013f SH |
132 | $restorersnewrole[0] = new lang_string('none'); |
133 | ||
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)); | |
82053cb1 PS |
144 | |
145 | // release memory | |
146 | unset($otherroles); | |
147 | unset($guestroles); | |
148 | unset($userroles); | |
149 | unset($creatornewroles); | |
73d000f3 | 150 | unset($restorersnewrole); |
220a90c5 | 151 | } |
69833712 | 152 | |
e106013f SH |
153 | $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0)); |
154 | ||
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'), | |
d6e7a63d | 160 | 'timezone' => new lang_string('timezone'), |
e106013f SH |
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'), | |
9d9361e8 | 169 | 'lastip' => new lang_string('lastip'), |
e106013f | 170 | 'mycourses' => new lang_string('mycourses'), |
44d5c138 SH |
171 | 'groups' => new lang_string('groups'), |
172 | 'suspended' => new lang_string('suspended', 'auth'), | |
4ad72c28 | 173 | ))); |
99cd2f77 | 174 | |
5c60a847 | 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', | |
e106013f SH |
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'), | |
70fb46c8 | 188 | 'phone1' => new lang_string('phone1'), |
e106013f SH |
189 | 'phone2' => new lang_string('phone2'), |
190 | 'department' => new lang_string('department'), | |
191 | 'institution' => new lang_string('institution'), | |
5c60a847 | 192 | ))); |
a327f25e | 193 | $temp->add(new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50)); |
b3d5f7bc AG |
194 | $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'), |
195 | new lang_string('alternativefullnameformat_desc', 'admin'), | |
196 | 'language', PARAM_RAW, 50)); | |
9a51c3d9 | 197 | $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT)); |
e106013f | 198 | $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0)); |
f127b1a5 | 199 | $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm')); |
c785d40a | 200 | } |
4766a50c | 201 | |
220a90c5 | 202 | $ADMIN->add('roles', $temp); |
8f8ed475 | 203 | |
4f0c2d00 | 204 | if (is_siteadmin()) { |
e106013f | 205 | $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php")); |
4f0c2d00 | 206 | } |
e106013f SH |
207 | $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage')); |
208 | $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')); | |
209 | $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 | 210 | |
a559f630 | 211 | } // end of speedup |