Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * IMS Enterprise enrolments plugin settings and presets.
  19   *
  20   * @package    enrol_imsenterprise
  21   * @copyright  2010 Eugene Venter
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  if ($ADMIN->fulltree) {
  28      require_once($CFG->dirroot.'/enrol/imsenterprise/locallib.php');
  29  
  30      $settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '',
  31          get_string('pluginname_desc', 'enrol_imsenterprise')));
  32  
  33      // General settings.
  34      $settings->add(new admin_setting_heading('enrol_imsenterprise_basicsettings',
  35          get_string('basicsettings', 'enrol_imsenterprise'), ''));
  36  
  37      $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsfilelocation',
  38          get_string('location', 'enrol_imsenterprise'), '', ''));
  39  
  40      $settings->add(new admin_setting_configtext('enrol_imsenterprise/logtolocation',
  41          get_string('logtolocation', 'enrol_imsenterprise'), '', ''));
  42  
  43      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/mailadmins',
  44          get_string('mailadmins', 'enrol_imsenterprise'), '', 0));
  45  
  46      // User data options.
  47      $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings',
  48          get_string('usersettings', 'enrol_imsenterprise'), ''));
  49  
  50      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewusers',
  51          get_string('createnewusers', 'enrol_imsenterprise'), get_string('createnewusers_desc', 'enrol_imsenterprise'), 0));
  52  
  53      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsupdateusers',
  54          get_string('updateusers', 'enrol_imsenterprise'), get_string('updateusers_desc', 'enrol_imsenterprise'), 0));
  55  
  56      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsdeleteusers',
  57          get_string('deleteusers', 'enrol_imsenterprise'), get_string('deleteusers_desc', 'enrol_imsenterprise'), 0));
  58  
  59      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcaseusernames',
  60          get_string('fixcaseusernames', 'enrol_imsenterprise'), '', 0));
  61  
  62      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcasepersonalnames',
  63          get_string('fixcasepersonalnames', 'enrol_imsenterprise'), '', 0));
  64  
  65      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imssourcedidfallback',
  66          get_string('sourcedidfallback', 'enrol_imsenterprise'), get_string('sourcedidfallback_desc', 'enrol_imsenterprise'), 0));
  67  
  68      $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings_roles',
  69          get_string('roles', 'enrol_imsenterprise'), get_string('imsrolesdescription', 'enrol_imsenterprise')));
  70  
  71      if (!during_initial_install()) {
  72          $coursecontext = context_course::instance(SITEID);
  73          $assignableroles = get_assignable_roles($coursecontext);
  74          $assignableroles = array('0' => get_string('ignore', 'enrol_imsenterprise')) + $assignableroles;
  75          $imsroles = new imsenterprise_roles();
  76          foreach ($imsroles->get_imsroles() as $imsrolenum => $imsrolename) {
  77              $settings->add(new admin_setting_configselect('enrol_imsenterprise/imsrolemap'.$imsrolenum,
  78                  format_string('"'.$imsrolename.'" ('.$imsrolenum.')'), '',
  79                  (int)$imsroles->determine_default_rolemapping($imsrolenum), $assignableroles));
  80          }
  81      }
  82  
  83      // Course data options.
  84      $settings->add(new admin_setting_heading('enrol_imsenterprise_coursesettings',
  85          get_string('coursesettings', 'enrol_imsenterprise'), ''));
  86  
  87      $settings->add(new admin_setting_configtext('enrol_imsenterprise/truncatecoursecodes',
  88          get_string('truncatecoursecodes', 'enrol_imsenterprise'), get_string('truncatecoursecodes_desc', 'enrol_imsenterprise'),
  89          0, PARAM_INT, 2));
  90  
  91      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcourses',
  92          get_string('createnewcourses', 'enrol_imsenterprise'), get_string('createnewcourses_desc', 'enrol_imsenterprise'), 0));
  93  
  94      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/updatecourses',
  95          get_string('updatecourses', 'enrol_imsenterprise'), get_string('updatecourses_desc', 'enrol_imsenterprise'), 0));
  96  
  97      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcategories',
  98          get_string('createnewcategories', 'enrol_imsenterprise'), get_string('createnewcategories_desc', 'enrol_imsenterprise'),
  99          0));
 100  
 101      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/nestedcategories',
 102          get_string('nestedcategories', 'enrol_imsenterprise'), get_string('nestedcategories_desc', 'enrol_imsenterprise'), 0));
 103  
 104      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/categoryidnumber',
 105          get_string('categoryidnumber', 'enrol_imsenterprise'), get_string('categoryidnumber_desc', 'enrol_imsenterprise'), 0));
 106  
 107      $settings->add(new admin_setting_configtext('enrol_imsenterprise/categoryseparator',
 108          get_string('categoryseparator', 'enrol_imsenterprise'), get_string('categoryseparator_desc', 'enrol_imsenterprise'), '',
 109          PARAM_TEXT, 3));
 110  
 111      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsunenrol',
 112          get_string('allowunenrol', 'enrol_imsenterprise'), get_string('allowunenrol_desc', 'enrol_imsenterprise'), 0));
 113  
 114      /* Action to take when a request to remove a user enrolment record is detected in the IMS file */
 115      $options = [
 116          ENROL_EXT_REMOVED_KEEP => get_string('noaction', 'enrol_imsenterprise'),
 117          ENROL_EXT_REMOVED_UNENROL => get_string('removeenrolmentandallroles', 'enrol_imsenterprise'),
 118          ENROL_EXT_REMOVED_SUSPEND => get_string('disableenrolonly', 'enrol_imsenterprise'),
 119          ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('disableenrolmentandremoveallroles', 'enrol_imsenterprise'),
 120      ];
 121  
 122      $settings->add(
 123          new admin_setting_configselect('enrol_imsenterprise/unenrolaction',
 124              get_string('unenrolaction', 'enrol_imsenterprise'),
 125              get_string('unenrolaction_desc', 'enrol_imsenterprise'),
 126              ENROL_EXT_REMOVED_UNENROL, $options)
 127      );
 128  
 129      if (!during_initial_install()) {
 130          $imscourses = new imsenterprise_courses();
 131          foreach ($imscourses->get_courseattrs() as $courseattr) {
 132  
 133              // The assignable values of this course attribute.
 134              $assignablevalues = $imscourses->get_imsnames($courseattr);
 135              $name = get_string('setting' . $courseattr, 'enrol_imsenterprise');
 136              $description = get_string('setting' . $courseattr . 'description', 'enrol_imsenterprise');
 137              $defaultvalue = (string) $imscourses->determine_default_coursemapping($courseattr);
 138              $settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name,
 139                  $description, $defaultvalue, $assignablevalues));
 140          }
 141      }
 142  
 143      // Miscellaneous.
 144      $settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings',
 145          get_string('miscsettings', 'enrol_imsenterprise'), ''));
 146  
 147      $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget',
 148          get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
 149  
 150      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix',
 151          get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
 152  
 153      $importurl = new moodle_url('/enrol/imsenterprise/importnow.php', array('sesskey' => sesskey()));
 154      $importnowstring = get_string('aftersaving...', 'enrol_imsenterprise').' ';
 155      $importnowstring .= html_writer::link($importurl, get_string('doitnow', 'enrol_imsenterprise'));
 156      $settings->add(new admin_setting_heading('enrol_imsenterprise_doitnowmessage', '', $importnowstring));
 157  }