MDL-16043: manage case when administrator set enrol_remotecoursefield or enrol_remote...
[moodle-linuxchix.git] / admin / settings / users.php
blobc15caf6f0baa94a95384b2ba96906cd6163824f3
1 <?php // $Id$
3 // This file defines settingpages and externalpages under the "users" category
5 if ($hassiteconfig
6 or has_capability('moodle/site:uploadusers', $systemcontext)
7 or has_capability('moodle/user:create', $systemcontext)
8 or has_capability('moodle/user:update', $systemcontext)
9 or has_capability('moodle/user:delete', $systemcontext)) { // speedup for non-admins, add all caps used on this page
12 $ADMIN->add('users', new admin_category('authsettings', get_string('authentication','admin')));
14 $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin'));
15 $temp->add(new admin_setting_manageauths());
16 $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), ''));
17 $temp->add(new admin_setting_special_registerauth());
18 $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'),
19 get_string('showguestlogin', 'auth'), '1', array('0'=>get_string('hide'), '1'=>get_string('show'))));
20 $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'),
21 get_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php')), ''));
22 $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'),
23 get_string('forgottenpassword', 'auth'), ''));
24 $temp->add(new admin_setting_configtextarea('auth_instructions', get_string('instructions', 'auth'),
25 get_string('authinstructions', 'auth'), ''));
26 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
27 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
29 $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
30 $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
31 $ADMIN->add('authsettings', $temp);
34 if ($auths = get_list_of_plugins('auth')) {
35 $authsenabled = get_enabled_auth_plugins();
36 $authbyname = array();
38 foreach ($auths as $auth) {
39 $strauthname = get_string("auth_{$auth}title", "auth");
40 if ($strauthname == "[[auth_{$auth}title]]") {
41 $strauthname = get_string("auth_{$auth}title", "auth_{$auth}");
43 $authbyname[$strauthname] = $auth;
45 ksort($authbyname);
47 foreach ($authbyname as $strauthname=>$authname) {
48 if (file_exists($CFG->dirroot.'/auth/'.$authname.'/settings.php')) {
49 // do not show disabled auths in tree, keep only settings link on manage page
50 $settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled));
51 if ($ADMIN->fulltree) {
52 include($CFG->dirroot.'/auth/'.$authname.'/settings.php');
54 // TODO: finish implementation of common settings - locking, etc.
55 $ADMIN->add('authsettings', $settings);
57 } else {
58 $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)));
64 if(empty($CFG->loginhttps)) {
65 $securewwwroot = $CFG->wwwroot;
66 } else {
67 $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
69 // stuff under the "accounts" subcategory
70 $ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
71 $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
72 $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')));
73 $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
74 $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers'));
75 $ADMIN->add('accounts', new admin_externalpage('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.php", 'moodle/site:uploadusers'));
76 $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
79 // stuff under the "roles" subcategory
80 $ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
81 $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php"));
82 $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id));
85 // "userpolicies" settingpage
86 $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
87 if ($ADMIN->fulltree) {
88 if (!empty($CFG->rolesactive)) {
89 $context = get_context_instance(CONTEXT_SYSTEM);
90 if (!$guestrole = get_guest_role()) {
91 $guestrole->id = 0;
93 if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
94 $studentrole = array_shift($studentroles); /// Take the first one
95 } else {
96 $studentrole->id = 0;
98 if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW)) {
99 $userrole = array_shift($userroles); /// Take the first one
100 } else {
101 $userrole->id = 0;
103 if (empty($CFG->creatornewroleid)) {
104 if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, $context)) {
105 $teachereditrole = array_shift($teacherroles);
106 set_config('creatornewroleid', $teachereditrole->id);
107 } else {
108 set_config('creatornewroleid', 0);
111 if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
112 $guestroles = array();
114 // we must not use assignable roles here:
115 // 1/ unsetting roles as assignable for admin might bork the settings!
116 // 2/ default user role should not be assignable anyway
117 $allroles = array();
118 $nonguestroles = array();
119 if ($roles = get_all_roles()) {
120 foreach ($roles as $role) {
121 $rolename = strip_tags(format_string($role->name, true));
122 $allroles[$role->id] = $rolename;
123 if (!isset($guestroles[$role->id])) {
124 $nonguestroles[$role->id] = $rolename;
129 $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
130 get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $allroles ));
131 $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
132 get_string('configguestroleid', 'admin'), $guestrole->id, $allroles));
133 $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
134 get_string('configdefaultuserroleid', 'admin'), $userrole->id, $nonguestroles)); // guest role here breaks a lot of stuff
137 $temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
139 if (!empty($CFG->rolesactive)) {
140 $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
141 get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles));
142 $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
143 get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid, $allroles));
146 $temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
148 if (!empty($CFG->rolesactive)) {
149 $temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
150 get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
153 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
154 get_string('confighiddenuserfields', 'admin'), array(),
155 array('description' => get_string('description'),
156 'city' => get_string('city'),
157 'country' => get_string('country'),
158 'webpage' => get_string('webpage'),
159 'icqnumber' => get_string('icqnumber'),
160 'skypeid' => get_string('skypeid'),
161 'yahooid' => get_string('yahooid'),
162 'aimid' => get_string('aimid'),
163 'msnid' => get_string('msnid'),
164 'lastaccess' => get_string('lastaccess'))));
167 $ADMIN->add('roles', $temp);
169 } // end of speedup