MDL-35578 - Also justify email2, used in signup
[moodle.git] / admin / settings / users.php
blobb7f1e2579470c4b906d32b3e80f077032bfa7596
1 <?php
3 // This file defines settingpages and externalpages under the "users" category
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')));
8 if ($hassiteconfig
9 or has_capability('moodle/user:create', $systemcontext)
10 or has_capability('moodle/user:update', $systemcontext)
11 or has_capability('moodle/user:delete', $systemcontext)
12 or has_capability('moodle/role:manage', $systemcontext)
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
18 if (empty($CFG->loginhttps)) {
19 $securewwwroot = $CFG->wwwroot;
20 } else {
21 $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
23 // stuff under the "accounts" subcategory
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'));
27 $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
28 $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
31 // stuff under the "roles" subcategory
33 // "userpolicies" settingpage
34 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
35 if ($ADMIN->fulltree) {
36 if (!during_initial_install()) {
37 $context = context_system::instance();
39 $otherroles = array();
40 $guestroles = array();
41 $userroles = array();
42 $creatornewroles = array();
44 $defaultteacherid = null;
45 $defaultuserid = null;
46 $defaultguestid = null;
48 $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
49 foreach ($roles as $role) {
50 $rolename = $role->localname;
51 switch ($role->archetype) {
52 case 'manager':
53 $creatornewroles[$role->id] = $rolename;
54 break;
55 case 'coursecreator':
56 break;
57 case 'editingteacher':
58 $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
59 $creatornewroles[$role->id] = $rolename;
60 break;
61 case 'teacher':
62 $creatornewroles[$role->id] = $rolename;
63 break;
64 case 'student':
65 break;
66 case 'guest':
67 $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
68 $guestroles[$role->id] = $rolename;
69 break;
70 case 'user':
71 $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
72 $userroles[$role->id] = $rolename;
73 break;
74 case 'frontpage':
75 break;
76 default:
77 $creatornewroles[$role->id] = $rolename;
78 $otherroles[$role->id] = $rolename;
79 break;
83 if (empty($guestroles)) {
84 $guestroles[0] = new lang_string('none');
85 $defaultguestid = 0;
88 if (empty($userroles)) {
89 $userroles[0] = new lang_string('none');
90 $defaultuserid = 0;
93 $restorersnewrole = $creatornewroles;
94 $restorersnewrole[0] = new lang_string('none');
96 $temp->add(new admin_setting_configselect('notloggedinroleid', new lang_string('notloggedinroleid', 'admin'),
97 new lang_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
98 $temp->add(new admin_setting_configselect('guestroleid', new lang_string('guestroleid', 'admin'),
99 new lang_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
100 $temp->add(new admin_setting_configselect('defaultuserroleid', new lang_string('defaultuserroleid', 'admin'),
101 new lang_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
102 $temp->add(new admin_setting_configselect('creatornewroleid', new lang_string('creatornewroleid', 'admin'),
103 new lang_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
104 $temp->add(new admin_setting_configselect('restorernewroleid', new lang_string('restorernewroleid', 'admin'),
105 new lang_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole));
107 // release memory
108 unset($otherroles);
109 unset($guestroles);
110 unset($userroles);
111 unset($creatornewroles);
112 unset($restorersnewrole);
115 $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0));
117 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'),
118 new lang_string('confighiddenuserfields', 'admin'), array(),
119 array('description' => new lang_string('description'),
120 'city' => new lang_string('city'),
121 'country' => new lang_string('country'),
122 'webpage' => new lang_string('webpage'),
123 'icqnumber' => new lang_string('icqnumber'),
124 'skypeid' => new lang_string('skypeid'),
125 'yahooid' => new lang_string('yahooid'),
126 'aimid' => new lang_string('aimid'),
127 'msnid' => new lang_string('msnid'),
128 'firstaccess' => new lang_string('firstaccess'),
129 'lastaccess' => new lang_string('lastaccess'),
130 'mycourses' => new lang_string('mycourses'),
131 'groups' => new lang_string('groups'),
132 'suspended' => new lang_string('suspended', 'auth'),
133 )));
135 // Select fields to display as part of user identity (only to those
136 // with moodle/site:viewuseridentity).
137 // Options include fields from the user table that might be helpful to
138 // distinguish when adding or listing users ('I want to add the John
139 // Smith from Science faculty').
140 // Username is not included as an option because in some sites, it might
141 // be a security problem to reveal usernames even to trusted staff.
142 // Custom user profile fields are not currently supported.
143 $temp->add(new admin_setting_configmulticheckbox('showuseridentity',
144 new lang_string('showuseridentity', 'admin'),
145 new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
146 'idnumber' => new lang_string('idnumber'),
147 'email' => new lang_string('email'),
148 'phone1' => new lang_string('phone'),
149 'phone2' => new lang_string('phone2'),
150 'department' => new lang_string('department'),
151 'institution' => new lang_string('institution'),
152 )));
153 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
156 $ADMIN->add('roles', $temp);
158 if (is_siteadmin()) {
159 $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
161 $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
162 $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'));
163 $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')));
165 } // end of speedup