mirror of
https://github.com/moodle/moodle.git
synced 2025-03-24 09:30:17 +01:00
MDL-65635 forum: convert inline reply format when opening the advanced
When a inline reply post is written and the user changes to the advanced edition, the post format has to be converted from FORMAT_MOODLE.
This commit is contained in:
parent
88f6ca6cbe
commit
f6548dfbae
2
mod/forum/amd/build/posts_list.min.js
vendored
2
mod/forum/amd/build/posts_list.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(e){e.on("click",d.post.inpageReplyLink,function(e){if(e.preventDefault(),window.location.hash){var f=window.location.href.split("#")[0];history.pushState({},document.title,f)}var g=a(e.currentTarget).parents(d.post.forumCoreContent),h=g.find(d.post.forumSubject),i=a(e.currentTarget).parents(d.post.forumContent),j={postid:a(i).data("post-id"),reply_url:a(e.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:h.html(),canreplyprivately:a(e.currentTarget).data("can-reply-privately")};if(i.find(d.post.inpageReplyContent).length){var k=i.find(d.post.inpageReplyContent);k.slideToggle(300),k.is(":visible")&&k.find("textarea").focus()}else b.render("mod_forum/inpage_reply",j).then(function(a,c){return b.appendNodeContents(g,a,c)}).then(function(){return i.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
|
||||
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)}}});
|
@ -60,7 +60,8 @@ define([
|
||||
"reply_url": $(e.currentTarget).attr('href'),
|
||||
sesskey: M.cfg.sesskey,
|
||||
parentsubject: currentSubject.html(),
|
||||
canreplyprivately: $(e.currentTarget).data('can-reply-privately')
|
||||
canreplyprivately: $(e.currentTarget).data('can-reply-privately'),
|
||||
postformat: InPageReply.CONTENT_FORMATS.MOODLE
|
||||
};
|
||||
|
||||
if (!currentRoot.find(Selectors.post.inpageReplyContent).length) {
|
||||
|
@ -36,6 +36,7 @@ $confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
$groupid = optional_param('groupid', null, PARAM_INT);
|
||||
$subject = optional_param('subject', '', PARAM_TEXT);
|
||||
$prefilledpost = optional_param('post', '', PARAM_TEXT);
|
||||
$prefilledpostformat = optional_param('postformat', FORMAT_MOODLE, PARAM_INT);
|
||||
$prefilledprivatereply = optional_param('privatereply', false, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/mod/forum/post.php', array(
|
||||
@ -251,6 +252,12 @@ if (!empty($forum)) {
|
||||
print_error('cannotreplytoprivatereply', 'forum');
|
||||
}
|
||||
|
||||
// If the prefilled post is sent using a different format to the preferred by the user, convert it.
|
||||
$preferredformat = editors_get_preferred_format();
|
||||
if ($preferredformat != $prefilledpostformat) {
|
||||
$prefilledpost = format_text($prefilledpost, $prefilledpostformat, ['context' => $modcontext]);
|
||||
}
|
||||
|
||||
// Load up the $post variable.
|
||||
$post = new stdClass();
|
||||
$post->course = $course->id;
|
||||
|
@ -39,6 +39,7 @@
|
||||
<div class="row pb-1">
|
||||
<span>
|
||||
<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="reply" value="{{postid}}"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user