Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]
1 <?php 2 3 // This file defines settingpages and externalpages under the "users" category. 4 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'))); 7 $ADMIN->add('users', new admin_category('privacy', new lang_string('privacyandpolicies', 'admin'))); 8 9 if ($hassiteconfig 10 or has_capability('moodle/user:create', $systemcontext) 11 or has_capability('moodle/user:update', $systemcontext) 12 or has_capability('moodle/user:delete', $systemcontext) 13 or has_capability('moodle/role:manage', $systemcontext) 14 or has_capability('moodle/role:assign', $systemcontext) 15 or has_capability('moodle/cohort:manage', $systemcontext) 16 or has_capability('moodle/cohort:view', $systemcontext)) { // Speedup for non-admins, add all caps used on this page. 17 18 19 // Stuff under the "accounts" subcategory. 20 $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'))); 21 $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'))); 22 $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$CFG->wwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); 23 24 // User management settingpage. 25 $temp = new admin_settingpage('usermanagement', new lang_string('usermanagement', 'admin')); 26 if ($ADMIN->fulltree) { 27 $choices = array(); 28 $choices['realname'] = new lang_string('fullnameuser'); 29 $choices['lastname'] = new lang_string('lastname'); 30 $choices['firstname'] = new lang_string('firstname'); 31 $choices['username'] = new lang_string('username'); 32 $choices['email'] = new lang_string('email'); 33 $choices['city'] = new lang_string('city'); 34 $choices['country'] = new lang_string('country'); 35 $choices['confirmed'] = new lang_string('confirmed', 'admin'); 36 $choices['suspended'] = new lang_string('suspended', 'auth'); 37 $choices['profile'] = new lang_string('profilefields', 'admin'); 38 $choices['courserole'] = new lang_string('courserole', 'filters'); 39 $choices['anycourses'] = new lang_string('anycourses', 'filters'); 40 $choices['systemrole'] = new lang_string('globalrole', 'role'); 41 $choices['cohort'] = new lang_string('idnumber', 'core_cohort'); 42 $choices['firstaccess'] = new lang_string('firstaccess', 'filters'); 43 $choices['lastaccess'] = new lang_string('lastaccess'); 44 $choices['neveraccessed'] = new lang_string('neveraccessed', 'filters'); 45 $choices['timecreated'] = new lang_string('timecreated'); 46 $choices['timemodified'] = new lang_string('lastmodified'); 47 $choices['nevermodified'] = new lang_string('nevermodified', 'filters'); 48 $choices['auth'] = new lang_string('authentication'); 49 $choices['idnumber'] = new lang_string('idnumber'); 50 $choices['lastip'] = new lang_string('lastip'); 51 $choices['mnethostid'] = new lang_string('mnetidprovider', 'mnet'); 52 $temp->add(new admin_setting_configmultiselect('userfiltersdefault', new lang_string('userfiltersdefault', 'admin'), 53 new lang_string('userfiltersdefault_desc', 'admin'), array('realname'), $choices)); 54 } 55 $ADMIN->add('accounts', $temp); 56 57 // User default preferences settingpage. 58 $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin')); 59 if ($ADMIN->fulltree) { 60 $choices = array(); 61 $choices['0'] = new lang_string('emaildisplayno'); 62 $choices['1'] = new lang_string('emaildisplayyes'); 63 $choices['2'] = new lang_string('emaildisplaycourse'); 64 $temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'), 65 new lang_string('emaildisplay_help'), 2, $choices)); 66 67 $choices = array(); 68 $choices['0'] = new lang_string('textformat'); 69 $choices['1'] = new lang_string('htmlformat'); 70 $temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices)); 71 72 $choices = array(); 73 $choices['0'] = new lang_string('emaildigestoff'); 74 $choices['1'] = new lang_string('emaildigestcomplete'); 75 $choices['2'] = new lang_string('emaildigestsubjects'); 76 $temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'), 77 new lang_string('emaildigest_help'), 0, $choices)); 78 79 80 $choices = array(); 81 $choices['1'] = new lang_string('autosubscribeyes'); 82 $choices['0'] = new lang_string('autosubscribeno'); 83 $temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'), 84 '', 1, $choices)); 85 86 $choices = array(); 87 $choices['0'] = new lang_string('trackforumsno'); 88 $choices['1'] = new lang_string('trackforumsyes'); 89 $temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'), 90 '', 0, $choices)); 91 92 $choices = []; 93 $choices[\core_contentbank\content::VISIBILITY_PUBLIC] = new lang_string('visibilitychoicepublic', 'core_contentbank'); 94 $choices[\core_contentbank\content::VISIBILITY_UNLISTED] = new lang_string('visibilitychoiceunlisted', 'core_contentbank'); 95 $temp->add(new admin_setting_configselect('defaultpreference_core_contentbank_visibility', 96 new lang_string('visibilitypref', 'core_contentbank'), 97 new lang_string('visibilitypref_help', 'core_contentbank'), 98 \core_contentbank\content::VISIBILITY_PUBLIC, $choices)); 99 } 100 $ADMIN->add('accounts', $temp); 101 102 $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); 103 $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view'))); 104 $ADMIN->add( 105 'accounts', 106 new admin_externalpage( 107 'cohort_customfield', 108 new lang_string('cohort_customfield', 'admin'), 109 $CFG->wwwroot . '/cohort/customfield.php', 110 ['moodle/cohort:configurecustomfields'] 111 ) 112 ); 113 114 // Stuff under the "roles" subcategory. 115 116 // User policies settingpage. 117 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin')); 118 if ($ADMIN->fulltree) { 119 if (!during_initial_install()) { 120 $context = context_system::instance(); 121 122 $otherroles = array(); 123 $guestroles = array(); 124 $userroles = array(); 125 $creatornewroles = array(); 126 127 $defaultteacherid = null; 128 $defaultuserid = null; 129 $defaultguestid = null; 130 131 $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT); 132 foreach ($roles as $role) { 133 $rolename = $role->localname; 134 switch ($role->archetype) { 135 case 'manager': 136 $creatornewroles[$role->id] = $rolename; 137 break; 138 case 'coursecreator': 139 break; 140 case 'editingteacher': 141 $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id; 142 $creatornewroles[$role->id] = $rolename; 143 break; 144 case 'teacher': 145 $creatornewroles[$role->id] = $rolename; 146 break; 147 case 'student': 148 break; 149 case 'guest': 150 $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id; 151 $guestroles[$role->id] = $rolename; 152 break; 153 case 'user': 154 $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id; 155 $userroles[$role->id] = $rolename; 156 break; 157 case 'frontpage': 158 break; 159 default: 160 $creatornewroles[$role->id] = $rolename; 161 $otherroles[$role->id] = $rolename; 162 break; 163 } 164 } 165 166 if (empty($guestroles)) { 167 $guestroles[0] = new lang_string('none'); 168 $defaultguestid = 0; 169 } 170 171 if (empty($userroles)) { 172 $userroles[0] = new lang_string('none'); 173 $defaultuserid = 0; 174 } 175 176 $restorersnewrole = $creatornewroles; 177 $restorersnewrole[0] = new lang_string('none'); 178 179 $temp->add(new admin_setting_configselect('notloggedinroleid', new lang_string('notloggedinroleid', 'admin'), 180 new lang_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles))); 181 $temp->add(new admin_setting_configselect('guestroleid', new lang_string('guestroleid', 'admin'), 182 new lang_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles))); 183 $temp->add(new admin_setting_configselect('defaultuserroleid', new lang_string('defaultuserroleid', 'admin'), 184 new lang_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles))); 185 $temp->add(new admin_setting_configselect('creatornewroleid', new lang_string('creatornewroleid', 'admin'), 186 new lang_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles)); 187 $temp->add(new admin_setting_configselect('restorernewroleid', new lang_string('restorernewroleid', 'admin'), 188 new lang_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole)); 189 190 // Release memory. 191 unset($otherroles); 192 unset($guestroles); 193 unset($userroles); 194 unset($creatornewroles); 195 unset($restorersnewrole); 196 } 197 198 $temp->add(new admin_setting_configcheckbox('enroladminnewcourse', new lang_string('enroladminnewcourse', 'admin'), 199 new lang_string('enroladminnewcourse_help', 'admin'), 1)); 200 201 $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0)); 202 203 $temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'), 204 new lang_string('confighiddenuserfields', 'admin'), array(), 205 array('description' => new lang_string('description'), 206 'email' => new lang_string('email'), 207 'city' => new lang_string('city'), 208 'country' => new lang_string('country'), 209 'moodlenetprofile' => new lang_string('moodlenetprofile', 'user'), 210 'timezone' => new lang_string('timezone'), 211 'firstaccess' => new lang_string('firstaccess'), 212 'lastaccess' => new lang_string('lastaccess'), 213 'lastip' => new lang_string('lastip'), 214 'mycourses' => new lang_string('mycourses'), 215 'groups' => new lang_string('groups'), 216 'suspended' => new lang_string('suspended', 'auth'), 217 ))); 218 219 // Select fields to display as part of user identity (only to those 220 // with moodle/site:viewuseridentity). 221 // Options include fields from the user table that might be helpful to 222 // distinguish when adding or listing users ('I want to add the John 223 // Smith from Science faculty') and any custom profile fields. 224 $temp->add(new admin_setting_configmulticheckbox('showuseridentity', 225 new lang_string('showuseridentity', 'admin'), 226 new lang_string('showuseridentity_desc', 'admin'), ['email' => 1], 227 function() { 228 global $CFG; 229 require_once($CFG->dirroot.'/user/profile/lib.php'); 230 231 // Basic fields available in user table. 232 $fields = [ 233 'username' => new lang_string('username'), 234 'idnumber' => new lang_string('idnumber'), 235 'email' => new lang_string('email'), 236 'phone1' => new lang_string('phone1'), 237 'phone2' => new lang_string('phone2'), 238 'department' => new lang_string('department'), 239 'institution' => new lang_string('institution'), 240 'city' => new lang_string('city'), 241 'country' => new lang_string('country'), 242 ]; 243 244 // Custom profile fields. 245 $profilefields = profile_get_custom_fields(); 246 foreach ($profilefields as $field) { 247 // Only reasonable-length text fields can be used as identity fields. 248 if ($field->param2 > 255 || $field->datatype != 'text') { 249 continue; 250 } 251 $fields['profile_field_' . $field->shortname] = format_string($field->name, true, 252 ['context' => context_system::instance()]) . ' *'; 253 } 254 255 return $fields; 256 })); 257 $setting = new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), 258 new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50); 259 $setting->set_force_ltr(true); 260 $temp->add($setting); 261 $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'), 262 new lang_string('alternativefullnameformat_desc', 'admin'), 263 'language', PARAM_RAW, 50)); 264 $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT)); 265 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0)); 266 $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm')); 267 } 268 269 $ADMIN->add('roles', $temp); 270 271 if (is_siteadmin()) { 272 $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php")); 273 } 274 $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage')); 275 $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')); 276 $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'))); 277 278 } // End of speedup. 279 280 // Privacy settings. 281 if ($hassiteconfig) { 282 $temp = new admin_settingpage('privacysettings', new lang_string('privacysettings', 'admin')); 283 284 $options = array( 285 0 => get_string('no'), 286 1 => get_string('yes') 287 ); 288 $url = new moodle_url('/admin/settings.php?section=supportcontact'); 289 $url = $url->out(); 290 $setting = new admin_setting_configselect('agedigitalconsentverification', 291 new lang_string('agedigitalconsentverification', 'admin'), 292 new lang_string('agedigitalconsentverification_desc', 'admin', $url), 0, $options); 293 $setting->set_force_ltr(true); 294 $temp->add($setting); 295 296 // See {@link https://gdpr-info.eu/art-8-gdpr/}. 297 // See {@link https://www.betterinternetforkids.eu/web/portal/practice/awareness/detail?articleId=3017751}. 298 $ageofdigitalconsentmap = implode(PHP_EOL, [ 299 '*, 16', 300 'AT, 14', 301 'BE, 13', 302 'BG, 14', 303 'CY, 14', 304 'CZ, 15', 305 'DK, 13', 306 'EE, 13', 307 'ES, 14', 308 'FI, 13', 309 'FR, 15', 310 'GB, 13', 311 'GR, 15', 312 'IT, 14', 313 'LT, 14', 314 'LV, 13', 315 'MT, 13', 316 'NO, 13', 317 'PT, 13', 318 'SE, 13', 319 'US, 13' 320 ]); 321 $setting = new admin_setting_agedigitalconsentmap('agedigitalconsentmap', 322 new lang_string('ageofdigitalconsentmap', 'admin'), 323 new lang_string('ageofdigitalconsentmap_desc', 'admin'), 324 $ageofdigitalconsentmap, 325 PARAM_RAW 326 ); 327 $temp->add($setting); 328 329 $ADMIN->add('privacy', $temp); 330 331 // Policy settings. 332 $temp = new admin_settingpage('policysettings', new lang_string('policysettings', 'admin')); 333 $temp->add(new admin_settings_sitepolicy_handler_select('sitepolicyhandler', new lang_string('sitepolicyhandler', 'core_admin'), 334 new lang_string('sitepolicyhandler_desc', 'core_admin'))); 335 $temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'core_admin'), 336 new lang_string('sitepolicy_help', 'core_admin'), '', PARAM_RAW)); 337 $temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'core_admin'), 338 new lang_string('sitepolicyguest_help', 'core_admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW)); 339 340 $ADMIN->add('privacy', $temp); 341 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body