Skip to content
Snippets Groups Projects
Commit 6289b05b authored by Friederike Schwager's avatar Friederike Schwager
Browse files

handle private comments on course/recent.php

parent 82f865c5
No related branches found
No related tags found
No related merge requests found
...@@ -562,6 +562,7 @@ function mod_pdfannotator_core_calendar_provide_event_action(calendar_event $eve ...@@ -562,6 +562,7 @@ function mod_pdfannotator_core_calendar_provide_event_action(calendar_event $eve
*/ */
function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) { function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) {
global $CFG, $COURSE, $USER, $DB; global $CFG, $COURSE, $USER, $DB;
require_once($CFG->dirroot . '/mod/pdfannotator/locallib.php');
if ($COURSE->id == $courseid) { if ($COURSE->id == $courseid) {
$course = $COURSE; $course = $COURSE;
} else { } else {
...@@ -586,7 +587,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, ...@@ -586,7 +587,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
$groupselect = ""; $groupselect = "";
} }
$allnames = get_all_user_name_fields(true, 'u'); $allnames = get_all_user_name_fields(true, 'u');
if (!$posts = $DB->get_records_sql("SELECT p.*,c.id, c.userid AS duserid, c.visibility, c.content, c.timecreated, c.annotationid, c.isquestion, if (!$posts = $DB->get_records_sql("SELECT p.*,c.id, c.userid AS userid, c.visibility, c.content, c.timecreated, c.annotationid, c.isquestion,
$allnames, u.email, u.picture, u.imagealt, u.email, a.page $allnames, u.email, u.picture, u.imagealt, u.email, a.page
FROM {pdfannotator} p FROM {pdfannotator} p
JOIN {pdfannotator_annotations} a ON a.pdfannotatorid=p.id JOIN {pdfannotator_annotations} a ON a.pdfannotatorid=p.id
...@@ -598,7 +599,11 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, ...@@ -598,7 +599,11 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
return; return;
} }
$printposts = array(); $printposts = array();
$context = context_course::instance($courseid);
foreach ($posts as $post) { foreach ($posts as $post) {
if(!pdfannotator_can_see_comment($post, $context)) {
continue;
}
$printposts[] = $post; $printposts[] = $post;
} }
if (!$printposts) { if (!$printposts) {
...@@ -627,7 +632,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, ...@@ -627,7 +632,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
// $additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email'); // $additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email');
$additionalfields = explode(',', user_picture::fields()); $additionalfields = explode(',', user_picture::fields());
$tmpactivity->user = username_load_fields_from_object($tmpactivity->user, $post, null, $additionalfields); $tmpactivity->user = username_load_fields_from_object($tmpactivity->user, $post, null, $additionalfields);
$tmpactivity->user->id = $post->duserid; $tmpactivity->user->id = $post->userid;
$activities[$index++] = $tmpactivity; $activities[$index++] = $tmpactivity;
} }
...@@ -660,7 +665,7 @@ function pdfannotator_print_recent_mod_activity($activity, $courseid, $detail, $ ...@@ -660,7 +665,7 @@ function pdfannotator_print_recent_mod_activity($activity, $courseid, $detail, $
$output = html_writer::start_tag('table', $tableoptions); $output = html_writer::start_tag('table', $tableoptions);
$output .= html_writer::start_tag('tr'); $output .= html_writer::start_tag('tr');
$authorhidden = ($activity->visible == 'public') ? 0 : 1; $authorhidden = ($activity->visible == 'anonymous') ? 1 : 0;
// Show user picture if author should not be hidden. // Show user picture if author should not be hidden.
$pictureoptions = [ $pictureoptions = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment