_binary From 6fce64fadaaec8e4e29b32f20c8886402ff85538 Mon Sep 17 00:00:00 2001
From: Aniruddha Mallya <anirudh.mallya09@gmail.com>
Date: Thu, 3 Sep 2020 17:45:05 +0530
Subject: [PATCH] Comment deletion prompt on any thread, a=aniruddha

---
 src/views/elements/GroupfeedElement.php | 28 ++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/views/elements/GroupfeedElement.php b/src/views/elements/GroupfeedElement.php
index c572b1da..6641c390 100644
--- a/src/views/elements/GroupfeedElement.php
+++ b/src/views/elements/GroupfeedElement.php
@@ -185,7 +185,7 @@ class GroupfeedElement extends Element implements CrawlConstants
         $is_api = !empty($data['API']);
         $is_status = !empty($data['STATUS']);
         $open_in_tabs = $data['OPEN_IN_TABS'];
-        $time = time();
+        $time = time(); 
         $can_comment = [C\GROUP_READ_COMMENT, C\GROUP_READ_WRITE,
             C\GROUP_READ_WIKI];
         $start_thread = [C\GROUP_READ_WRITE, C\GROUP_READ_WIKI];
@@ -197,8 +197,22 @@ class GroupfeedElement extends Element implements CrawlConstants
         $token_string = ($logged_in) ? C\CSRF_TOKEN . "=".
             $data[C\CSRF_TOKEN] : "";
         $no_follow = ($token_string) ? " rel='nofollow' " : "";
-        $page = [];
-        $member_access = (!empty($data['WIKI_MEMBER_ACCESS'])) ?
+        $page = []; ?>
+        <script>
+            function confirmWithUser(clickedId){
+                var promptAns=confirm("<?=
+                    tl('comment_deletion_prompt') ?>"); 
+                var deleteURL = clickedId.replace(/&amp;/g, '&')
+                var currentURL = window.location.href
+                if(promptAns){
+                    window.setInterval(function(){
+                        window.location.href = currentURL
+                    },1000)
+                    window.location.href = deleteURL
+                }
+            }
+        </script><?php 
+            $member_access = (!empty($data['WIKI_MEMBER_ACCESS'])) ?
             $data['WIKI_MEMBER_ACCESS'] : (
             (empty($data['PAGES'][0]["MEMBER_ACCESS"])) ?
             C\NOT_MEMBER_STATUS : $data['PAGES'][0]["MEMBER_ACCESS"]);
@@ -215,7 +229,7 @@ class GroupfeedElement extends Element implements CrawlConstants
         $is_user = !empty($data['JUST_USER_ID']);
         $is_page_with_comments = ($data['ELEMENT'] == 'wiki');
         $is_all_feed = !$is_thread && !$is_group && !$is_page_with_comments &&
-            !$is_user;
+            !$is_user; 
         if ($is_all_feed && !$is_api && !$is_status) {?>
             <h2 class='feed-heading'><?=
             tl('groupfeed_element_combined_discussions') ?></h2><?php
@@ -345,9 +359,9 @@ class GroupfeedElement extends Element implements CrawlConstants
                 $delete_url = (empty($data['WIKI_FEED_BASE'])) ?
                     $paging_query : $data['WIKI_FEED_BASE'];
                 ?>
-                [<a href="<?= $delete_url .'&amp;arg=deletepost&amp;'.
-                    "post_id=" . $page['ID'] ?>" title="<?=
-                    tl('groupfeed_element_delete') ?>">X</a>]
+                
+                [<a href='#' id = "<?= $delete_url .'&amp;arg=deletepost&amp;'."post_id=" . $page['ID'] ?>" onclick='confirmWithUser(this.id)'>X</a>]
+                    
                 </div><?php
             }
             $title_class = "";
-- 
2.28.0.windows.1

