MDL-21781 integrating cohorts into UI - admin tree and list of categories in edit...
[moodle.git] / admin / settings / users.php
CommitLineData
11b749ca 1<?php
50999a0b 2
3// This file defines settingpages and externalpages under the "users" category
4
d86f4473 5$ADMIN->add('users', new admin_category('authsettings', get_string('authentication','admin')));
6$ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
7$ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
8
fc4069d6 9if ($hassiteconfig
10 or has_capability('moodle/site:uploadusers', $systemcontext)
11 or has_capability('moodle/user:create', $systemcontext)
12 or has_capability('moodle/user:update', $systemcontext)
61d04bcc 13 or has_capability('moodle/user:delete', $systemcontext)
14 or has_capability('moodle/role:manage', $systemcontext)
864e2805
PS
15 or has_capability('moodle/role:assign', $systemcontext)
16 or has_capability('moodle/cohort:manage', $systemcontext)
17 or has_capability('moodle/cohort:view', $systemcontext)) { // speedup for non-admins, add all caps used on this page
7d0c81b3 18
50999a0b 19
220a90c5 20 $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin'));
21 $temp->add(new admin_setting_manageauths());
22 $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), ''));
23 $temp->add(new admin_setting_special_registerauth());
24 $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'),
25 get_string('showguestlogin', 'auth'), '1', array('0'=>get_string('hide'), '1'=>get_string('show'))));
26 $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'),
93f66983 27 get_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
220a90c5 28 $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'),
29 get_string('forgottenpassword', 'auth'), ''));
247b7dbb 30 $temp->add(new admin_setting_confightmleditor('auth_instructions', get_string('instructions', 'auth'),
220a90c5 31 get_string('authinstructions', 'auth'), ''));
32 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
33 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
bff34a67 34 $temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1));
11b749ca 35
5d6308d4 36 $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
37 $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
220a90c5 38 $ADMIN->add('authsettings', $temp);
39
40
17da2e6f 41 if ($auths = get_plugin_list('auth')) {
220a90c5 42 $authsenabled = get_enabled_auth_plugins();
43 $authbyname = array();
44
17da2e6f 45 foreach ($auths as $auth => $authdir) {
370f10b7 46 $strauthname = get_string('pluginname', "auth_{$auth}");
220a90c5 47 $authbyname[$strauthname] = $auth;
48 }
49 ksort($authbyname);
50
51 foreach ($authbyname as $strauthname=>$authname) {
17da2e6f 52 if (file_exists($authdir.'/settings.php')) {
220a90c5 53 // do not show disabled auths in tree, keep only settings link on manage page
54 $settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled));
55 if ($ADMIN->fulltree) {
17da2e6f 56 include($authdir.'/settings.php');
220a90c5 57 }
58 // TODO: finish implementation of common settings - locking, etc.
59 $ADMIN->add('authsettings', $settings);
60
61 } else {
62 $ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !in_array($authname, $authsenabled)));
63 }
64 }
65 }
69833712 66
69833712 67
1caea91e 68 if (empty($CFG->loginhttps)) {
220a90c5 69 $securewwwroot = $CFG->wwwroot;
70 } else {
71 $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
72 }
73 // stuff under the "accounts" subcategory
220a90c5 74 $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
75 $ADMIN->add('accounts', new admin_externalpage('userbulk', get_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete')));
76 $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
77 $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers'));
b352b2e9 78 $ADMIN->add('accounts', new admin_externalpage('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.php", 'moodle/site:uploadusers'));
220a90c5 79 $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
864e2805 80 $ADMIN->add('accounts', new admin_externalpage('cohorts', get_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
220a90c5 81
82
83 // stuff under the "roles" subcategory
220a90c5 84
85 // "userpolicies" settingpage
86 $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
87 if ($ADMIN->fulltree) {
31a99877 88 if (!during_initial_install()) {
220a90c5 89 $context = get_context_instance(CONTEXT_SYSTEM);
4f0c2d00
PS
90 $allroles = array();
91 $generalroles = array();
92 $guestroles = array();
93 $userroles = array();
94 $studentroles = array();
95 $teacherroles = array();
96 $creatornewroles = array();
97
98 foreach (get_all_roles() as $role) {
99 $rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
100 $allroles[$role->id] = $rolename;
101 switch ($role->archetype) {
102 case 'manager':
103 $creatornewroles[$role->id] = $rolename;
104 break;
105 case 'coursecreator':
106 break;
107 case 'editingteacher':
108 $teacherroles[$role->id] = $rolename;
109 $creatornewroles[$role->id] = $rolename;
110 break;
111 case 'teacher':
112 $creatornewroles[$role->id] = $rolename;
113 break;
114 case 'student':
115 $studentroles[$role->id] = $rolename;
116 break;
117 case 'guest':
118 $guestroles[$role->id] = $rolename;
119 break;
120 case 'user':
121 $userroles[$role->id] = $rolename;
122 break;
123 case 'frontpage':
124 break;
125 default:
126 $creatornewroles[$role->id] = $rolename;
127 $generalroles[$role->id] = $rolename;
128 break;
220a90c5 129 }
130 }
11b749ca 131
4f0c2d00
PS
132 reset($guestroles);
133 $defaultguestid = key($guestroles);
134 reset($studentroles);
135 $defaultstudentid = key($studentroles);
136 reset($teacherroles);
137 $defaultteacherid = key($teacherroles);
138
139 if ($userroles) {
140 reset($userroles);
141 $defaultuserid = key($userroles);
142 } else {
143 $userroles = array('0'=>get_string('none'));
144 $defaultuserid = 0;
220a90c5 145 }
146
147 $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
4f0c2d00 148 get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
220a90c5 149 $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
4f0c2d00 150 get_string('configguestroleid', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
220a90c5 151 $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
4f0c2d00 152 get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $generalroles)));
220a90c5 153 }
69833712 154
220a90c5 155 $temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
69833712 156
31a99877 157 if (!during_initial_install()) {
220a90c5 158 $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
4f0c2d00 159 get_string('configdefaultcourseroleid', 'admin'), $defaultstudentid, $allroles));
220a90c5 160 $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
4f0c2d00 161 get_string('configcreatornewroleid', 'admin'), $defaultteacherid, $creatornewroles));
220a90c5 162 }
69833712 163
220a90c5 164 $temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
8f8ed475 165
31a99877 166 if (!during_initial_install()) {
220a90c5 167 $temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
168 get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
7d0c81b3 169 }
220a90c5 170
171 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
172 get_string('confighiddenuserfields', 'admin'), array(),
173 array('description' => get_string('description'),
174 'city' => get_string('city'),
175 'country' => get_string('country'),
176 'webpage' => get_string('webpage'),
177 'icqnumber' => get_string('icqnumber'),
178 'skypeid' => get_string('skypeid'),
179 'yahooid' => get_string('yahooid'),
180 'aimid' => get_string('aimid'),
181 'msnid' => get_string('msnid'),
1263a0ff 182 'firstaccess' => get_string('firstaccess'),
53bd2255 183 'lastaccess' => get_string('lastaccess'),
c6b4179c 184 'mycourses' => get_string('mycourses'),
185 'groups' => get_string('groups'))));
99cd2f77 186
187 $temp->add(new admin_setting_configmulticheckbox('extrauserselectorfields',
188 get_string('extrauserselectorfields', 'admin'), get_string('configextrauserselectorfields', 'admin'), array('email' => '1'),
189 array('email' => get_string('email'), 'idnumber' => get_string('idnumber'), 'username' => get_string('username'), )));
c785d40a 190 }
220a90c5 191 $ADMIN->add('roles', $temp);
8f8ed475 192
4f0c2d00
PS
193 if (is_siteadmin()) {
194 $ADMIN->add('roles', new admin_externalpage('admins', get_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
195 }
44079dfe 196 $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
8a8272b0 197 $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
bed9cec8 198 $ADMIN->add('roles', new admin_externalpage('checkpermissions', get_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 199
a559f630 200} // end of speedup