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