Skip to content

Commit c2d3962

Browse files
handle private comments on course/recent.php
1 parent 6417c47 commit c2d3962

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ function mod_pdfannotator_core_calendar_provide_event_action(calendar_event $eve
562562
*/
563563
function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) {
564564
global $CFG, $COURSE, $USER, $DB;
565+
require_once($CFG->dirroot . '/mod/pdfannotator/locallib.php');
565566
if ($COURSE->id == $courseid) {
566567
$course = $COURSE;
567568
} else {
@@ -586,7 +587,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
586587
$groupselect = "";
587588
}
588589
$allnames = get_all_user_name_fields(true, 'u');
589-
if (!$posts = $DB->get_records_sql("SELECT p.*,c.id, c.userid AS duserid, c.visibility, c.content, c.timecreated, c.annotationid, c.isquestion,
590+
if (!$posts = $DB->get_records_sql("SELECT p.*,c.id, c.userid AS userid, c.visibility, c.content, c.timecreated, c.annotationid, c.isquestion,
590591
$allnames, u.email, u.picture, u.imagealt, u.email, a.page
591592
FROM {pdfannotator} p
592593
JOIN {pdfannotator_annotations} a ON a.pdfannotatorid=p.id
@@ -598,7 +599,11 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
598599
return;
599600
}
600601
$printposts = array();
602+
$context = context_course::instance($courseid);
601603
foreach ($posts as $post) {
604+
if(!pdfannotator_can_see_comment($post, $context)) {
605+
continue;
606+
}
602607
$printposts[] = $post;
603608
}
604609
if (!$printposts) {
@@ -627,7 +632,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
627632
// $additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email');
628633
$additionalfields = explode(',', user_picture::fields());
629634
$tmpactivity->user = username_load_fields_from_object($tmpactivity->user, $post, null, $additionalfields);
630-
$tmpactivity->user->id = $post->duserid;
635+
$tmpactivity->user->id = $post->userid;
631636

632637
$activities[$index++] = $tmpactivity;
633638
}
@@ -660,7 +665,7 @@ function pdfannotator_print_recent_mod_activity($activity, $courseid, $detail, $
660665
$output = html_writer::start_tag('table', $tableoptions);
661666
$output .= html_writer::start_tag('tr');
662667

663-
$authorhidden = ($activity->visible == 'public') ? 0 : 1;
668+
$authorhidden = ($activity->visible == 'anonymous') ? 1 : 0;
664669

665670
// Show user picture if author should not be hidden.
666671
$pictureoptions = [

0 commit comments

Comments
 (0)