From a598e9d42e8de6871f4142980d301b71fe3e7fa4 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 24 Mar 2022 20:41:26 +0000 Subject: [PATCH 1/3] Remove non-existant delete query that prevents client being deleted properly on some installs --- post.php | 1 - 1 file changed, 1 deletion(-) diff --git a/post.php b/post.php index 771fa567..c9f6d151 100644 --- a/post.php +++ b/post.php @@ -1247,7 +1247,6 @@ if(isset($_GET['delete_client'])){ mysqli_query($mysqli,"DELETE FROM software WHERE software_client_id = $client_id"); mysqli_query($mysqli,"DELETE FROM vendors WHERE vendor_client_id = $client_id"); mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_id = $client_id"); - mysqli_query($mysqli,"DELETE FROM user_clients WHERE client_id = $client_id"); $sql = mysqli_query($mysqli,"SELECT recurring_id FROM recurring WHERE recurring_client_id = $client_id"); while($row = mysqli_fetch_array($sql)){ From fd589c53fae1bc4589da6ad26436ae6468c9e0f3 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 24 Mar 2022 20:45:58 +0000 Subject: [PATCH 2/3] Delete scheduled tickets when client is deleted --- post.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/post.php b/post.php index c9f6d151..1f710565 100644 --- a/post.php +++ b/post.php @@ -1247,8 +1247,9 @@ if(isset($_GET['delete_client'])){ mysqli_query($mysqli,"DELETE FROM software WHERE software_client_id = $client_id"); mysqli_query($mysqli,"DELETE FROM vendors WHERE vendor_client_id = $client_id"); mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_id = $client_id"); + mysqli_query($mysqli,"DELETE FROM scheduled_tickets WHERE scheduled_ticket_client_id = $client_id"); - $sql = mysqli_query($mysqli,"SELECT recurring_id FROM recurring WHERE recurring_client_id = $client_id"); + $sql = mysqli_query($mysqli,"SELECT recurring_id FROM recurring WHERE recurring_client_id = $client_id"); while($row = mysqli_fetch_array($sql)){ $recurring_id = $row['recurring_id']; From e4d2d0c699fb9d6b7ca8b82b1bf11872739ccc4b Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 24 Mar 2022 20:52:26 +0000 Subject: [PATCH 3/3] Prevent deletion of client unless user role is 3 (admin) --- post.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/post.php b/post.php index 1f710565..eff05994 100644 --- a/post.php +++ b/post.php @@ -1226,6 +1226,13 @@ if(isset($_POST['edit_client'])){ } if(isset($_GET['delete_client'])){ + if($session_user_role !== "3"){ + $_SESSION['alert_type'] = "danger"; + $_SESSION['alert_message'] = "You are not permitted to do that!"; + header("Location: " . $_SERVER["HTTP_REFERER"]); + exit(); + } + $client_id = intval($_GET['delete_client']); //Get Client Name