-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-23460 MNet Reverted recent removal of per-peer profile field setting
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Allows the admin to configure a list of profile fields that are sent/recieved | ||
* | ||
* @package core | ||
* @subpackage mnet | ||
* @copyright 2010 onwards Penny Leach <penny@liip.ch> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require(dirname(dirname(dirname(__FILE__))).'/config.php'); | ||
require_once($CFG->libdir.'/adminlib.php'); | ||
require_once($CFG->dirroot . '/admin/mnet/profilefields_form.php'); | ||
$mnet = get_mnet_environment(); | ||
|
||
require_login(); | ||
$hostid = required_param('hostid', PARAM_INT); | ||
$mnet_peer = new mnet_peer(); | ||
$mnet_peer->set_id($hostid); | ||
|
||
$context = get_context_instance(CONTEXT_SYSTEM); | ||
|
||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions'); | ||
admin_externalpage_setup('mnetpeers'); | ||
$form = new mnet_profile_form(null, array('hostid' => $hostid)); | ||
|
||
if ($data = $form->get_data()) { | ||
if (!isset($data->importdefault)) { | ||
$data->importdefault = 0; | ||
} | ||
if (!isset($data->exportdefault)) { | ||
$data->exportdefault = 0; | ||
} | ||
if (!isset($data->importfields)) { | ||
$data->importfields = array(); | ||
} | ||
if (!isset($data->exportfields)) { | ||
$data->exportfields = array(); | ||
} | ||
set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet'); | ||
set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet'); | ||
set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet'); | ||
set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet'); | ||
|
||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved')); | ||
} elseif ($form->is_cancelled()) { | ||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid))); | ||
} | ||
|
||
echo $OUTPUT->header(); | ||
|
||
$currenttab = 'mnetprofilefields'; | ||
require_once('tabs.php'); | ||
|
||
echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4); | ||
|
||
$data = new Stdclass; | ||
$data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault'); | ||
$data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault'); | ||
$data->importfields = get_config('mnet', 'host' . $hostid . 'importfields'); | ||
$data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields'); | ||
|
||
if ($data->importfields === false) { | ||
$data->importdefault = true; | ||
} else { | ||
$data->importfields = explode(',', $data->importfields); | ||
} | ||
if ($data->exportfields === false) { | ||
$data->exportdefault = true; | ||
} else { | ||
$data->exportfields = explode(',', $data->exportfields); | ||
} | ||
|
||
$form->set_data($data); | ||
$form->display(); | ||
|
||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Allows the admin to configure a list of profile fields that are sent/recieved | ||
* | ||
* @package core | ||
* @subpackage mnet | ||
* @copyright 2010 onwards Penny Leach <penny@liip.ch> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
if (!defined('MOODLE_INTERNAL')) { | ||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page | ||
} | ||
|
||
require_once($CFG->libdir . '/formslib.php'); | ||
|
||
/** | ||
* small form to allow the administrator to configure (override) which profile fields are sent/imported over mnet | ||
*/ | ||
class mnet_profile_form extends moodleform { | ||
|
||
function definition() { | ||
global $CFG; | ||
$mform =& $this->_form; | ||
|
||
|
||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']); | ||
$fields = mnet_profile_field_options(); | ||
|
||
// Fields to import ---------------------------------------------------- | ||
$mform->addElement('header', 'import', get_string('importfields', 'mnet')); | ||
|
||
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']); | ||
$select->setMultiple(true); | ||
|
||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileimportfields)); | ||
|
||
// Fields to export ---------------------------------------------------- | ||
$mform->addElement('header', 'export', get_string('exportfields', 'mnet')); | ||
|
||
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']); | ||
$select->setMultiple(true); | ||
|
||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileexportfields)); | ||
|
||
$this->add_action_buttons(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters