3 // This file defines settingpages and externalpages under the "users" category
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;
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);
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
;
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()) {
93 if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW
)) {
94 $studentrole = array_shift($studentroles); /// Take the first one
98 if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW
)) {
99 $userrole = array_shift($userroles); /// Take the first one
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
);
108 set_config('creatornewroleid', 0);
111 // we must not use assignable roles here:
112 // 1/ unsetting roles as assignable for admin might bork the settings!
113 // 2/ default user role should not be assignable anyway
115 if ($roles = get_all_roles()) {
116 foreach ($roles as $role) {
117 $allroles[$role->id
] = strip_tags(format_string($role->name
, true));
121 $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
122 get_string('confignotloggedinroleid', 'admin'), $guestrole->id
, $allroles ));
123 $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
124 get_string('configguestroleid', 'admin'), $guestrole->id
, $allroles));
125 $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
126 get_string('configdefaultuserroleid', 'admin'), $userrole->id
, $allroles));
129 $temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
131 if (!empty($CFG->rolesactive
)) {
132 $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
133 get_string('configdefaultcourseroleid', 'admin'), $studentrole->id
, $allroles));
134 $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
135 get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid
, $allroles));
138 $temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
140 if (!empty($CFG->rolesactive
)) {
141 $temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
142 get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
145 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
146 get_string('confighiddenuserfields', 'admin'), array(),
147 array('description' => get_string('description'),
148 'city' => get_string('city'),
149 'country' => get_string('country'),
150 'webpage' => get_string('webpage'),
151 'icqnumber' => get_string('icqnumber'),
152 'skypeid' => get_string('skypeid'),
153 'yahooid' => get_string('yahooid'),
154 'aimid' => get_string('aimid'),
155 'msnid' => get_string('msnid'),
156 'lastaccess' => get_string('lastaccess'))));
159 $ADMIN->add('roles', $temp);