*/
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),
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.'),
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),
'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.'),
$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) {
'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'),
'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'),
}
}
+ /**
+ * 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.
*
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'),
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'),
),
'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...'),
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'),
)
)
);
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'),
)
);
}
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'),
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'),
)
)
);
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'),
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')
)
),
'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'),
'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),
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'),
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
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'
'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?'),
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'),
'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?'),
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'),
'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?'),