From 30bee9ef409974b1cffe754a22e892c94eb3f8a3 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Fri, 23 Jul 2010 08:10:23 +0000 Subject: [PATCH] MDL-23460 MNet Reverted recent removal of per-peer profile field setting --- admin/mnet/profilefields.php | 93 +++++++++++++++++++++++++++++++ admin/mnet/profilefields_form.php | 64 +++++++++++++++++++++ lang/en/mnet.php | 4 ++ 3 files changed, 161 insertions(+) create mode 100644 admin/mnet/profilefields.php create mode 100644 admin/mnet/profilefields_form.php diff --git a/admin/mnet/profilefields.php b/admin/mnet/profilefields.php new file mode 100644 index 0000000000000..23443e90636c6 --- /dev/null +++ b/admin/mnet/profilefields.php @@ -0,0 +1,93 @@ +. + +/** + * Allows the admin to configure a list of profile fields that are sent/recieved + * + * @package core + * @subpackage mnet + * @copyright 2010 onwards Penny Leach + * @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(); diff --git a/admin/mnet/profilefields_form.php b/admin/mnet/profilefields_form.php new file mode 100644 index 0000000000000..79809f3b55a1c --- /dev/null +++ b/admin/mnet/profilefields_form.php @@ -0,0 +1,64 @@ +. + +/** + * Allows the admin to configure a list of profile fields that are sent/recieved + * + * @package core + * @subpackage mnet + * @copyright 2010 onwards Penny Leach + * @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(); + } +} diff --git a/lang/en/mnet.php b/lang/en/mnet.php index f88cf33fbe133..cae5f9c08b063 100644 --- a/lang/en/mnet.php +++ b/lang/en/mnet.php @@ -66,6 +66,7 @@ $string['expires'] = 'Valid until'; $string['expireyourkey'] = 'Delete this key'; $string['expireyourkeyexplain'] = 'Moodle automatically rotates your keys every 28 days (by default) but you have the option to manually expire this key at any time. This will only be useful if you believe this key has been compromised. A replacement will be immediately automatically generated.
Deleting this key will make it impossible for other applications to communicate with you, until you manually contact each administrator and provide them with your new key.'; +$string['exportfields'] = 'Fields to export'; $string['failedaclwrite'] = 'Failed to write to the MNet access control list for user \'{$a}\'.'; $string['findlogin'] = 'Find login'; $string['forbidden-function'] = 'That function has not been enabled for RPC.'; @@ -89,6 +90,7 @@ $string['http_verified_help'] = 'Permit connections using a verified SSL certificate in PHP on the remote host, but over http (not https).'; $string['id'] = 'ID'; $string['idhelp'] = 'This value is automatically assigned and cannot be changed'; +$string['importfields'] = 'Fields to import'; $string['inspect'] = 'Inspect'; $string['installnosuchfunction'] = 'Coding error! Something is trying to install a mnet xmlrpc function ({$a->method}) from a file ({$a->file}) and it can\'t be found!'; $string['installnosuchmethod'] = 'Coding error! Something is trying to install a mnet xmlrpc method ({$a->method}) on a class ({$a->class}) and it can\'t be found!'; @@ -108,6 +110,7 @@ $string['last_connect_time'] = 'Last connect time'; $string['last_connect_time_help'] = 'The time that you last connected to this host.'; $string['last_transport_help'] = 'The transport that you used for the last connection to this host.'; +$string['leavedefault'] = 'Use the default settings instead'; $string['listservices'] = 'List services'; $string['loginlinkmnetuser'] = '
If you are MNet remote user and can confirm your email address here, you can be redirected to your login page.
'; $string['logs'] = 'logs'; @@ -160,6 +163,7 @@ $string['off'] = 'Off'; $string['on'] = 'On'; $string['options'] = 'Options'; +$string['peerprofilefielddesc'] = 'Here you can override the global settings for which profile fields to send and import when new users are created'; $string['permittedtransports'] = 'Permitted transports'; $string['phperror'] = 'An internal PHP error prevented your request being fulfilled.'; $string['position'] = 'Position';