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  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Allows the admin to configure a list of profile fields that are sent/recieved
  20   *
  21   * @package    core
  22   * @subpackage mnet
  23   * @copyright  2010 onwards Penny Leach <penny@liip.ch>
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  if (!defined('MOODLE_INTERNAL')) {
  28      die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
  29  }
  30  
  31  require_once($CFG->libdir . '/formslib.php');
  32  
  33  /**
  34   * small form to allow the administrator to configure (override) which profile fields are sent/imported over mnet
  35   */
  36  class mnet_profile_form extends moodleform {
  37  
  38      function definition() {
  39          global $CFG;
  40          $mform =& $this->_form;
  41  
  42          $mnetprofileimportfields = '';
  43          if (isset($CFG->mnetprofileimportfields)) {
  44              $mnetprofileimportfields = str_replace(',', ', ', $CFG->mnetprofileimportfields);
  45          }
  46  
  47          $mnetprofileexportfields = '';
  48          if (isset($CFG->mnetprofileexportfields)) {
  49              $mnetprofileexportfields = str_replace(',', ', ', $CFG->mnetprofileexportfields);
  50          }
  51  
  52          $mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
  53          $mform->setType('hostid', PARAM_INT);
  54  
  55          $fields = mnet_profile_field_options();
  56  
  57          // Fields to import ----------------------------------------------------
  58          $mform->addElement('header', 'import', get_string('importfields', 'mnet'));
  59  
  60          $select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
  61          $select->setMultiple(true);
  62  
  63          $mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), $mnetprofileimportfields);
  64  
  65          // Fields to export ----------------------------------------------------
  66          $mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
  67  
  68          $select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
  69          $select->setMultiple(true);
  70  
  71          $mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), $mnetprofileexportfields);
  72  
  73          $this->add_action_buttons();
  74      }
  75  }