diff --git a/admin/tool/dataprivacy/classes/external.php b/admin/tool/dataprivacy/classes/external.php index 4c4e71944ab..7306eb20d9d 100644 --- a/admin/tool/dataprivacy/classes/external.php +++ b/admin/tool/dataprivacy/classes/external.php @@ -1613,7 +1613,7 @@ class external extends external_api { */ private static function get_tree_node_structure($allowchildbranches = true) { $fields = [ - 'text' => new external_value(PARAM_TEXT, 'The node text', VALUE_REQUIRED), + 'text' => new external_value(PARAM_RAW, 'The node text', VALUE_REQUIRED), 'expandcontextid' => new external_value(PARAM_INT, 'The contextid this node expands', VALUE_REQUIRED), 'expandelement' => new external_value(PARAM_ALPHA, 'What element is this node expanded to', VALUE_REQUIRED), 'contextid' => new external_value(PARAM_INT, 'The node contextid', VALUE_REQUIRED), diff --git a/admin/tool/mobile/classes/external.php b/admin/tool/mobile/classes/external.php index b3c56bb3e01..8b9057c0f04 100644 --- a/admin/tool/mobile/classes/external.php +++ b/admin/tool/mobile/classes/external.php @@ -139,7 +139,7 @@ class external extends external_api { array( 'wwwroot' => new external_value(PARAM_RAW, 'Site URL.'), 'httpswwwroot' => new external_value(PARAM_RAW, 'Site https URL (if httpslogin is enabled).'), - 'sitename' => new external_value(PARAM_TEXT, 'Site name.'), + 'sitename' => new external_value(PARAM_RAW, 'Site name.'), 'guestlogin' => new external_value(PARAM_INT, 'Whether guest login is enabled.'), 'rememberusername' => new external_value(PARAM_INT, 'Values: 0 for No, 1 for Yes, 2 for optional.'), 'authloginviaemail' => new external_value(PARAM_INT, 'Whether log in via email is enabled.'), diff --git a/auth/email/classes/external.php b/auth/email/classes/external.php index 782f0336c4e..52e7227bae7 100644 --- a/auth/email/classes/external.php +++ b/auth/email/classes/external.php @@ -147,12 +147,12 @@ class auth_email_external extends external_api { array( 'id' => new external_value(PARAM_INT, 'Profile field id', VALUE_OPTIONAL), 'shortname' => new external_value(PARAM_ALPHANUMEXT, 'Profile field shortname', VALUE_OPTIONAL), - 'name' => new external_value(PARAM_TEXT, 'Profield field name', VALUE_OPTIONAL), + 'name' => new external_value(PARAM_RAW, 'Profield field name', VALUE_OPTIONAL), 'datatype' => new external_value(PARAM_ALPHANUMEXT, 'Profield field datatype', VALUE_OPTIONAL), 'description' => new external_value(PARAM_RAW, 'Profield field description', VALUE_OPTIONAL), 'descriptionformat' => new external_format_value('description'), 'categoryid' => new external_value(PARAM_INT, 'Profield field category id', VALUE_OPTIONAL), - 'categoryname' => new external_value(PARAM_TEXT, 'Profield field category name', VALUE_OPTIONAL), + 'categoryname' => new external_value(PARAM_RAW, 'Profield field category name', VALUE_OPTIONAL), 'sortorder' => new external_value(PARAM_INT, 'Profield field sort order', VALUE_OPTIONAL), 'required' => new external_value(PARAM_INT, 'Profield field required', VALUE_OPTIONAL), 'locked' => new external_value(PARAM_INT, 'Profield field locked', VALUE_OPTIONAL), diff --git a/blocks/classes/external.php b/blocks/classes/external.php index e9f09ac3837..cc0818097b6 100644 --- a/blocks/classes/external.php +++ b/blocks/classes/external.php @@ -59,7 +59,7 @@ class core_block_external extends external_api { 'visible' => new external_value(PARAM_BOOL, 'Whether the block is visible.', VALUE_OPTIONAL), 'contents' => new external_single_structure( array( - 'title' => new external_value(PARAM_TEXT, 'Block title.'), + 'title' => new external_value(PARAM_RAW, 'Block title.'), 'content' => new external_value(PARAM_RAW, 'Block contents.'), 'contentformat' => new external_format_value('content'), 'footer' => new external_value(PARAM_RAW, 'Block footer.'), diff --git a/calendar/externallib.php b/calendar/externallib.php index 3f186f1ee86..b2c94b546b0 100644 --- a/calendar/externallib.php +++ b/calendar/externallib.php @@ -319,6 +319,7 @@ class core_calendar_external extends external_api { $event = (array) $eventobj; // Description formatting. $calendareventobj = new calendar_event($event); + $event['name'] = $calendareventobj->format_external_name(); list($event['description'], $event['format']) = $calendareventobj->format_external_text(); if ($hassystemcap) { @@ -365,7 +366,7 @@ class core_calendar_external extends external_api { 'events' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'event id'), - 'name' => new external_value(PARAM_TEXT, 'event name'), + 'name' => new external_value(PARAM_RAW, 'event name'), 'description' => new external_value(PARAM_RAW, 'Description', VALUE_OPTIONAL, null, NULL_ALLOWED), 'format' => new external_format_value('description'), 'courseid' => new external_value(PARAM_INT, 'course id'), @@ -745,7 +746,7 @@ class core_calendar_external extends external_api { 'events' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'event id'), - 'name' => new external_value(PARAM_TEXT, 'event name'), + 'name' => new external_value(PARAM_RAW, 'event name'), 'description' => new external_value(PARAM_RAW, 'Description', VALUE_OPTIONAL), 'format' => new external_format_value('description'), 'courseid' => new external_value(PARAM_INT, 'course id'), diff --git a/calendar/lib.php b/calendar/lib.php index 9755765b13a..5189052e113 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -968,6 +968,22 @@ class calendar_event { } } + /** + * Format the event name using the external API. + * + * This function should we used when text formatting is required in external functions. + * + * @return string Formatted name. + */ + public function format_external_name() { + if ($this->editorcontext === null) { + // Switch on the event type to decide upon the appropriate context to use for this event. + $this->editorcontext = $this->get_context(); + } + + return external_format_string($this->properties->name, $this->editorcontext->id); + } + /** * Format the text using the external API. * diff --git a/course/externallib.php b/course/externallib.php index 5a896e7f2bf..66312c36407 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -426,7 +426,7 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Section ID'), - 'name' => new external_value(PARAM_TEXT, 'Section name'), + 'name' => new external_value(PARAM_RAW, 'Section name'), 'visible' => new external_value(PARAM_INT, 'is the section visible', VALUE_OPTIONAL), 'summary' => new external_value(PARAM_RAW, 'Section description'), 'summaryformat' => new external_format_value('summary'), @@ -669,12 +669,12 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'course id'), - 'shortname' => new external_value(PARAM_TEXT, 'course short name'), + 'shortname' => new external_value(PARAM_RAW, 'course short name'), 'categoryid' => new external_value(PARAM_INT, 'category id'), 'categorysortorder' => new external_value(PARAM_INT, 'sort order into the category', VALUE_OPTIONAL), - 'fullname' => new external_value(PARAM_TEXT, 'full name'), - 'displayname' => new external_value(PARAM_TEXT, 'course display name'), + 'fullname' => new external_value(PARAM_RAW, 'full name'), + 'displayname' => new external_value(PARAM_RAW, 'course display name'), 'idnumber' => new external_value(PARAM_RAW, 'id number', VALUE_OPTIONAL), 'summary' => new external_value(PARAM_RAW, 'summary'), 'summaryformat' => new external_format_value('summary'), @@ -729,7 +729,7 @@ class core_course_external extends external_api { ), 'customfields' => new external_multiple_structure( new external_single_structure( - ['name' => new external_value(PARAM_TEXT, 'The name of the custom field'), + ['name' => new external_value(PARAM_RAW, 'The name of the custom field'), 'shortname' => new external_value(PARAM_ALPHANUMEXT, 'The shortname of the custom field'), 'type' => new external_value(PARAM_COMPONENT, 'The type of the custom field - text, checkbox...'), @@ -939,7 +939,7 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'course id'), - 'shortname' => new external_value(PARAM_TEXT, 'short name'), + 'shortname' => new external_value(PARAM_RAW, 'short name'), ) ) ); @@ -1485,7 +1485,7 @@ class core_course_external extends external_api { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'course id'), - 'shortname' => new external_value(PARAM_TEXT, 'short name'), + 'shortname' => new external_value(PARAM_RAW, 'short name'), ) ); } @@ -1963,7 +1963,7 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'category id'), - 'name' => new external_value(PARAM_TEXT, 'category name'), + 'name' => new external_value(PARAM_RAW, 'category name'), 'idnumber' => new external_value(PARAM_RAW, 'category id number', VALUE_OPTIONAL), 'description' => new external_value(PARAM_RAW, 'category description'), 'descriptionformat' => new external_format_value('description'), @@ -2069,7 +2069,7 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'new category id'), - 'name' => new external_value(PARAM_TEXT, 'new category name'), + 'name' => new external_value(PARAM_RAW, 'new category name'), ) ) ); @@ -2607,11 +2607,11 @@ class core_course_external extends external_api { protected static function get_course_structure($onlypublicdata = true) { $coursestructure = array( 'id' => new external_value(PARAM_INT, 'course id'), - 'fullname' => new external_value(PARAM_TEXT, 'course full name'), - 'displayname' => new external_value(PARAM_TEXT, 'course display name'), - 'shortname' => new external_value(PARAM_TEXT, 'course short name'), + 'fullname' => new external_value(PARAM_RAW, 'course full name'), + 'displayname' => new external_value(PARAM_RAW, 'course display name'), + 'shortname' => new external_value(PARAM_RAW, 'course short name'), 'categoryid' => new external_value(PARAM_INT, 'category id'), - 'categoryname' => new external_value(PARAM_TEXT, 'category name'), + 'categoryname' => new external_value(PARAM_RAW, 'category name'), 'sortorder' => new external_value(PARAM_INT, 'Sort order in the category', VALUE_OPTIONAL), 'summary' => new external_value(PARAM_RAW, 'summary'), 'summaryformat' => new external_format_value('summary'), @@ -2861,7 +2861,7 @@ class core_course_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_ALPHANUMEXT, 'Outcome id'), - 'name' => new external_value(PARAM_TEXT, 'Outcome full name'), + 'name' => new external_value(PARAM_RAW, 'Outcome full name'), 'scale' => new external_value(PARAM_TEXT, 'Scale items') ) ), diff --git a/enrol/externallib.php b/enrol/externallib.php index 3d1f03f7450..d0fbaa9453a 100644 --- a/enrol/externallib.php +++ b/enrol/externallib.php @@ -460,7 +460,7 @@ class core_enrol_external extends external_api { 'id' => new external_value(PARAM_INT, 'id of course'), 'shortname' => new external_value(PARAM_RAW, 'short name of course'), 'fullname' => new external_value(PARAM_RAW, 'long name of course'), - 'displayname' => new external_value(PARAM_TEXT, 'course display name for lists.', VALUE_OPTIONAL), + 'displayname' => new external_value(PARAM_RAW, 'course display name for lists.', VALUE_OPTIONAL), 'enrolledusercount' => new external_value(PARAM_INT, 'Number of enrolled users in this course', VALUE_OPTIONAL), 'idnumber' => new external_value(PARAM_RAW, 'id number of course'), diff --git a/lib/external/externallib.php b/lib/external/externallib.php index c8e08abbb20..7bc8ab6b56a 100644 --- a/lib/external/externallib.php +++ b/lib/external/externallib.php @@ -497,7 +497,7 @@ class core_external extends external_api { 'value' => new external_value(PARAM_RAW, 'value of the item as it is stored', VALUE_OPTIONAL), 'itemid' => new external_value(PARAM_RAW, 'identifier of the updated item', VALUE_OPTIONAL), 'edithint' => new external_value(PARAM_NOTAGS, 'hint for editing element', VALUE_OPTIONAL), - 'editlabel' => new external_value(PARAM_NOTAGS, 'label for editing element', VALUE_OPTIONAL), + 'editlabel' => new external_value(PARAM_RAW, 'label for editing element', VALUE_OPTIONAL), 'type' => new external_value(PARAM_ALPHA, 'type of the element (text, toggle, select)', VALUE_OPTIONAL), 'options' => new external_value(PARAM_RAW, 'options of the element, format depends on type', VALUE_OPTIONAL), 'linkeverything' => new external_value(PARAM_INT, 'Should everything be wrapped in the edit link or link displayed separately', VALUE_OPTIONAL), diff --git a/message/externallib.php b/message/externallib.php index 0358c402ec8..32504c6acf2 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -1002,8 +1002,8 @@ class core_message_external extends external_api { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'The conversation id'), - 'name' => new external_value(PARAM_TEXT, 'The conversation name, if set', VALUE_DEFAULT, null), - 'subname' => new external_value(PARAM_TEXT, 'A subtitle for the conversation name, if set', VALUE_DEFAULT, null), + 'name' => new external_value(PARAM_RAW, 'The conversation name, if set', VALUE_DEFAULT, null), + 'subname' => new external_value(PARAM_RAW, 'A subtitle for the conversation name, if set', VALUE_DEFAULT, null), 'imageurl' => new external_value(PARAM_URL, 'A link to the conversation picture, if set', VALUE_DEFAULT, null), 'type' => new external_value(PARAM_INT, 'The type of the conversation (1=individual,2=group,3=self)'), 'membercount' => new external_value(PARAM_INT, 'Total number of conversation members'), @@ -1063,7 +1063,7 @@ class core_message_external extends external_api { array( 'id' => new external_value(PARAM_INT, 'Conversations id'), 'type' => new external_value(PARAM_INT, 'Conversation type: private or public'), - 'name' => new external_value(PARAM_TEXT, 'Multilang compatible conversation name'. VALUE_OPTIONAL), + 'name' => new external_value(PARAM_RAW, 'Multilang compatible conversation name'. VALUE_OPTIONAL), 'timecreated' => new external_value(PARAM_INT, 'The timecreated timestamp for the conversation'), ), 'information about conversation', VALUE_OPTIONAL), 'Conversations between users', VALUE_OPTIONAL diff --git a/mod/assign/externallib.php b/mod/assign/externallib.php index 907f7fa1552..49320c76680 100644 --- a/mod/assign/externallib.php +++ b/mod/assign/externallib.php @@ -593,8 +593,8 @@ class mod_assign_external extends external_api { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'course id'), - 'fullname' => new external_value(PARAM_TEXT, 'course full name'), - 'shortname' => new external_value(PARAM_TEXT, 'course short name'), + 'fullname' => new external_value(PARAM_RAW, 'course full name'), + 'shortname' => new external_value(PARAM_RAW, 'course short name'), 'timemodified' => new external_value(PARAM_INT, 'last time modified'), 'assignments' => new external_multiple_structure(self::get_assignments_assignment_structure(), 'assignment info') ), 'course information object' diff --git a/mod/forum/externallib.php b/mod/forum/externallib.php index a2e47e03f95..94b10b98c1f 100644 --- a/mod/forum/externallib.php +++ b/mod/forum/externallib.php @@ -467,7 +467,7 @@ class mod_forum_external extends external_api { 'created' => new external_value(PARAM_INT, 'Creation time'), 'modified' => new external_value(PARAM_INT, 'Time modified'), 'mailed' => new external_value(PARAM_INT, 'Mailed?'), - 'subject' => new external_value(PARAM_TEXT, 'The post subject'), + 'subject' => new external_value(PARAM_RAW, 'The post subject'), 'message' => new external_value(PARAM_RAW, 'The post message'), 'messageformat' => new external_format_value('message'), 'messagetrust' => new external_value(PARAM_INT, 'Can we trust?'), @@ -716,7 +716,7 @@ class mod_forum_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Post id'), - 'name' => new external_value(PARAM_TEXT, 'Discussion name'), + 'name' => new external_value(PARAM_RAW, 'Discussion name'), 'groupid' => new external_value(PARAM_INT, 'Group id'), 'timemodified' => new external_value(PARAM_INT, 'Time modified'), 'usermodified' => new external_value(PARAM_INT, 'The id of the user who last modified'), @@ -728,7 +728,7 @@ class mod_forum_external extends external_api { 'created' => new external_value(PARAM_INT, 'Creation time'), 'modified' => new external_value(PARAM_INT, 'Time modified'), 'mailed' => new external_value(PARAM_INT, 'Mailed?'), - 'subject' => new external_value(PARAM_TEXT, 'The post subject'), + 'subject' => new external_value(PARAM_RAW, 'The post subject'), 'message' => new external_value(PARAM_RAW, 'The post message'), 'messageformat' => new external_format_value('message'), 'messagetrust' => new external_value(PARAM_INT, 'Can we trust?'), @@ -1002,7 +1002,7 @@ class mod_forum_external extends external_api { new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Post id'), - 'name' => new external_value(PARAM_TEXT, 'Discussion name'), + 'name' => new external_value(PARAM_RAW, 'Discussion name'), 'groupid' => new external_value(PARAM_INT, 'Group id'), 'timemodified' => new external_value(PARAM_INT, 'Time modified'), 'usermodified' => new external_value(PARAM_INT, 'The id of the user who last modified'), @@ -1014,7 +1014,7 @@ class mod_forum_external extends external_api { 'created' => new external_value(PARAM_INT, 'Creation time'), 'modified' => new external_value(PARAM_INT, 'Time modified'), 'mailed' => new external_value(PARAM_INT, 'Mailed?'), - 'subject' => new external_value(PARAM_TEXT, 'The post subject'), + 'subject' => new external_value(PARAM_RAW, 'The post subject'), 'message' => new external_value(PARAM_RAW, 'The post message'), 'messageformat' => new external_format_value('message'), 'messagetrust' => new external_value(PARAM_INT, 'Can we trust?'),