MDL-65025 forum: Fix text formatting (check messagetrust) in WS
[moodle.git] / mod / forum / externallib.php
index 5a6fb60..04fb63c 100644 (file)
@@ -413,8 +413,10 @@ class mod_forum_external extends external_api {
 
             $post->subject = external_format_string($post->subject, $modcontext->id);
             // Rewrite embedded images URLs.
+            $options = array('trusted' => $post->messagetrust);
             list($post->message, $post->messageformat) =
-                external_format_text($post->message, $post->messageformat, $modcontext->id, 'mod_forum', 'post', $post->id);
+                external_format_text($post->message, $post->messageformat, $modcontext->id, 'mod_forum', 'post', $post->id,
+                    $options);
 
             // List attachments.
             if (!empty($post->attachment)) {
@@ -626,9 +628,10 @@ class mod_forum_external extends external_api {
                 $discussion->name = external_format_string($discussion->name, $modcontext->id);
                 $discussion->subject = external_format_string($discussion->subject, $modcontext->id);
                 // Rewrite embedded images URLs.
+                $options = array('trusted' => $discussion->messagetrust);
                 list($discussion->message, $discussion->messageformat) =
                     external_format_text($discussion->message, $discussion->messageformat,
-                                            $modcontext->id, 'mod_forum', 'post', $discussion->id);
+                                            $modcontext->id, 'mod_forum', 'post', $discussion->id, $options);
 
                 // List attachments.
                 if (!empty($discussion->attachment)) {
@@ -925,9 +928,10 @@ class mod_forum_external extends external_api {
                 $discussionobject->name = external_format_string($discussion->get_name(), $modcontext->id);
                 $discussionobject->subject = external_format_string($discussionobject->subject, $modcontext->id);
                 // Rewrite embedded images URLs.
+                $options = array('trusted' => $discussionobject->messagetrust);
                 list($discussionobject->message, $discussionobject->messageformat) =
                     external_format_text($discussionobject->message, $discussionobject->messageformat,
-                        $modcontext->id, 'mod_forum', 'post', $discussionobject->id);
+                        $modcontext->id, 'mod_forum', 'post', $discussionobject->id, $options);
 
                 // List attachments.
                 if (!empty($discussionobject->attachment)) {