From 9ba09a12445ca6ca870f4562209bc292d323e82b Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 22 May 2019 11:04:51 +0800 Subject: [PATCH] MDL-65675 forum: Remove duplicate Re in subjects --- mod/forum/amd/build/posts_list.min.js | 2 +- mod/forum/amd/src/posts_list.js | 2 +- mod/forum/classes/local/exporters/post.php | 8 ++++++++ mod/forum/lang/en/deprecated.txt | 1 + mod/forum/lang/en/forum.php | 4 +++- mod/forum/templates/forum_discussion_post.mustache | 6 +++++- mod/forum/templates/inpage_reply.mustache | 2 +- mod/forum/tests/externallib_test.php | 2 ++ 8 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 mod/forum/lang/en/deprecated.txt diff --git a/mod/forum/amd/build/posts_list.min.js b/mod/forum/amd/build/posts_list.min.js index df43413cab2..b888a7fb6b2 100644 --- a/mod/forum/amd/build/posts_list.min.js +++ b/mod/forum/amd/build/posts_list.min.js @@ -1 +1 @@ -define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(f){f.on("click",d.post.inpageReplyLink,function(f){if(f.preventDefault(),window.location.hash){var g=window.location.href.split("#")[0];history.pushState({},document.title,g)}var h=a(f.currentTarget).parents(d.post.forumCoreContent),i=h.find(d.post.forumSubject),j=a(f.currentTarget).parents(d.post.forumContent),k={postid:a(j).data("post-id"),reply_url:a(f.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:i.html(),canreplyprivately:a(f.currentTarget).data("can-reply-privately"),postformat:e.CONTENT_FORMATS.MOODLE};if(j.find(d.post.inpageReplyContent).length){var l=j.find(d.post.inpageReplyContent);l.slideToggle(300),l.is(":visible")&&l.find("textarea").focus()}else b.render("mod_forum/inpage_reply",k).then(function(a,c){return b.appendNodeContents(h,a,c)}).then(function(){return j.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}}); \ No newline at end of file +define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(f){f.on("click",d.post.inpageReplyLink,function(f){if(f.preventDefault(),window.location.hash){var g=window.location.href.split("#")[0];history.pushState({},document.title,g)}var h=a(f.currentTarget).parents(d.post.forumCoreContent),i=h.find(d.post.forumSubject),j=a(f.currentTarget).parents(d.post.forumContent),k={postid:a(j).data("post-id"),reply_url:a(f.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:i.data("replySubject"),canreplyprivately:a(f.currentTarget).data("can-reply-privately"),postformat:e.CONTENT_FORMATS.MOODLE};if(j.find(d.post.inpageReplyContent).length){var l=j.find(d.post.inpageReplyContent);l.slideToggle(300),l.is(":visible")&&l.find("textarea").focus()}else b.render("mod_forum/inpage_reply",k).then(function(a,c){return b.appendNodeContents(h,a,c)}).then(function(){return j.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}}); \ No newline at end of file diff --git a/mod/forum/amd/src/posts_list.js b/mod/forum/amd/src/posts_list.js index 5e24d7a5baf..3fbc5933c73 100644 --- a/mod/forum/amd/src/posts_list.js +++ b/mod/forum/amd/src/posts_list.js @@ -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 }; diff --git a/mod/forum/classes/local/exporters/post.php b/mod/forum/classes/local/exporters/post.php index 4528c602d8e..a5bff7d43c3 100644 --- a/mod/forum/classes/local/exporters/post.php +++ b/mod/forum/classes/local/exporters/post.php @@ -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 index 00000000000..dd59859d3d3 --- /dev/null +++ b/mod/forum/lang/en/deprecated.txt @@ -0,0 +1 @@ +inpagereplysubject,mod_forum diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index 12b78249fd5..89a544f64b6 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -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}'; diff --git a/mod/forum/templates/forum_discussion_post.mustache b/mod/forum/templates/forum_discussion_post.mustache index e5a8e1d1c48..73e202ca532 100644 --- a/mod/forum/templates/forum_discussion_post.mustache +++ b/mod/forum/templates/forum_discussion_post.mustache @@ -67,7 +67,11 @@ {{#parentauthorname}} {{#str}} inreplyto, mod_forum, {{.}} {{/str}} {{/parentauthorname}} -

{{$subject}}{{{subject}}}{{/subject}}

+

{{$subject}}{{{subject}}}{{/subject}}

{{^isdeleted}}
{{#html.authorsubheading}}{{{.}}}{{/html.authorsubheading}} diff --git a/mod/forum/templates/inpage_reply.mustache b/mod/forum/templates/inpage_reply.mustache index 8a99d1d356d..5ceb5c93c1e 100644 --- a/mod/forum/templates/inpage_reply.mustache +++ b/mod/forum/templates/inpage_reply.mustache @@ -41,7 +41,7 @@ - + diff --git a/mod/forum/tests/externallib_test.php b/mod/forum/tests/externallib_test.php index 5e903acbee5..177bf1a169b 100644 --- a/mod/forum/tests/externallib_test.php +++ b/mod/forum/tests/externallib_test.php @@ -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.