Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   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      if (!during_initial_install()) {
 115          $imscourses = new imsenterprise_courses();
 116          foreach ($imscourses->get_courseattrs() as $courseattr) {
 117  
 118              // The assignable values of this course attribute.
 119              $assignablevalues = $imscourses->get_imsnames($courseattr);
 120              $name = get_string('setting' . $courseattr, 'enrol_imsenterprise');
 121              $description = get_string('setting' . $courseattr . 'description', 'enrol_imsenterprise');
 122              $defaultvalue = (string) $imscourses->determine_default_coursemapping($courseattr);
 123              $settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name,
 124                  $description, $defaultvalue, $assignablevalues));
 125          }
 126      }
 127  
 128      // Miscellaneous.
 129      $settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings',
 130          get_string('miscsettings', 'enrol_imsenterprise'), ''));
 131  
 132      $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget',
 133          get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
 134  
 135      $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix',
 136          get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
 137  
 138      $importurl = new moodle_url('/enrol/imsenterprise/importnow.php', array('sesskey' => sesskey()));
 139      $importnowstring = get_string('aftersaving...', 'enrol_imsenterprise').' ';
 140      $importnowstring .= html_writer::link($importurl, get_string('doitnow', 'enrol_imsenterprise'));
 141      $settings->add(new admin_setting_heading('enrol_imsenterprise_doitnowmessage', '', $importnowstring));
 142  }