From 43a6a7f179e9ebb60d5ddf3f80a787d9b6eeb31f Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Wed, 13 Jun 2018 15:55:05 +0530 Subject: [PATCH 1/8] Backend for show deleted threads --- .../app/controllers/forum/ForumController.php | 22 +++++++++++++------ .../libraries/database/DatabaseQueries.php | 20 ++++++++++------- site/public/js/server.js | 9 +++++++- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index fe6d52e9b0..40692ad0e6 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -309,14 +309,14 @@ public function alterPost($modifyType){ } } - private function getSortedThreads($categories_ids){ + private function getSortedThreads($categories_ids, $max_thread, $show_deleted = false){ $current_user = $this->core->getUser()->getId(); if($this->isValidCategories($categories_ids)) { - $announce_threads = $this->core->getQueries()->loadAnnouncements($categories_ids); - $reg_threads = $this->core->getQueries()->loadThreads($categories_ids); + $announce_threads = $this->core->getQueries()->loadAnnouncements($categories_ids, $show_deleted); + $reg_threads = $this->core->getQueries()->loadThreads($categories_ids, $show_deleted); } else { - $announce_threads = $this->core->getQueries()->loadAnnouncementsWithoutCategory(); - $reg_threads = $this->core->getQueries()->loadThreadsWithoutCategory(); + $announce_threads = $this->core->getQueries()->loadAnnouncementsWithoutCategory($show_deleted); + $reg_threads = $this->core->getQueries()->loadThreadsWithoutCategory($show_deleted); } $favorite_threads = $this->core->getQueries()->loadPinnedThreads($current_user); @@ -358,12 +358,16 @@ private function getSortedThreads($categories_ids){ public function getThreads(){ + $show_deleted = false; + if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_REQUEST["show_deleted"]) == 1) { + $show_deleted = true; + } $categories_ids = array_key_exists('thread_categories', $_POST) && !empty($_POST["thread_categories"]) ? explode("|", $_POST['thread_categories']) : array(); foreach ($categories_ids as &$id) { $id = (int)$id; } $max_thread = 0; - $threads = $this->getSortedThreads($categories_ids, $max_thread); + $threads = $this->getSortedThreads($categories_ids, $max_thread, $show_deleted); $currentCategoriesIds = array_key_exists('currentCategoriesId', $_POST) ? explode("|", $_POST["currentCategoriesId"]) : array(); $currentThreadId = array_key_exists('currentThreadId', $_POST) && !empty($_POST["currentThreadId"]) && is_numeric($_POST["currentThreadId"]) ? (int)$_POST["currentThreadId"] : -1; @@ -382,7 +386,11 @@ public function showThreads(){ $category_id = in_array('thread_category', $_POST) ? $_POST['thread_category'] : -1; $max_thread = 0; - $threads = $this->getSortedThreads(array($category_id), $max_thread); + $show_deleted = false; + if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_REQUEST["show_deleted"]) == 1) { + $show_deleted = true; + } + $threads = $this->getSortedThreads(array($category_id), $max_thread, $show_deleted); $current_user = $this->core->getUser()->getId(); diff --git a/site/app/libraries/database/DatabaseQueries.php b/site/app/libraries/database/DatabaseQueries.php index 03012d50e1..1086344221 100644 --- a/site/app/libraries/database/DatabaseQueries.php +++ b/site/app/libraries/database/DatabaseQueries.php @@ -107,31 +107,35 @@ public function insertSubmittyUser(User $user) { throw new NotImplementedException(); } - public function loadAnnouncements($categories_ids){ + public function loadAnnouncements($categories_ids, $show_deleted = false){ assert(count($categories_ids) > 0); $query_multiple_qmarks = "?".str_repeat(",?", count($categories_ids)-1); $query_parameters = array_merge( array(count($categories_ids)), $categories_ids ); + $query_delete = $show_deleted?"true":"deleted = false"; - $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE deleted = false and pinned = true and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id HAVING ? = (SELECT count(*) FROM thread_categories tc WHERE tc.thread_id = t.id and category_id IN (".$query_multiple_qmarks.")) ORDER BY t.id DESC", $query_parameters); + $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE {$query_delete} and pinned = true and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id HAVING ? = (SELECT count(*) FROM thread_categories tc WHERE tc.thread_id = t.id and category_id IN (".$query_multiple_qmarks.")) ORDER BY t.id DESC", $query_parameters); return $this->course_db->rows(); } - public function loadAnnouncementsWithoutCategory(){ - $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE deleted = false and pinned = true and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id ORDER BY t.id DESC"); + public function loadAnnouncementsWithoutCategory($show_deleted = false){ + $query_delete = $show_deleted?"true":"deleted = false"; + $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE {$query_delete} and pinned = true and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id ORDER BY t.id DESC"); return $this->course_db->rows(); } - public function loadThreadsWithoutCategory(){ - $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE deleted = false and pinned = false and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id ORDER BY t.id DESC"); + public function loadThreadsWithoutCategory($show_deleted = false){ + $query_delete = $show_deleted?"true":"deleted = false"; + $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE {$query_delete} and pinned = false and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id ORDER BY t.id DESC"); return $this->course_db->rows(); } - public function loadThreads($categories_ids) { + public function loadThreads($categories_ids, $show_deleted = false) { assert(count($categories_ids) > 0); $query_multiple_qmarks = "?".str_repeat(",?", count($categories_ids)-1); $query_parameters = array_merge( array(count($categories_ids)), $categories_ids ); + $query_delete = $show_deleted?"true":"deleted = false"; - $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE deleted = false and pinned = false and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id HAVING ? = (SELECT count(*) FROM thread_categories tc WHERE tc.thread_id = t.id and category_id IN (".$query_multiple_qmarks.")) ORDER BY t.id DESC", $query_parameters); + $this->course_db->query("SELECT t.*, array_to_string(array_agg(e.category_id),'|') as categories_ids, array_to_string(array_agg(w.category_desc),'|') as categories_desc FROM threads t, thread_categories e, categories_list w WHERE {$query_delete} and pinned = false and t.id = e.thread_id and e.category_id = w.category_id GROUP BY t.id HAVING ? = (SELECT count(*) FROM thread_categories tc WHERE tc.thread_id = t.id and category_id IN (".$query_multiple_qmarks.")) ORDER BY t.id DESC", $query_parameters); return $this->course_db->rows(); } diff --git a/site/public/js/server.js b/site/public/js/server.js index 2551ca4a0a..851dc3e9af 100644 --- a/site/public/js/server.js +++ b/site/public/js/server.js @@ -1274,6 +1274,12 @@ function saveScrollLocationOnRefresh(id){ function modifyThreadList(currentThreadId, currentCategoriesId){ var categories_value = $("#thread_category").val(); + var match_show_deleted = RegExp('[?&]show_deleted=([^&]*)').exec(window.location.search); + var show_deleted = 0; + if(match_show_deleted && match_show_deleted[1] == 1) { + show_deleted = 1; + } + categories_value = (categories_value == null)?"":categories_value.join("|"); var url = buildUrl({'component': 'forum', 'page': 'get_threads'}); $.ajax({ @@ -1282,7 +1288,8 @@ function modifyThreadList(currentThreadId, currentCategoriesId){ data: { thread_categories: categories_value, currentThreadId: currentThreadId, - currentCategoriesId: currentCategoriesId + currentCategoriesId: currentCategoriesId, + show_deleted: show_deleted }, success: function(r){ var x = JSON.parse(r).html; From c3466737e720ba5783e99888312821f22aece434 Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Sat, 16 Jun 2018 15:32:47 +0530 Subject: [PATCH 2/8] Show deleted threads frontend --- site/app/controllers/forum/ForumController.php | 10 +++++----- site/app/libraries/Core.php | 6 ++++++ site/app/libraries/database/DatabaseQueries.php | 9 +++++---- site/app/views/forum/ForumThreadView.php | 17 +++++++++++++++++ site/public/css/server.css | 8 ++++++++ site/public/js/server.js | 3 +-- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index 40692ad0e6..e465c87c9f 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -359,7 +359,7 @@ private function getSortedThreads($categories_ids, $max_thread, $show_deleted = public function getThreads(){ $show_deleted = false; - if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_REQUEST["show_deleted"]) == 1) { + if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_GET["show_deleted"]) == 1) { $show_deleted = true; } $categories_ids = array_key_exists('thread_categories', $_POST) && !empty($_POST["thread_categories"]) ? explode("|", $_POST['thread_categories']) : array(); @@ -387,7 +387,7 @@ public function showThreads(){ $max_thread = 0; $show_deleted = false; - if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_REQUEST["show_deleted"]) == 1) { + if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_GET["show_deleted"]) == 1) { $show_deleted = true; } $threads = $this->getSortedThreads(array($category_id), $max_thread, $show_deleted); @@ -402,15 +402,15 @@ public function showThreads(){ if(!empty($_REQUEST["thread_id"])){ $thread_id = (int)$_REQUEST["thread_id"]; if($option == "alpha"){ - $posts = $this->core->getQueries()->getPostsForThread($current_user, $thread_id, 'alpha'); + $posts = $this->core->getQueries()->getPostsForThread($current_user, $thread_id, $show_deleted, 'alpha'); } else { - $posts = $this->core->getQueries()->getPostsForThread($current_user, $thread_id, 'tree'); + $posts = $this->core->getQueries()->getPostsForThread($current_user, $thread_id, $show_deleted, 'tree'); } } if(empty($_REQUEST["thread_id"]) || empty($posts)) { - $posts = $this->core->getQueries()->getPostsForThread($current_user, -1); + $posts = $this->core->getQueries()->getPostsForThread($current_user, -1, $show_deleted); } $this->core->getOutput()->renderOutput('forum\ForumThread', 'showForumThreads', $user, $posts, $threads, $option, $max_thread); diff --git a/site/app/libraries/Core.php b/site/app/libraries/Core.php index eb3eee2959..b95b1f7284 100644 --- a/site/app/libraries/Core.php +++ b/site/app/libraries/Core.php @@ -351,6 +351,12 @@ public function checkCsrfToken($csrf_token=null) { * @return string */ public function buildUrl($parts=array(), $hash = null) { + $persistent_request = array("show_deleted"); + foreach ($persistent_request as $request) { + if(isset($_GET[$request])) { + $parts[$request] = $_GET[$request]; + } + } $url = $this->getConfig()->getSiteUrl().((count($parts) > 0) ? "&".http_build_query($parts) : ""); if ($hash !== null) { $url .= "#".$hash; diff --git a/site/app/libraries/database/DatabaseQueries.php b/site/app/libraries/database/DatabaseQueries.php index 1086344221..fea8a4b460 100644 --- a/site/app/libraries/database/DatabaseQueries.php +++ b/site/app/libraries/database/DatabaseQueries.php @@ -2119,20 +2119,21 @@ public function getCategories(){ return $this->course_db->rows(); } - public function getPostsForThread($current_user, $thread_id, $option = "tree"){ + public function getPostsForThread($current_user, $thread_id, $show_deleted = false, $option = "tree"){ + $query_delete = $show_deleted?"true":"deleted = false"; if($thread_id == -1) { $announcement_id = $this->existsAnnouncements(); if($announcement_id == -1){ - $this->course_db->query("SELECT MAX(id) as max from threads WHERE deleted = false and pinned = false"); + $this->course_db->query("SELECT MAX(id) as max from threads WHERE {$query_delete} and pinned = false"); $thread_id = $this->course_db->rows()[0]["max"]; } else { $thread_id = $announcement_id; } } if($option == 'alpha'){ - $this->course_db->query("SELECT posts.*, users.user_lastname FROM posts INNER JOIN users ON posts.author_user_id=users.user_id WHERE thread_id=? AND deleted = false ORDER BY user_lastname, posts.timestamp;", array($thread_id)); + $this->course_db->query("SELECT posts.*, users.user_lastname FROM posts INNER JOIN users ON posts.author_user_id=users.user_id WHERE thread_id=? AND {$query_delete} ORDER BY user_lastname, posts.timestamp;", array($thread_id)); } else { - $this->course_db->query("SELECT * FROM posts WHERE thread_id=? AND deleted = false ORDER BY timestamp ASC", array($thread_id)); + $this->course_db->query("SELECT * FROM posts WHERE thread_id=? AND {$query_delete} ORDER BY timestamp ASC", array($thread_id)); } $result_rows = $this->course_db->rows(); diff --git a/site/app/views/forum/ForumThreadView.php b/site/app/views/forum/ForumThreadView.php index 577f113a12..212bd6fb01 100644 --- a/site/app/views/forum/ForumThreadView.php +++ b/site/app/views/forum/ForumThreadView.php @@ -230,7 +230,21 @@ function changeName(element, user, visible_username, anon){ if($this->core->getUser()->getGroup() <= 2){ $return .= << Stats + HTML; } $categories = $this->core->getQueries()->getCategories(); @@ -551,6 +565,9 @@ public function displayThreadList($threads, $filtering, &$activeThreadAnnounceme if($this->core->getQueries()->viewedThread($current_user, $thread["id"])){ $class .= " viewed"; } + if($thread["deleted"]) { + $class .= " deleted"; + } //fix legacy code $titleDisplay = html_entity_decode($thread['title'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); diff --git a/site/public/css/server.css b/site/public/css/server.css index 404ca9e2f3..b712e8696d 100755 --- a/site/public/css/server.css +++ b/site/public/css/server.css @@ -577,6 +577,14 @@ table tr.table-header { background-color: #21C2F6; } +.deleted { + background-color: #FFCCCC; +} + +.deleted.active { + background-color: #FF9999; +} + .important { /* THIS IS WHERE THE BACKGROUND COLOR FOR POSTS IS */ border-style: solid; diff --git a/site/public/js/server.js b/site/public/js/server.js index 851dc3e9af..ebbc022d7a 100644 --- a/site/public/js/server.js +++ b/site/public/js/server.js @@ -1281,7 +1281,7 @@ function modifyThreadList(currentThreadId, currentCategoriesId){ } categories_value = (categories_value == null)?"":categories_value.join("|"); - var url = buildUrl({'component': 'forum', 'page': 'get_threads'}); + var url = buildUrl({'component': 'forum', 'page': 'get_threads', 'show_deleted': show_deleted}); $.ajax({ url: url, type: "POST", @@ -1289,7 +1289,6 @@ function modifyThreadList(currentThreadId, currentCategoriesId){ thread_categories: categories_value, currentThreadId: currentThreadId, currentCategoriesId: currentCategoriesId, - show_deleted: show_deleted }, success: function(r){ var x = JSON.parse(r).html; From 360b3741437342c311ef3095056ec0f2d10c80e7 Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Sat, 16 Jun 2018 16:44:54 +0530 Subject: [PATCH 3/8] Bug Fix + Added class for button --- .../app/controllers/forum/ForumController.php | 2 +- site/app/libraries/Core.php | 2 +- site/app/views/forum/ForumThreadView.php | 24 +++++++------------ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index e465c87c9f..9beec1bfef 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -413,7 +413,7 @@ public function showThreads(){ $posts = $this->core->getQueries()->getPostsForThread($current_user, -1, $show_deleted); } - $this->core->getOutput()->renderOutput('forum\ForumThread', 'showForumThreads', $user, $posts, $threads, $option, $max_thread); + $this->core->getOutput()->renderOutput('forum\ForumThread', 'showForumThreads', $user, $posts, $threads, $show_deleted, $option, $max_thread); } public function showCreateThread(){ diff --git a/site/app/libraries/Core.php b/site/app/libraries/Core.php index b95b1f7284..e817e36712 100644 --- a/site/app/libraries/Core.php +++ b/site/app/libraries/Core.php @@ -353,7 +353,7 @@ public function checkCsrfToken($csrf_token=null) { public function buildUrl($parts=array(), $hash = null) { $persistent_request = array("show_deleted"); foreach ($persistent_request as $request) { - if(isset($_GET[$request])) { + if(isset($_GET[$request]) && !array_key_exists($request, $parts)) { $parts[$request] = $_GET[$request]; } } diff --git a/site/app/views/forum/ForumThreadView.php b/site/app/views/forum/ForumThreadView.php index 212bd6fb01..55c3ab98c9 100644 --- a/site/app/views/forum/ForumThreadView.php +++ b/site/app/views/forum/ForumThreadView.php @@ -144,7 +144,7 @@ public function searchResult($threads){ for a specific thread, in addition to all of the threads that have been created to be displayed in the left panel. */ - public function showForumThreads($user, $posts, $threads, $display_option, $max_thread) { + public function showForumThreads($user, $posts, $threads, $show_deleted, $display_option, $max_thread) { if(!$this->forumAccess()){ $this->core->redirect($this->core->buildUrl(array('component' => 'navigation'))); return; @@ -228,23 +228,15 @@ function changeName(element, user, visible_username, anon){ Create Thread HTML; if($this->core->getUser()->getGroup() <= 2){ - + if($show_deleted) { + $show_deleted_class = "active"; + } else { + $show_deleted_class = ""; + } + $show_deleted_url = $this->core->buildUrl(array('component' => 'forum', 'page' => 'view_thread', 'show_deleted' => ($show_deleted?"0":"1"))); $return .= << + Stats - HTML; } $categories = $this->core->getQueries()->getCategories(); From b2775631003838cb18790b5008fc5293e34df43e Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Mon, 18 Jun 2018 20:13:47 +0530 Subject: [PATCH 4/8] show_deleted in SESSION --- .../app/controllers/forum/ForumController.php | 20 ++++++++++++------- site/app/libraries/Core.php | 6 ------ site/app/views/forum/ForumThreadView.php | 3 +++ site/public/css/server.css | 2 +- site/public/js/server.js | 8 +------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index 9beec1bfef..e75bcde5ac 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -79,6 +79,15 @@ public function run() { } } + private function showDeleted() { + return ($this->core->getUser()->getGroup() <= 2 && isset($_SESSION['show_deleted']) && $_SESSION['show_deleted'] === true); + } + + private function updateShowDeleted($show_deleted) { + if($this->core->getUser()->getGroup() <= 2) { + $_SESSION['show_deleted'] = $show_deleted; + } + } private function returnUserContentToPage($error, $isThread, $thread_id){ //Notify User @@ -358,10 +367,7 @@ private function getSortedThreads($categories_ids, $max_thread, $show_deleted = public function getThreads(){ - $show_deleted = false; - if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_GET["show_deleted"]) == 1) { - $show_deleted = true; - } + $show_deleted = $this->showDeleted(); $categories_ids = array_key_exists('thread_categories', $_POST) && !empty($_POST["thread_categories"]) ? explode("|", $_POST['thread_categories']) : array(); foreach ($categories_ids as &$id) { $id = (int)$id; @@ -386,10 +392,10 @@ public function showThreads(){ $category_id = in_array('thread_category', $_POST) ? $_POST['thread_category'] : -1; $max_thread = 0; - $show_deleted = false; - if($this->core->getUser()->getGroup() <= 2 && array_key_exists('show_deleted', $_REQUEST) && ((int)$_GET["show_deleted"]) == 1) { - $show_deleted = true; + if(array_key_exists('show_deleted', $_REQUEST)) { + $this->updateShowDeleted(((int)$_GET["show_deleted"]) == 1); } + $show_deleted = $this->showDeleted(); $threads = $this->getSortedThreads(array($category_id), $max_thread, $show_deleted); $current_user = $this->core->getUser()->getId(); diff --git a/site/app/libraries/Core.php b/site/app/libraries/Core.php index e817e36712..eb3eee2959 100644 --- a/site/app/libraries/Core.php +++ b/site/app/libraries/Core.php @@ -351,12 +351,6 @@ public function checkCsrfToken($csrf_token=null) { * @return string */ public function buildUrl($parts=array(), $hash = null) { - $persistent_request = array("show_deleted"); - foreach ($persistent_request as $request) { - if(isset($_GET[$request]) && !array_key_exists($request, $parts)) { - $parts[$request] = $_GET[$request]; - } - } $url = $this->getConfig()->getSiteUrl().((count($parts) > 0) ? "&".http_build_query($parts) : ""); if ($hash !== null) { $url .= "#".$hash; diff --git a/site/app/views/forum/ForumThreadView.php b/site/app/views/forum/ForumThreadView.php index 55c3ab98c9..21d0d7c0b1 100644 --- a/site/app/views/forum/ForumThreadView.php +++ b/site/app/views/forum/ForumThreadView.php @@ -657,6 +657,9 @@ public function createPost($thread_id, $post, $function_date, $title_html, $firs if($this->core->getQueries()->isStaffPost($post["author_user_id"])){ $classes .= " important"; } + if($post["deleted"]) { + $classes .= " deleted"; + } $offset = min(($reply_level - 1) * 30, 180); $return = << Date: Mon, 18 Jun 2018 23:48:33 +0530 Subject: [PATCH 5/8] UI view update --- site/app/views/forum/ForumThreadView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/app/views/forum/ForumThreadView.php b/site/app/views/forum/ForumThreadView.php index 21d0d7c0b1..563b836702 100644 --- a/site/app/views/forum/ForumThreadView.php +++ b/site/app/views/forum/ForumThreadView.php @@ -235,7 +235,7 @@ function changeName(element, user, visible_username, anon){ } $show_deleted_url = $this->core->buildUrl(array('component' => 'forum', 'page' => 'view_thread', 'show_deleted' => ($show_deleted?"0":"1"))); $return .= << + Show Deleted Threads Stats HTML; } @@ -757,7 +757,7 @@ public function createPost($thread_id, $post, $function_date, $title_html, $firs if($this->core->getUser()->getGroup() <= 2){ $wrapped_content = json_encode($post['content']); $return .= << + HTML; } From aa0f095c81e07251c5278b6a4f6f586e3e155de0 Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Tue, 19 Jun 2018 15:42:59 +0530 Subject: [PATCH 6/8] Using COOKIES for show_deleted status --- site/app/controllers/forum/ForumController.php | 11 +---------- site/app/views/forum/ForumThreadView.php | 5 +++-- site/public/js/server.js | 5 +++++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index e75bcde5ac..7687aff70d 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -80,13 +80,7 @@ public function run() { } private function showDeleted() { - return ($this->core->getUser()->getGroup() <= 2 && isset($_SESSION['show_deleted']) && $_SESSION['show_deleted'] === true); - } - - private function updateShowDeleted($show_deleted) { - if($this->core->getUser()->getGroup() <= 2) { - $_SESSION['show_deleted'] = $show_deleted; - } + return ($this->core->getUser()->getGroup() <= 2 && isset($_COOKIE['show_deleted']) && $_COOKIE['show_deleted'] == "1"); } private function returnUserContentToPage($error, $isThread, $thread_id){ @@ -392,9 +386,6 @@ public function showThreads(){ $category_id = in_array('thread_category', $_POST) ? $_POST['thread_category'] : -1; $max_thread = 0; - if(array_key_exists('show_deleted', $_REQUEST)) { - $this->updateShowDeleted(((int)$_GET["show_deleted"]) == 1); - } $show_deleted = $this->showDeleted(); $threads = $this->getSortedThreads(array($category_id), $max_thread, $show_deleted); diff --git a/site/app/views/forum/ForumThreadView.php b/site/app/views/forum/ForumThreadView.php index 563b836702..9422b903a1 100644 --- a/site/app/views/forum/ForumThreadView.php +++ b/site/app/views/forum/ForumThreadView.php @@ -230,12 +230,13 @@ function changeName(element, user, visible_username, anon){ if($this->core->getUser()->getGroup() <= 2){ if($show_deleted) { $show_deleted_class = "active"; + $show_deleted_action = "alterShowDeletedStatus(0);"; } else { $show_deleted_class = ""; + $show_deleted_action = "alterShowDeletedStatus(1);"; } - $show_deleted_url = $this->core->buildUrl(array('component' => 'forum', 'page' => 'view_thread', 'show_deleted' => ($show_deleted?"0":"1"))); $return .= <<Show Deleted Threads + Show Deleted Threads Stats HTML; } diff --git a/site/public/js/server.js b/site/public/js/server.js index c2c449a7df..6d54841661 100644 --- a/site/public/js/server.js +++ b/site/public/js/server.js @@ -1608,6 +1608,11 @@ function saveScrollLocationOnRefresh(id){ }); } +function alterShowDeletedStatus(newStatus) { + document.cookie = "show_deleted=" + newStatus + "; path=/;"; + location.reload(); +} + function modifyThreadList(currentThreadId, currentCategoriesId){ var categories_value = $("#thread_category").val(); categories_value = (categories_value == null)?"":categories_value.join("|"); From 27ee04d693d31c5bf9fa06785808acae5573e750 Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Thu, 21 Jun 2018 10:43:08 +0530 Subject: [PATCH 7/8] Fixed Bug from Merge Conflict --- site/app/controllers/forum/ForumController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/app/controllers/forum/ForumController.php b/site/app/controllers/forum/ForumController.php index 01feb5539e..b4ca1f44c2 100644 --- a/site/app/controllers/forum/ForumController.php +++ b/site/app/controllers/forum/ForumController.php @@ -473,7 +473,7 @@ private function editPost(){ return null; } - private function getSortedThreads($categories_ids, $show_deleted = false){ + private function getSortedThreads($categories_ids, $max_thread, $show_deleted = false){ $current_user = $this->core->getUser()->getId(); if($this->isValidCategories($categories_ids)) { $announce_threads = $this->core->getQueries()->loadAnnouncements($categories_ids, $show_deleted); From 6bba965c9a9bfa5a3eb1da5caff75109e0bcb169 Mon Sep 17 00:00:00 2001 From: Gagan Kumar Date: Thu, 21 Jun 2018 10:46:51 +0530 Subject: [PATCH 8/8] CSS Bug Fix --- site/public/css/server.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/public/css/server.css b/site/public/css/server.css index 32f9723b7e..aaecaafe48 100644 --- a/site/public/css/server.css +++ b/site/public/css/server.css @@ -582,7 +582,7 @@ table tr.table-header { } .deleted.active { - background-color: #FF9999; + background-color: #FF9999 !important; } .important {