[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/mnet/ -> profilefields.php (source)

   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 . '/admin/mnet/profilefields_form.php');
  30  $mnet = get_mnet_environment();
  31  
  32  require_login();
  33  $hostid = required_param('hostid', PARAM_INT);
  34  $mnet_peer = new mnet_peer();
  35  $mnet_peer->set_id($hostid);
  36  
  37  $context = context_system::instance();
  38  
  39  require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
  40  admin_externalpage_setup('mnetpeers');
  41  $form = new mnet_profile_form(null, array('hostid' => $hostid));
  42  
  43  if ($data = $form->get_data()) {
  44      if (!isset($data->importdefault)) {
  45          $data->importdefault = 0;
  46      }
  47      if (!isset($data->exportdefault)) {
  48          $data->exportdefault = 0;
  49      }
  50      if (!isset($data->importfields)) {
  51          $data->importfields = array();
  52      }
  53      if (!isset($data->exportfields)) {
  54          $data->exportfields = array();
  55      }
  56      set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet');
  57      set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet');
  58      set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet');
  59      set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet');
  60  
  61      redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
  62  } elseif ($form->is_cancelled()) {
  63      redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid)));
  64  }
  65  
  66  echo $OUTPUT->header();
  67  
  68  $currenttab = 'mnetprofilefields';
  69  require_once ('tabs.php');
  70  
  71  echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4);
  72  
  73  $data = new Stdclass;
  74  $data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault');
  75  $data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault');
  76  $data->importfields = get_config('mnet', 'host' . $hostid . 'importfields');
  77  $data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields');
  78  
  79  if ($data->importfields === false) {
  80      $data->importdefault = true;
  81  } else {
  82      $data->importfields = explode(',', $data->importfields);
  83  }
  84  if ($data->exportfields === false) {
  85      $data->exportdefault = true;
  86  } else {
  87      $data->exportfields = explode(',', $data->exportfields);
  88  }
  89  
  90  $form->set_data($data);
  91  $form->display();
  92  
  93  echo $OUTPUT->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1