Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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   * Admin settings and defaults.
  19   *
  20   * @package    auth_shibboleth
  21   * @copyright  2017 Stephen Bourget
  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      // We use a couple of custom admin settings since we need to massage the data before it is inserted into the DB.
  29      require_once($CFG->dirroot.'/auth/shibboleth/classes/admin_setting_special_wayf_select.php');
  30      require_once($CFG->dirroot.'/auth/shibboleth/classes/admin_setting_special_idp_configtextarea.php');
  31      require_once($CFG->dirroot.'/auth/shibboleth/classes/admin_setting_special_convert_data_configfile.php');
  32  
  33      // Introductory explanation.
  34      $readmeurl = (new moodle_url('/auth/shibboleth/README.txt'))->out();
  35      $settings->add(new admin_setting_heading('auth_shibboleth/pluginname', '',
  36              new lang_string('auth_shibbolethdescription', 'auth_shibboleth', $readmeurl)));
  37  
  38      // Username.
  39      $settings->add(new admin_setting_configtext('auth_shibboleth/user_attribute', get_string('username'),
  40              get_string('auth_shib_username_description', 'auth_shibboleth'), '', PARAM_RAW));
  41  
  42      // Convert Data configuration file.
  43      $settings->add(new auth_shibboleth_admin_setting_convert_data('auth_shibboleth/convert_data',
  44              get_string('auth_shib_convert_data', 'auth_shibboleth'),
  45              get_string('auth_shib_convert_data_description', 'auth_shibboleth', $readmeurl), ''));
  46  
  47      // WAYF.
  48      $settings->add(new auth_shibboleth_admin_setting_special_wayf_select());
  49  
  50      // Organization_selection.
  51      $settings->add(new auth_shibboleth_admin_setting_special_idp_configtextarea());
  52  
  53      // Logout handler.
  54      $settings->add(new admin_setting_configtext('auth_shibboleth/logout_handler',
  55              get_string('auth_shib_logout_url', 'auth_shibboleth'),
  56              get_string('auth_shib_logout_url_description', 'auth_shibboleth'), '', PARAM_URL));
  57  
  58      // Logout return URL.
  59      $settings->add(new admin_setting_configtext('auth_shibboleth/logout_return_url',
  60              get_string('auth_shib_logout_return_url', 'auth_shibboleth'),
  61              get_string('auth_shib_logout_return_url_description', 'auth_shibboleth'), '', PARAM_URL));
  62  
  63      // Authentication method name.
  64      $settings->add(new admin_setting_configtext('auth_shibboleth/login_name',
  65              get_string('auth_shib_auth_method', 'auth_shibboleth'),
  66              get_string('auth_shib_auth_method_description', 'auth_shibboleth'), 'Shibboleth Login', PARAM_RAW_TRIMMED));
  67  
  68      // Authentication method logo.
  69      $settings->add(new admin_setting_configstoredfile('auth_shibboleth/auth_logo',
  70                  get_string('auth_shib_auth_logo', 'auth_shibboleth'),
  71                  get_string('auth_shib_auth_logo_description', 'auth_shibboleth'), 'logo', 0, ['accepted_types' => ['image']]));
  72  
  73      // Login directions.
  74      $settings->add(new admin_setting_configtextarea('auth_shibboleth/auth_instructions',
  75              get_string('auth_shib_instructions_key', 'auth_shibboleth'),
  76              get_string('auth_shib_instructions_help', 'auth_shibboleth', $CFG->wwwroot.'/auth/shibboleth/index.php'),
  77              get_string('auth_shib_instructions', 'auth_shibboleth', $CFG->wwwroot.'/auth/shibboleth/index.php'), PARAM_RAW_TRIMMED));
  78  
  79      // Password change URL.
  80      $settings->add(new admin_setting_configtext('auth_shibboleth/changepasswordurl',
  81              get_string('auth_shib_changepasswordurl', 'auth_shibboleth'),
  82              get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
  83  
  84      // Display locking / mapping of profile fields.
  85      $authplugin = get_auth_plugin('shibboleth');
  86      display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
  87              '', true, false, $authplugin->get_custom_user_profile_fields());
  88  
  89  }