public static function verify_webfinger_parameters() {
return new external_function_parameters(
array(
- 'profileurl' => new external_value(PARAM_RAW, 'The profile url that the user has given us', VALUE_REQUIRED),
+ 'profileurl' => new external_value(PARAM_NOTAGS, 'The profile url that the user has given us', VALUE_REQUIRED),
'course' => new external_value(PARAM_INT, 'The course we are adding to', VALUE_REQUIRED),
'section' => new external_value(PARAM_INT, 'The section within the course we are adding to', VALUE_REQUIRED),
)
$user = \core_user::get_user($userid, 'moodlenetprofile');
try {
$userprofile = $user->moodlenetprofile ? $user->moodlenetprofile : '';
- return (isset($user)) ? new moodlenet_user_profile($userprofile, $userid) : null;
+ return (isset($user)) ? new moodlenet_user_profile(s($userprofile), $userid) : null;
} catch (\moodle_exception $e) {
// If an exception is thrown, means there isn't a valid profile set. No need to log exception.
return null;
if ($field->get_category_name() == self::get_category_name()
&& $field->inputname == 'profile_field_mnetprofile') {
try {
- return new moodlenet_user_profile($field->display_data(), $userid);
+ return new moodlenet_user_profile(s($field->display_data()), $userid);
} catch (\moodle_exception $e) {
// If an exception is thrown, means there isn't a valid profile set. No need to log exception.
return null;
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2020061503) {
+
+ // Find out if there are users with MoodleNet profiles set.
+ $sql = "SELECT u.*
+ FROM {user} u
+ WHERE u.moodlenetprofile IS NOT NULL";
+
+ $records = $DB->get_records_sql($sql);
+
+ foreach ($records as $record) {
+ // Force clean user value just incase there is something malicious.
+ $record->moodlenetprofile = clean_text($record->moodlenetprofile, PARAM_NOTAGS);
+ $DB->update_record('user', $record);
+ }
+
+ upgrade_plugin_savepoint(true, 2020061503, 'tool', 'moodlenet');
+ }
+
return true;
}
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'tool_moodlenet';
-$plugin->version = 2020061502;
+$plugin->version = 2020061503;
$plugin->requires = 2020060900;
$plugin->maturity = MATURITY_ALPHA;
$string['match'] = 'Match';
$string['matchofthefollowing'] = 'of the following:';
$string['moodlenetprofile'] = 'MoodleNet profile';
+$string['moodlenetprofile_help'] = 'This field is to link your MoodleNet profile to Moodle. It expects a WebFinger compliant URI';
$string['placeholdertypeorselect'] = 'Type or select...';
$string['placeholdertype'] = 'Type...';
$string['privacy:courserequestpath'] = 'Requested courses';
$mform->addHelpButton('maildisplay', 'emaildisplay');
$mform->addElement('text', 'moodlenetprofile', get_string('moodlenetprofile', 'user'));
- $mform->setType('moodlenetprofile', PARAM_RAW_TRIMMED);
+ $mform->setType('moodlenetprofile', PARAM_NOTAGS);
+ $mform->addHelpButton('moodlenetprofile', 'moodlenetprofile', 'user');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT);