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

handle private comments on course/recent.php

parent 6417c47d
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
*/
function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) {
global $CFG, $COURSE, $USER, $DB;
require_once($CFG->dirroot . '/mod/pdfannotator/locallib.php');
if ($COURSE->id == $courseid) {
$course = $COURSE;
} else {
......@@ -586,7 +587,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
$groupselect = "";
}
$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
FROM {pdfannotator} p
JOIN {pdfannotator_annotations} a ON a.pdfannotatorid=p.id
......@@ -598,7 +599,11 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
return;
}
$printposts = array();
$context = context_course::instance($courseid);
foreach ($posts as $post) {
if(!pdfannotator_can_see_comment($post, $context)) {
continue;
}
$printposts[] = $post;
}
if (!$printposts) {
......@@ -627,7 +632,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
// $additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email');
$additionalfields = explode(',', user_picture::fields());
$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;
}
......@@ -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('tr');
$authorhidden = ($activity->visible == 'public') ? 0 : 1;
$authorhidden = ($activity->visible == 'anonymous') ? 1 : 0;
// Show user picture if author should not be hidden.
$pictureoptions = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment