MDL-65675 forum: Remove duplicate Re in subjects
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 22 May 2019 03:04:51 +0000 (11:04 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Mon, 27 May 2019 04:21:30 +0000 (12:21 +0800)
mod/forum/amd/build/posts_list.min.js
mod/forum/amd/src/posts_list.js
mod/forum/classes/local/exporters/post.php
mod/forum/lang/en/deprecated.txt [new file with mode: 0644]
mod/forum/lang/en/forum.php
mod/forum/templates/forum_discussion_post.mustache
mod/forum/templates/inpage_reply.mustache
mod/forum/tests/externallib_test.php

index df43413..b888a7f 100644 (file)
Binary files a/mod/forum/amd/build/posts_list.min.js and b/mod/forum/amd/build/posts_list.min.js differ
index 5e24d7a..3fbc593 100644 (file)
@@ -59,7 +59,7 @@ define([
                 postid: $(currentRoot).data('post-id'),
                 "reply_url": $(e.currentTarget).attr('href'),
                 sesskey: M.cfg.sesskey,
-                parentsubject: currentSubject.html(),
+                parentsubject: currentSubject.data('replySubject'),
                 canreplyprivately: $(e.currentTarget).data('can-reply-privately'),
                 postformat: InPageReply.CONTENT_FORMATS.MOODLE
             };
index 4528c60..a5bff7d 100644 (file)
@@ -92,6 +92,7 @@ class post extends exporter {
         return [
             'id' => ['type' => PARAM_INT],
             'subject' => ['type' => PARAM_TEXT],
+            'replysubject' => ['type' => PARAM_TEXT],
             'message' => ['type' => PARAM_RAW],
             'messageformat' => ['type' => PARAM_INT],
             'author' => ['type' => author_exporter::read_properties_definition()],
@@ -401,9 +402,16 @@ class post extends exporter {
             }
         }
 
+        $replysubject = $subject;
+        $strre = get_string('re', 'forum');
+        if (!(substr($replysubject, 0, strlen($strre)) == $strre)) {
+            $replysubject = "{$strre} {$replysubject}";
+        }
+
         return [
             'id' => $post->get_id(),
             'subject' => $subject,
+            'replysubject' => $replysubject,
             'message' => $message,
             'messageformat' => $post->get_message_format(),
             'author' => $exportedauthor,
diff --git a/mod/forum/lang/en/deprecated.txt b/mod/forum/lang/en/deprecated.txt
new file mode 100644 (file)
index 0000000..dd59859
--- /dev/null
@@ -0,0 +1 @@
+inpagereplysubject,mod_forum
index 12b7824..89a544f 100644 (file)
@@ -323,7 +323,6 @@ $string['invalidforcesubscribe'] = 'Invalid force subscription mode';
 $string['invalidforumid'] = 'Forum ID was incorrect';
 $string['invalidparentpostid'] = 'Parent post ID was incorrect';
 $string['invalidpostid'] = 'Invalid post ID - {$a}';
-$string['inpagereplysubject'] = 'Re: {$a}';
 $string['lastpost'] = 'Last post';
 $string['learningforums'] = 'Learning forums';
 $string['lockdiscussionafter'] = 'Lock discussions after period of inactivity';
@@ -673,3 +672,6 @@ $string['yournewtopic'] = 'Your new discussion topic';
 $string['yourreply'] = 'Your reply';
 $string['forumsubjectdeleted'] = 'This forum post has been removed';
 $string['forumbodydeleted'] = 'The content of this forum post has been removed and can no longer be accessed.';
+
+// Deprecated since Moodle 3.8.
+$string['inpagereplysubject'] = 'Re: {$a}';
index e5a8e1d..73e202c 100644 (file)
                     {{#parentauthorname}}
                         <span class="sr-only">{{#str}} inreplyto, mod_forum, {{.}} {{/str}}</span>
                     {{/parentauthorname}}
-                    <h3 class="h6 font-weight-bold mb-0" data-region-content="forum-post-core-subject">{{$subject}}{{{subject}}}{{/subject}}</h3>
+                    <h3 {{!
+                        }}class="h6 font-weight-bold mb-0" {{!
+                        }}data-region-content="forum-post-core-subject" {{!
+                        }}data-reply-subject="{{replysubject}}" {{!
+                        }}>{{$subject}}{{{subject}}}{{/subject}}</h3>
                     {{^isdeleted}}
                         <address tabindex="-1">
                             {{#html.authorsubheading}}{{{.}}}{{/html.authorsubheading}}
index 8a99d1d..5ceb5c9 100644 (file)
@@ -41,7 +41,7 @@
                     <textarea rows="5" name="post" title="post" class="w-100" placeholder="{{#str}} replyplaceholder, forum {{/str}}"></textarea>
                     <input type="hidden" name="postformat" value="{{postformat}}"/>
                 </span>
-                <input type="hidden" name="subject" value="{{#str}} inpagereplysubject, forum, {{parentsubject}} {{/str}}"/>
+                <input type="hidden" name="subject" value="{{parentsubject}}"/>
                 <input type="hidden" name="reply" value="{{postid}}"/>
                 <input type="hidden" name="sesskey" value="{{sesskey}}"/>
             </div>
index 5e903ac..177bf1a 100644 (file)
@@ -668,6 +668,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
             'hasparent' => true,
             'timecreated' => $discussion1reply2->created,
             'subject' => $discussion1reply2->subject,
+            'replysubject' => get_string('re', 'mod_forum') . " {$discussion1reply2->subject}",
             'message' => file_rewrite_pluginfile_urls($discussion1reply2->message, 'pluginfile.php',
                     $forum1context->id, 'mod_forum', 'post', $discussion1reply2->id),
             'messageformat' => 1,   // This value is usually changed by external_format_text() function.
@@ -721,6 +722,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
             'hasparent' => true,
             'timecreated' => $discussion1reply1->created,
             'subject' => $discussion1reply1->subject,
+            'replysubject' => get_string('re', 'mod_forum') . " {$discussion1reply1->subject}",
             'message' => file_rewrite_pluginfile_urls($discussion1reply1->message, 'pluginfile.php',
                     $forum1context->id, 'mod_forum', 'post', $discussion1reply1->id),
             'messageformat' => 1,   // This value is usually changed by external_format_text() function.