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.
   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   * Flatfile enrolments plugin settings and presets.
  19   *
  20   * @package    enrol_flatfile
  21   * @copyright  2010 Eugene Venter
  22   * @author     Eugene Venter - based on code by Petr Skoda and others
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  require_once (__DIR__.'/adminlib.php');
  29  
  30  if ($ADMIN->fulltree) {
  31  
  32      //--- general settings -----------------------------------------------------------------------------------
  33      $settings->add(new admin_setting_heading('enrol_flatfile_settings', '', get_string('pluginname_desc', 'enrol_flatfile')));
  34  
  35      $settings->add(new admin_setting_configfile('enrol_flatfile/location', get_string('location', 'enrol_flatfile'), get_string('location_desc', 'enrol_flatfile'), ''));
  36  
  37      $options = core_text::get_encodings();
  38      $settings->add(new admin_setting_configselect('enrol_flatfile/encoding', get_string('encoding', 'enrol_flatfile'), '', 'UTF-8', $options));
  39  
  40      $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailstudents', get_string('notifyenrolled', 'enrol_flatfile'), '', 0));
  41  
  42      $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailteachers', get_string('notifyenroller', 'enrol_flatfile'), '', 0));
  43  
  44      $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailadmins', get_string('notifyadmin', 'enrol_flatfile'), '', 0));
  45  
  46      $options = array(ENROL_EXT_REMOVED_UNENROL        => get_string('extremovedunenrol', 'enrol'),
  47                       ENROL_EXT_REMOVED_KEEP           => get_string('extremovedkeep', 'enrol'),
  48                       ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'));
  49      $settings->add(new admin_setting_configselect('enrol_flatfile/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options));
  50  
  51      // Note: let's reuse the ext sync constants and strings here, internally it is very similar,
  52      //       it describes what should happen when users are not supposed to be enrolled any more.
  53      $options = array(
  54          ENROL_EXT_REMOVED_KEEP           => get_string('extremovedkeep', 'enrol'),
  55          ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'),
  56          ENROL_EXT_REMOVED_UNENROL        => get_string('extremovedunenrol', 'enrol'),
  57      );
  58      $settings->add(new admin_setting_configselect('enrol_flatfile/expiredaction', get_string('expiredaction', 'enrol_flatfile'), get_string('expiredaction_help', 'enrol_flatfile'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options));
  59  
  60      //--- mapping -------------------------------------------------------------------------------------------
  61      if (!during_initial_install()) {
  62          $settings->add(new admin_setting_heading('enrol_flatfile_mapping', get_string('mapping', 'enrol_flatfile'), ''));
  63  
  64          $roles = role_fix_names(get_all_roles());
  65  
  66          foreach ($roles as $role) {
  67              $settings->add(new enrol_flatfile_role_setting($role));
  68          }
  69          unset($roles);
  70      }
  71  }