From a8e74347b80e3d3fcf9ef1d13ba2763748d6f8a9 Mon Sep 17 00:00:00 2001
From: Friederike Schwager <schwager@cil.rwth-aachen.de>
Date: Mon, 27 May 2019 12:26:36 +0200
Subject: [PATCH] clean-up comment.php, fix dropdown for deleted comments

---
 model/comment.class.php |  3 ++-
 shared/index.js         | 14 ++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/model/comment.class.php b/model/comment.class.php
index 077f453..dbfa17e 100644
--- a/model/comment.class.php
+++ b/model/comment.class.php
@@ -388,7 +388,8 @@ class pdfannotator_comment {
         $DB->delete_records('pdfannotator_votes', array("commentid" => $commentid));
 
         if ($success == 1) {
-            return ['status' => 'success', 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell, 'deleteannotation' => $deleteannotation];
+            return ['status' => 'success', 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell,
+                'deleteannotation' => $deleteannotation, 'isquestion' => $comment->isquestion];
         } else {
             return ['status' => 'error'];
         }
diff --git a/shared/index.js b/shared/index.js
index 0b96cd0..f57f89f 100644
--- a/shared/index.js
+++ b/shared/index.js
@@ -340,11 +340,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
                                     $('#comment_'+commentId+' .chat-message-meta .user').remove();
                                     $('#comment_'+commentId+' .countVotes').remove();
                                     $('#comment_'+commentId+' .comment-like-a').attr("disabled","disabled").css("visibility", "hidden");
-                                    $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-report-button').remove();
-                                    $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-delete-a').remove();
-                                    $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-edit-a').remove();
                                     $('#comment_'+commentId+' .edited').remove();
-                                }else{
+                                    if (data.isquestion == 0) {
+                                        $('#comment_'+commentId+' .dropdown').remove();
+                                    } else {
+                                        $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-report-button').remove();
+                                        $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-delete-a').remove();
+                                        $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-edit-a').remove();
+                                        $('#comment_'+commentId+' .chat-message-meta .dropdown .comment-forward-a').remove();
+                                        $('#comment_'+commentId+' .chat-message-meta .dropdown #hidebutton'+commentId).remove();
+                                    }
+                                } else {
                                     var parent = child.parentNode;
                                     parent.removeChild(child);
                                 }
-- 
GitLab