MDL-26140 hide unfinished experimental DTL pages
[moodle.git] / admin / settings / users.php
1 <?php
3 // This file defines settingpages and externalpages under the "users" category
5 $ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
6 $ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
8 if ($hassiteconfig
9  or has_capability('moodle/site:uploadusers', $systemcontext)
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
19     if (empty($CFG->loginhttps)) {
20         $securewwwroot = $CFG->wwwroot;
21     } else {
22         $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
23     }
24     // stuff under the "accounts" subcategory
25     $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
26     $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')));
27     $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
28     $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers', 'admin'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers'));
29     $ADMIN->add('accounts', new admin_externalpage('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.php", 'moodle/site:uploadusers'));
30     $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
31     $ADMIN->add('accounts', new admin_externalpage('cohorts', get_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
34     // stuff under the "roles" subcategory
36     // "userpolicies" settingpage
37     $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
38     if ($ADMIN->fulltree) {
39         if (!during_initial_install()) {
40             $context = get_context_instance(CONTEXT_SYSTEM);
41             $allroles        = array();
42             $generalroles    = array();
43             $guestroles      = array();
44             $userroles       = array();
45             $studentroles    = array();
46             $teacherroles    = array();
47             $creatornewroles = array();
49             foreach (get_all_roles() as $role) {
50                 $rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
51                 $allroles[$role->id] = $rolename;
52                 switch ($role->archetype) {
53                     case 'manager':
54                         $creatornewroles[$role->id] = $rolename;
55                         break;
56                     case 'coursecreator':
57                         break;
58                     case 'editingteacher':
59                         $teacherroles[$role->id] = $rolename;
60                         $creatornewroles[$role->id] = $rolename;
61                         break;
62                     case 'teacher':
63                         $creatornewroles[$role->id] = $rolename;
64                         break;
65                     case 'student':
66                         $studentroles[$role->id] = $rolename;
67                         break;
68                     case 'guest':
69                         $guestroles[$role->id] = $rolename;
70                         break;
71                     case 'user':
72                         $userroles[$role->id] = $rolename;
73                         break;
74                     case 'frontpage':
75                         break;
76                     default:
77                         $creatornewroles[$role->id] = $rolename;
78                         $generalroles[$role->id] = $rolename;
79                         break;
80                 }
81             }
83             reset($guestroles);
84             $defaultguestid = key($guestroles);
85             reset($studentroles);
86             $defaultstudentid = key($studentroles);
87             reset($teacherroles);
88             $defaultteacherid = key($teacherroles);
90             if ($userroles) {
91                 reset($userroles);
92                 $defaultuserid = key($userroles);
93             } else {
94                 $userroles = array('0'=>get_string('none'));
95                 $defaultuserid = 0;
96             }
98             $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
99                           get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
100             $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
101                           get_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
102             $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
103                           get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $generalroles)));
104         }
106         $temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
108         if (!during_initial_install()) {
109             $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
110                           get_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
111         }
113         $temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
115         $temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
116                    get_string('confighiddenuserfields', 'admin'), array(),
117                        array('description' => get_string('description'),
118                              'city' => get_string('city'),
119                              'country' => get_string('country'),
120                              'webpage' => get_string('webpage'),
121                              'icqnumber' => get_string('icqnumber'),
122                              'skypeid' => get_string('skypeid'),
123                              'yahooid' => get_string('yahooid'),
124                              'aimid' => get_string('aimid'),
125                              'msnid' => get_string('msnid'),
126                              'firstaccess' => get_string('firstaccess'),
127                              'lastaccess' => get_string('lastaccess'),
128                              'mycourses' => get_string('mycourses'),
129                              'groups' => get_string('groups'))));
131         $temp->add(new admin_setting_configmulticheckbox('extrauserselectorfields',
132                 get_string('extrauserselectorfields', 'admin'), get_string('configextrauserselectorfields', 'admin'), array('email' => '1'),
133                 array('email' => get_string('email'), 'idnumber' => get_string('idnumber'), 'username' => get_string('username'), )));
134     }
136     $ADMIN->add('roles', $temp);
138     if (is_siteadmin()) {
139         $ADMIN->add('roles', new admin_externalpage('admins', get_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
140     }
141     $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
142     $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
143     $ADMIN->add('roles', new admin_externalpage('checkpermissions', get_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')));
145 } // end of speedup