From e15444e1ec535cbaf0bcf51a0ecb7a405d7f81e1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 21 Jun 2022 17:09:59 +0100 Subject: [PATCH] MDL-75029 block_news_items: indicate posts made by deleted users. --- blocks/news_items/block_news_items.php | 11 ++++++++++- mod/forum/lib.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/blocks/news_items/block_news_items.php b/blocks/news_items/block_news_items.php index 482227cd332..a4c6ac17f96 100644 --- a/blocks/news_items/block_news_items.php +++ b/blocks/news_items/block_news_items.php @@ -119,10 +119,19 @@ class block_news_items extends block_base { if (!empty($CFG->forum_enabletimedposts) && ($discussion->timestart > $posttime)) { $posttime = $discussion->timestart; } + + // If the user who created the discussion post has been deleted, indicate so. + if ($discussion->userdeleted) { + $userfullname = get_string('deleteduser', 'mod_forum'); + } else { + $userfullname = fullname($discussion, has_capability('moodle/site:viewfullnames', $context)); + } + $text .= '
  • '. '
    '. '
    '.userdate($posttime, $strftimerecent).'
    '. - '
    '.fullname($discussion).'
    '. + '
    '.$userfullname.'
    '. + ''. ''. "
  • \n"; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index fc6f4a9cc6e..aa2f40b3db5 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1725,7 +1725,7 @@ function forum_get_discussions($cm, $forumsort="", $fullpost=true, $unused=-1, $ $allnames = $userfieldsapi->get_sql('u', false, '', '', false)->selects; $sql = "SELECT $postdata, $discussionfields, - $allnames, u.email, u.picture, u.imagealt $umfields + $allnames, u.email, u.picture, u.imagealt, u.deleted AS userdeleted $umfields FROM {forum_discussions} d JOIN {forum_posts} p ON p.discussion = d.id JOIN {user} u ON p.userid = u.id