From 685d0e1c77c86ba1b5b070be4ecca7d8ad681a86 Mon Sep 17 00:00:00 2001
From: Friederike Schwager <schwager@cil.rwth-aachen.de>
Date: Mon, 27 May 2019 13:07:47 +0200
Subject: [PATCH] display hidden comments as hidden after searching

---
 classes/output/comment.php |  1 -
 model/comment.class.php    | 16 +++++-----------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/classes/output/comment.php b/classes/output/comment.php
index 860baab..a6f6b33 100644
--- a/classes/output/comment.php
+++ b/classes/output/comment.php
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
diff --git a/model/comment.class.php b/model/comment.class.php
index dbfa17e..7baa082 100644
--- a/model/comment.class.php
+++ b/model/comment.class.php
@@ -606,13 +606,7 @@ class pdfannotator_comment {
                 . "JOIN (SELECT * FROM {pdfannotator_annotations} WHERE pdfannotatorid = :docid) a "
                 . "ON a.id = c.annotationid WHERE isquestion = 1";
         $questions = $DB->get_records_sql($sql, array('docid' => $documentid));
-//        if (!has_capability('mod/pdfannotator:seehiddencomments', $context)) {
-//            foreach ($questions as $question) {
-//                if ($question->ishidden == 1) {
-//                    $question->content = '<em>' . get_string('hiddenComment', 'pdfannotator') . '</em>';
-//                }
-//            }
-//        }
+
         $ret = [];
         foreach ($questions as $question) {
             $ret[$question->page][] = $question;
@@ -630,7 +624,7 @@ class pdfannotator_comment {
         global $DB;
         $ret = [];
         $i = 0;
-//        $displayhidden = has_capability('mod/pdfannotator:seehiddencomments', $context);
+        $displayhidden = has_capability('mod/pdfannotator:seehiddencomments', $context);
         $sql = "SELECT c.*, a.page FROM {pdfannotator_comments} c "
                 . "JOIN {pdfannotator_annotations} a ON a.id = c.annotationid "
                 . "WHERE isquestion = 1 AND c.pdfannotatorid = :docid AND "
@@ -649,9 +643,9 @@ class pdfannotator_comment {
             if ($question->isdeleted == 1) {
                 $question->content = '<em>'.get_string('deletedComment', 'pdfannotator').'</em>';
             }
-//            if ($question->ishidden == 1 && !$displayhidden) {
-//                $question->content = get_string('hiddenComment', 'pdfannotator');
-//            }
+            if ($question->ishidden == 1 && !$displayhidden) {
+                $question->content = get_string('hiddenComment', 'pdfannotator');
+            }
             $ret[$i] = $question;   // Without this array the order by page would get lost, because js sorts by id.
             $i++;
         }
-- 
GitLab