From 37355bf007720e60b2432a86a0be522862bb46c7 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Mon, 10 Aug 2020 14:58:56 +0100 Subject: [PATCH 1/3] :bug: Explicitly set ticket status to 'New' (#60) Signed-off-by: Luke Tainton --- app/public/actions/create.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/public/actions/create.php b/app/public/actions/create.php index 7c8d339..db8ec51 100644 --- a/app/public/actions/create.php +++ b/app/public/actions/create.php @@ -7,15 +7,15 @@ try { // Process ticket data $tkt_uuid = Uuid::uuid4()->toString(); - $stmt = "INSERT INTO tickets (uuid, title, description, created_by) VALUES (:tktuuid, :title, :description, :user)"; + $stmt = "INSERT INTO tickets (uuid, title, description, status, created_by) VALUES (:tktuuid, :title, :description, :status, :user)"; $sql = $db->prepare($stmt); $sql->bindParam(':tktuuid', $tkt_uuid); $sql->bindParam(':title', $_POST['title']); $sql->bindParam(':description', $_POST['description']); + $sql->bindParam(':status', 'New'); $sql->bindParam(':user', $_SESSION['uuid']); $sql->execute(); } catch (PDOException $e) { - // echo("Error:
" . $e->getMessage() . "
"); $alert = array("danger", "Failed to create request: " . $e->getMessage()); } @@ -39,7 +39,7 @@ $alert = array("danger", "Failed to upload file: " . $e->getMessage()); } } - + $newURL = "/view?rid=" . $tkt_uuid; echo(""); } From d7f9678fd6eddc67bd645ca32ca7e3aa3b2423ff Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Mon, 10 Aug 2020 15:03:35 +0100 Subject: [PATCH 2/3] :bug: Fix bindParam() issue Signed-off-by: Luke Tainton --- app/public/actions/create.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/public/actions/create.php b/app/public/actions/create.php index db8ec51..f6779eb 100644 --- a/app/public/actions/create.php +++ b/app/public/actions/create.php @@ -7,12 +7,11 @@ try { // Process ticket data $tkt_uuid = Uuid::uuid4()->toString(); - $stmt = "INSERT INTO tickets (uuid, title, description, status, created_by) VALUES (:tktuuid, :title, :description, :status, :user)"; + $stmt = "INSERT INTO tickets (uuid, title, description, status, created_by) VALUES (:tktuuid, :title, :description, 'New', :user)"; $sql = $db->prepare($stmt); $sql->bindParam(':tktuuid', $tkt_uuid); $sql->bindParam(':title', $_POST['title']); $sql->bindParam(':description', $_POST['description']); - $sql->bindParam(':status', 'New'); $sql->bindParam(':user', $_SESSION['uuid']); $sql->execute(); } catch (PDOException $e) { From b89cf56ce962a081b0ad6fbefae41ac34f530da0 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Mon, 10 Aug 2020 15:24:29 +0100 Subject: [PATCH 3/3] :bug: Fix request closure problem (#62) Signed-off-by: Luke Tainton --- app/public/actions/close.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/public/actions/close.php b/app/public/actions/close.php index 318e004..eb71ade 100644 --- a/app/public/actions/close.php +++ b/app/public/actions/close.php @@ -8,18 +8,16 @@ // Close request if ($is_authorised == true) { - if($_SERVER['REQUEST_METHOD'] == 'POST') { - try { - $stmt = "UPDATE tickets SET status='Closed' WHERE uuid=:uuid"; - $sql = $db->prepare($stmt); - $sql->bindParam(':uuid', $_GET['rid']); - $sql->execute(); - } catch (PDOException $e) { - $alert = array("danger", "Failed to close request: " . $e->getMessage()); - } - } - $newURL = "/"; - echo(""); + try { + $stmt = "UPDATE tickets SET status='Closed' WHERE uuid=:uuid"; + $sql = $db->prepare($stmt); + $sql->bindParam(':uuid', $_GET['rid']); + $sql->execute(); + } catch (PDOException $e) { + $alert = array("danger", "Failed to close request: " . $e->getMessage()); + } + $newURL = "/"; + echo(""); } else { $alert = array("danger", "You are not authorised to close this request."); $newURL = "/view?rid=" . $request['uuid'];