[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/settings/ -> users.php (source)

   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  
   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
  16  
  17  
  18      if (empty($CFG->loginhttps)) {
  19          $securewwwroot = $CFG->wwwroot;
  20      } else {
  21          $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
  22      }
  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  
  28      // "User default preferences" settingpage.
  29      $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin'));
  30      if ($ADMIN->fulltree) {
  31          $choices = array();
  32          $choices['0'] = new lang_string('emaildisplayno');
  33          $choices['1'] = new lang_string('emaildisplayyes');
  34          $choices['2'] = new lang_string('emaildisplaycourse');
  35          $temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
  36              '', 2, $choices));
  37  
  38          $choices = array();
  39          $choices['0'] = new lang_string('textformat');
  40          $choices['1'] = new lang_string('htmlformat');
  41          $temp->add(new admin_setting_configselect('defaultpreference_mailformat', new lang_string('emailformat'), '', 1, $choices));
  42  
  43          $choices = array();
  44          $choices['0'] = new lang_string('emaildigestoff');
  45          $choices['1'] = new lang_string('emaildigestcomplete');
  46          $choices['2'] = new lang_string('emaildigestsubjects');
  47          $temp->add(new admin_setting_configselect('defaultpreference_maildigest', new lang_string('emaildigest'),
  48              new lang_string('emaildigest_help'), 0, $choices));
  49  
  50  
  51          $choices = array();
  52          $choices['1'] = new lang_string('autosubscribeyes');
  53          $choices['0'] = new lang_string('autosubscribeno');
  54          $temp->add(new admin_setting_configselect('defaultpreference_autosubscribe', new lang_string('autosubscribe'),
  55              '', 1, $choices));
  56  
  57          $choices = array();
  58          $choices['0'] = new lang_string('trackforumsno');
  59          $choices['1'] = new lang_string('trackforumsyes');
  60          $temp->add(new admin_setting_configselect('defaultpreference_trackforums', new lang_string('trackforums'),
  61              '', 0, $choices));
  62      }
  63      $ADMIN->add('accounts', $temp);
  64  
  65      $ADMIN->add('accounts', new admin_externalpage('profilefields', new lang_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
  66      $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
  67  
  68  
  69      // stuff under the "roles" subcategory
  70  
  71      // "userpolicies" settingpage
  72      $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
  73      if ($ADMIN->fulltree) {
  74          if (!during_initial_install()) {
  75              $context = context_system::instance();
  76  
  77              $otherroles      = array();
  78              $guestroles      = array();
  79              $userroles       = array();
  80              $creatornewroles = array();
  81  
  82              $defaultteacherid = null;
  83              $defaultuserid    = null;
  84              $defaultguestid   = null;
  85  
  86              $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
  87              foreach ($roles as $role) {
  88                  $rolename = $role->localname;
  89                  switch ($role->archetype) {
  90                      case 'manager':
  91                          $creatornewroles[$role->id] = $rolename;
  92                          break;
  93                      case 'coursecreator':
  94                          break;
  95                      case 'editingteacher':
  96                          $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
  97                          $creatornewroles[$role->id] = $rolename;
  98                          break;
  99                      case 'teacher':
 100                          $creatornewroles[$role->id] = $rolename;
 101                          break;
 102                      case 'student':
 103                          break;
 104                      case 'guest':
 105                          $defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
 106                          $guestroles[$role->id] = $rolename;
 107                          break;
 108                      case 'user':
 109                          $defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
 110                          $userroles[$role->id] = $rolename;
 111                          break;
 112                      case 'frontpage':
 113                          break;
 114                      default:
 115                          $creatornewroles[$role->id] = $rolename;
 116                          $otherroles[$role->id] = $rolename;
 117                          break;
 118                  }
 119              }
 120  
 121              if (empty($guestroles)) {
 122                  $guestroles[0] = new lang_string('none');
 123                  $defaultguestid = 0;
 124              }
 125  
 126              if (empty($userroles)) {
 127                  $userroles[0] = new lang_string('none');
 128                  $defaultuserid = 0;
 129              }
 130  
 131              $restorersnewrole = $creatornewroles;
 132              $restorersnewrole[0] = new lang_string('none');
 133  
 134              $temp->add(new admin_setting_configselect('notloggedinroleid', new lang_string('notloggedinroleid', 'admin'),
 135                            new lang_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
 136              $temp->add(new admin_setting_configselect('guestroleid', new lang_string('guestroleid', 'admin'),
 137                            new lang_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
 138              $temp->add(new admin_setting_configselect('defaultuserroleid', new lang_string('defaultuserroleid', 'admin'),
 139                            new lang_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
 140              $temp->add(new admin_setting_configselect('creatornewroleid', new lang_string('creatornewroleid', 'admin'),
 141                            new lang_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
 142              $temp->add(new admin_setting_configselect('restorernewroleid', new lang_string('restorernewroleid', 'admin'),
 143                            new lang_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole));
 144  
 145              // release memory
 146              unset($otherroles);
 147              unset($guestroles);
 148              unset($userroles);
 149              unset($creatornewroles);
 150              unset($restorersnewrole);
 151          }
 152  
 153          $temp->add(new admin_setting_configcheckbox('autologinguests', new lang_string('autologinguests', 'admin'), new lang_string('configautologinguests', 'admin'), 0));
 154  
 155          $temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'),
 156                     new lang_string('confighiddenuserfields', 'admin'), array(),
 157                         array('description' => new lang_string('description'),
 158                               'city' => new lang_string('city'),
 159                               'country' => new lang_string('country'),
 160                               'timezone' => new lang_string('timezone'),
 161                               'webpage' => new lang_string('webpage'),
 162                               'icqnumber' => new lang_string('icqnumber'),
 163                               'skypeid' => new lang_string('skypeid'),
 164                               'yahooid' => new lang_string('yahooid'),
 165                               'aimid' => new lang_string('aimid'),
 166                               'msnid' => new lang_string('msnid'),
 167                               'firstaccess' => new lang_string('firstaccess'),
 168                               'lastaccess' => new lang_string('lastaccess'),
 169                               'lastip' => new lang_string('lastip'),
 170                               'mycourses' => new lang_string('mycourses'),
 171                               'groups' => new lang_string('groups'),
 172                               'suspended' => new lang_string('suspended', 'auth'),
 173                         )));
 174  
 175          // Select fields to display as part of user identity (only to those
 176          // with moodle/site:viewuseridentity).
 177          // Options include fields from the user table that might be helpful to
 178          // distinguish when adding or listing users ('I want to add the John
 179          // Smith from Science faculty').
 180          // Username is not included as an option because in some sites, it might
 181          // be a security problem to reveal usernames even to trusted staff.
 182          // Custom user profile fields are not currently supported.
 183          $temp->add(new admin_setting_configmulticheckbox('showuseridentity',
 184                  new lang_string('showuseridentity', 'admin'),
 185                  new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
 186                      'idnumber'    => new lang_string('idnumber'),
 187                      'email'       => new lang_string('email'),
 188                      'phone1'      => new lang_string('phone1'),
 189                      'phone2'      => new lang_string('phone2'),
 190                      'department'  => new lang_string('department'),
 191                      'institution' => new lang_string('institution'),
 192                  )));
 193          $temp->add(new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50));
 194          $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'),
 195                  new lang_string('alternativefullnameformat_desc', 'admin'),
 196                  'language', PARAM_RAW, 50));
 197          $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
 198          $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
 199          $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
 200      }
 201  
 202      $ADMIN->add('roles', $temp);
 203  
 204      if (is_siteadmin()) {
 205          $ADMIN->add('roles', new admin_externalpage('admins', new lang_string('siteadministrators', 'role'), "$CFG->wwwroot/$CFG->admin/roles/admins.php"));
 206      }
 207      $ADMIN->add('roles', new admin_externalpage('defineroles', new lang_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
 208      $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'));
 209      $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')));
 210  
 211  } // end of speedup


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1