From 14968ca9ac4f85853de9102d96b7ab2cfd9d2143 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Mon, 15 Aug 2016 15:53:06 +0800 Subject: [PATCH] MDL-55567 messages: Use FORMAT_MOODLE as default for sending messages This is like plain text, but it preserves new-lines and has some other special features. --- lib/externallib.php | 7 +++++-- message/externallib.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/externallib.php b/lib/externallib.php index 8cd2c41b99c..fb7f5945c8b 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -815,11 +815,14 @@ class external_format_value extends external_value { * * @param string $textfieldname Name of the text field * @param int $required if VALUE_REQUIRED then set standard default FORMAT_HTML + * @param int $default Default value. * @since Moodle 2.3 */ - public function __construct($textfieldname, $required = VALUE_REQUIRED) { + public function __construct($textfieldname, $required = VALUE_REQUIRED, $default = null) { - $default = ($required == VALUE_DEFAULT) ? FORMAT_HTML : null; + if ($default == null && $required == VALUE_DEFAULT) { + $default = FORMAT_HTML; + } $desc = $textfieldname . ' format (' . FORMAT_HTML . ' = HTML, ' . FORMAT_MOODLE . ' = MOODLE, ' diff --git a/message/externallib.php b/message/externallib.php index 8442f185de8..3f704a4e1e2 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -52,7 +52,7 @@ class core_message_external extends external_api { array( 'touserid' => new external_value(PARAM_INT, 'id of the user to send the private message'), 'text' => new external_value(PARAM_RAW, 'the text of the message'), - 'textformat' => new external_format_value('text', VALUE_DEFAULT), + 'textformat' => new external_format_value('text', VALUE_DEFAULT, FORMAT_MOODLE), 'clientmsgid' => new external_value(PARAM_ALPHANUMEXT, 'your own client id for the message. If this id is provided, the fail message id will be returned to you', VALUE_OPTIONAL), ) )