Example #1
0
 /**
  * Gets a list of the profile fields to be matched with the external ones.
  */
 function get_user_profile_fields()
 {
     return mnet_get_user_fields();
 }
Example #2
0
require_once 'mnet_userprofile_form.php';
require_login();
admin_externalpage_setup('mnetpeers');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
/// Initialize variables.
$hostid = required_param('hostid', PARAM_INT);
$strmnetuserprofile = get_string('mnetuserprofile', 'mnet');
admin_externalpage_print_header();
$mnet_peer->id = $hostid;
//hack to make tabs.php behave.
$mnet_peer->application->name = '';
//hack to make tabs.php behave.
$currenttab = 'mnetuserprofile';
require_once $CFG->dirroot . '/admin/mnet/tabs.php';
$userfields = mnet_get_user_fields();
$externalfields = mnet_get_externalprofilefields($hostid);
if (empty($externalfields)) {
    //todo - should use a default set of $externalfields as none have been returned from the external system
    error("Mnet returned no externalfields - please upgrade your external system");
}
$mform = new mnetuserpofile_form('', array('hostid' => $hostid, 'externalvalues' => $externalfields, 'internalvalues' => $userfields));
$mnetconfig = get_records_menu('config_plugins', 'plugin', 'mnet_userprofile_' . $hostid, '', 'UPPER(name), UPPER(value)');
$mform->set_data($mnetconfig);
/// If data submitted, process and store
if (($form = data_submitted()) && confirm_sesskey()) {
    foreach ($userfields as $field => $value) {
        set_config($value, strtolower($form->{$field}), 'mnet_userprofile_' . $hostid);
    }
}
$mform->display();