mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-65786-master' of git://github.com/rezaies/moodle
This commit is contained in:
commit
e9fc5a7381
@ -481,11 +481,24 @@ class renderer {
|
||||
$discussionentriesids,
|
||||
$canseeanyprivatereply
|
||||
);
|
||||
$forumdatamapper = $this->legacydatamapperfactory->get_forum_data_mapper();
|
||||
$forumrecord = $forumdatamapper->to_legacy_object($forum);
|
||||
if (forum_tp_is_tracked($forumrecord, $user)) {
|
||||
$discussionunreadscount = $postvault->get_unread_count_for_discussion_ids(
|
||||
$user,
|
||||
$discussionentriesids,
|
||||
$canseeanyprivatereply
|
||||
);
|
||||
} else {
|
||||
$discussionunreadscount = [];
|
||||
}
|
||||
|
||||
array_walk($exportedposts['posts'], function($post) use ($discussionrepliescount) {
|
||||
array_walk($exportedposts['posts'], function($post) use ($discussionrepliescount, $discussionunreadscount) {
|
||||
$post->discussionrepliescount = $discussionrepliescount[$post->discussionid] ?? 0;
|
||||
$post->discussionunreadscount = $discussionunreadscount[$post->discussionid] ?? 0;
|
||||
// TODO: Find a better solution due to language differences when defining the singular and plural form.
|
||||
$post->isreplyplural = $post->discussionrepliescount != 1 ? true : false;
|
||||
$post->isunreadplural = $post->discussionunreadscount != 1 ? true : false;
|
||||
});
|
||||
|
||||
$exportedposts['state']['hasdiscussions'] = $exportedposts['posts'] ? true : false;
|
||||
|
@ -38,7 +38,9 @@
|
||||
{{< mod_forum/forum_discussion_post }}
|
||||
{{$footer}}
|
||||
<div class="link text-right">
|
||||
<a href="{{urls.discuss}}">{{#str}}discussthistopic, forum{{/str}}</a> ({{discussionrepliescount}}{{#isreplyplural}}{{#str}}repliesmany, forum{{/str}}{{/isreplyplural}}{{^isreplyplural}}{{#str}}repliesone, forum{{/str}}{{/isreplyplural}})
|
||||
<a href="{{urls.discuss}}">{{#str}}discussthistopic, forum{{/str}}</a> ({{#isreplyplural}}{{#str}} repliesmany, forum, {{discussionrepliescount}} {{/str}}{{/isreplyplural}}{{^isreplyplural}}{{#str}} repliesone, forum, {{discussionrepliescount}} {{/str}}{{/isreplyplural}}{{#discussionunreadscount}}
|
||||
<span class="sep">/</span>
|
||||
<span class="unread"><a href="{{urls.discuss}}#unread">{{#isunreadplural}}{{#str}} unreadpostsnumber, mod_forum, {{discussionunreadscount}} {{/str}}{{/isunreadplural}}{{^isunreadplural}}{{#str}} unreadpostsone, mod_forum {{/str}}{{/isunreadplural}}</a></span>{{/discussionunreadscount}})
|
||||
</div>
|
||||
{{/footer}}
|
||||
{{$replyoutput}}{{/replyoutput}}
|
||||
|
@ -160,12 +160,27 @@ switch ($forum->get_type()) {
|
||||
$orderpostsby
|
||||
);
|
||||
echo $discussionsrenderer->render($USER, $post, $replies);
|
||||
|
||||
if (!$CFG->forum_usermarksread && forum_tp_is_tracked($forumrecord, $USER)) {
|
||||
$postids = array_map(function($post) {
|
||||
return $post->get_id();
|
||||
}, array_merge([$post], array_values($replies)));
|
||||
forum_tp_mark_posts_read($USER, $postids);
|
||||
}
|
||||
break;
|
||||
case 'blog':
|
||||
$discussionsrenderer = $rendererfactory->get_blog_discussion_list_renderer($forum);
|
||||
// Blog forums always show discussions newest first.
|
||||
echo $discussionsrenderer->render($USER, $cm, $groupid, $discussionlistvault::SORTORDER_CREATED_DESC,
|
||||
$pageno, $pagesize);
|
||||
|
||||
if (!$CFG->forum_usermarksread && forum_tp_is_tracked($forumrecord, $USER)) {
|
||||
$discussions = mod_forum_get_discussion_summaries($forum, $USER, $groupid, null, $pageno, $pagesize);
|
||||
$firstpostids = array_map(function($discussion) {
|
||||
return $discussion->get_first_post()->get_id();
|
||||
}, array_values($discussions));
|
||||
forum_tp_mark_posts_read($USER, $firstpostids);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$discussionsrenderer = $rendererfactory->get_discussion_list_renderer($forum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user