Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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  require(__DIR__.'/../../config.php');
  28  require_once($CFG->libdir.'/adminlib.php');
  29  require_once($CFG->dirroot . '/' . $CFG->admin .'/mnet/profilefields_form.php');
  30  $mnet = get_mnet_environment();
  31  
  32  $hostid = required_param('hostid', PARAM_INT);
  33  $mnet_peer = new mnet_peer();
  34  $mnet_peer->set_id($hostid);
  35  
  36  admin_externalpage_setup('mnetpeers');
  37  $form = new mnet_profile_form(null, array('hostid' => $hostid));
  38  
  39  if ($data = $form->get_data()) {
  40      if (!isset($data->importdefault)) {
  41          $data->importdefault = 0;
  42      }
  43      if (!isset($data->exportdefault)) {
  44          $data->exportdefault = 0;
  45      }
  46      if (!isset($data->importfields)) {
  47          $data->importfields = array();
  48      }
  49      if (!isset($data->exportfields)) {
  50          $data->exportfields = array();
  51      }
  52      set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet');
  53      set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet');
  54      set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet');
  55      set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet');
  56  
  57      redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
  58  } elseif ($form->is_cancelled()) {
  59      redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid)));
  60  }
  61  
  62  echo $OUTPUT->header();
  63  
  64  $currenttab = 'mnetprofilefields';
  65  require_once ('tabs.php');
  66  
  67  echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4);
  68  
  69  $data = new Stdclass;
  70  $data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault');
  71  $data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault');
  72  $data->importfields = get_config('mnet', 'host' . $hostid . 'importfields');
  73  $data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields');
  74  
  75  if ($data->importfields === false) {
  76      $data->importdefault = true;
  77  } else {
  78      $data->importfields = explode(',', $data->importfields);
  79  }
  80  if ($data->exportfields === false) {
  81      $data->exportdefault = true;
  82  } else {
  83      $data->exportfields = explode(',', $data->exportfields);
  84  }
  85  
  86  $form->set_data($data);
  87  $form->display();
  88  
  89  echo $OUTPUT->footer();