MDL-35669 gravatar Provide default image URL to Gravatar
[moodle.git] / admin / settings / users.php
CommitLineData
11b749ca 1<?php
50999a0b 2
3// This file defines settingpages and externalpages under the "users" category
4
e106013f
SH
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')));
d86f4473 7
fc4069d6 8if ($hassiteconfig
fc4069d6 9 or has_capability('moodle/user:create', $systemcontext)
10 or has_capability('moodle/user:update', $systemcontext)
61d04bcc 11 or has_capability('moodle/user:delete', $systemcontext)
12 or has_capability('moodle/role:manage', $systemcontext)
864e2805
PS
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
7d0c81b3 16
50999a0b 17
1caea91e 18 if (empty($CFG->loginhttps)) {
220a90c5 19 $securewwwroot = $CFG->wwwroot;
20 } else {
21 $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
22 }
23 // stuff under the "accounts" subcategory
e106013f
SH
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')));
220a90c5 29
30
31 // stuff under the "roles" subcategory
220a90c5 32
33 // "userpolicies" settingpage
e106013f 34 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
220a90c5 35 if ($ADMIN->fulltree) {
31a99877 36 if (!during_initial_install()) {
bf006d2c 37 $context = context_system::instance();
82053cb1
PS
38
39 $otherroles = array();
4f0c2d00
PS
40 $guestroles = array();
41 $userroles = array();
4f0c2d00 42 $creatornewroles = array();
df997f84 43
82053cb1
PS
44 $defaultteacherid = null;
45 $defaultuserid = null;
46 $defaultguestid = null;
47
c52551dc
PS
48 $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
49 foreach ($roles as $role) {
50 $rolename = $role->localname;
4f0c2d00
PS
51 switch ($role->archetype) {
52 case 'manager':
53 $creatornewroles[$role->id] = $rolename;
54 break;
55 case 'coursecreator':
56 break;
57 case 'editingteacher':
82053cb1 58 $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
4f0c2d00
PS
59 $creatornewroles[$role->id] = $rolename;
60 break;
61 case 'teacher':
62 $creatornewroles[$role->id] = $rolename;
63 break;
64 case 'student':
4f0c2d00
PS
65 break;
66 case 'guest':
82053cb1 67 $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
4f0c2d00
PS
68 $guestroles[$role->id] = $rolename;
69 break;
70 case 'user':
82053cb1 71 $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
4f0c2d00
PS
72 $userroles[$role->id] = $rolename;
73 break;
74 case 'frontpage':
75 break;
76 default:
77 $creatornewroles[$role->id] = $rolename;
82053cb1 78 $otherroles[$role->id] = $rolename;
4f0c2d00 79 break;
220a90c5 80 }
81 }
11b749ca 82
82053cb1 83 if (empty($guestroles)) {
e106013f 84 $guestroles[0] = new lang_string('none');
82053cb1
PS
85 $defaultguestid = 0;
86 }
87
88 if (empty($userroles)) {
e106013f 89 $userroles[0] = new lang_string('none');
4f0c2d00 90 $defaultuserid = 0;
220a90c5 91 }
92
73d000f3 93 $restorersnewrole = $creatornewroles;
e106013f
SH
94 $restorersnewrole[0] = new lang_string('none');
95
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));
82053cb1
PS
106
107 // release memory
108 unset($otherroles);
109 unset($guestroles);
110 unset($userroles);
111 unset($creatornewroles);
73d000f3 112 unset($restorersnewrole);
220a90c5 113 }
69833712 114
e106013f
SH
115 $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0));
116
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'),
44d5c138
SH
131 'groups' => new lang_string('groups'),
132 'suspended' => new lang_string('suspended', 'auth'),
4ad72c28 133 )));
99cd2f77 134
5c60a847 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',
e106013f
SH
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'),
5c60a847 152 )));
e106013f 153 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
f127b1a5 154 $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
c785d40a 155 }
4766a50c 156
220a90c5 157 $ADMIN->add('roles', $temp);
8f8ed475 158
4f0c2d00 159 if (is_siteadmin()) {
e106013f 160 $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
4f0c2d00 161 }
e106013f
SH
162 $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
163 $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'));
164 $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')));
8a8272b0 165
a559f630 166} // end of speedup