From cf61b081c0efc5f30b9f499d1c12fdeeb251a824 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Mon, 10 Aug 2020 16:12:57 +0100 Subject: [PATCH] [WIP] Subscription management (#63) * Basic UI @luketainton please edit lines 120-140 on the editsub and managesub files * :sparkles: Add subscription management Signed-off-by: Luke Tainton * :sparkles: Add subscription management Signed-off-by: Luke Tainton * :bug: Fix incorrect POST variable and add foreach() Signed-off-by: Luke Tainton * :art: Fix file names and add link on view.php Signed-off-by: Luke Tainton Co-authored-by: Alexander Davis --- app/includes/app_functions.php | 13 +++ app/public/actions/addsub.php | 30 +++++++ app/public/actions/delsub.php | 32 +++++++ app/public/editsub.php | 159 +++++++++++++++++++++++++++++++++ app/public/editsub.php.old | 154 +++++++++++++++++++++++++++++++ app/public/view.php | 5 +- 6 files changed, 391 insertions(+), 2 deletions(-) create mode 100644 app/public/actions/addsub.php create mode 100644 app/public/actions/delsub.php create mode 100644 app/public/editsub.php create mode 100644 app/public/editsub.php.old diff --git a/app/includes/app_functions.php b/app/includes/app_functions.php index 4011194..6d7bf28 100644 --- a/app/includes/app_functions.php +++ b/app/includes/app_functions.php @@ -1,4 +1,17 @@ prepare($stmt); + $sql->execute(); + $sql->setFetchMode(PDO::FETCH_ASSOC); + $result = $sql->fetchAll(); + } catch (PDOException $e) { + echo("Error: " . $e->getMessage()); + } + return $result; + } + function get_user_name($db, $user_uuid) { try { $stmt = "SELECT given_name, family_name FROM users WHERE uuid=:uuid"; diff --git a/app/public/actions/addsub.php b/app/public/actions/addsub.php new file mode 100644 index 0000000..6a18db0 --- /dev/null +++ b/app/public/actions/addsub.php @@ -0,0 +1,30 @@ +prepare($stmt); + $sql->bindParam(':tktuuid', $request['uuid']); + $sql->bindParam(':usruuid', $POST['addSubSelector']); + $sql->execute(); + } catch (PDOException $e) { + $alert = array("danger", "Failed to add subscriber: " . $e->getMessage()); + } + } + $newURL = "/managesub?rid=" . $request['uuid']; + echo(""); + } else { + $alert = array("danger", "You are not authorised to manage subscribers on this request."); + $newURL = "/managesub?rid=" . $request['uuid']; + echo(""); + } + +?> diff --git a/app/public/actions/delsub.php b/app/public/actions/delsub.php new file mode 100644 index 0000000..917e59a --- /dev/null +++ b/app/public/actions/delsub.php @@ -0,0 +1,32 @@ +prepare($stmt); + $sql->bindParam(':tktuuid', $request['uuid']); + $sql->bindParam(':usruuid', $sub); + $sql->execute(); + } catch (PDOException $e) { + $alert = array("danger", "Failed to remove subscriber(s): " . $e->getMessage()); + } + } + } + $newURL = "/managesub?rid=" . $request['uuid']; + echo(""); + } else { + $alert = array("danger", "You are not authorised to manage subscribers on this request."); + $newURL = "/managesub?rid=" . $request['uuid']; + echo(""); + } + +?> diff --git a/app/public/editsub.php b/app/public/editsub.php new file mode 100644 index 0000000..e403603 --- /dev/null +++ b/app/public/editsub.php @@ -0,0 +1,159 @@ + + + + + +
+ + +
+
+ +
+
+ +
+
+

+

+

+
+
+
+
+
+
+
+
+ Information +
+
    +
  • +
    +
    + Status: + +
    +
    +
  • +
  • +
    +
    + Created by: + +
    +
    +
  • +
  • +
    +
    + Assigned to: + " . get_user_name($db, $request['assignee']) . ""); + } else { + echo("None"); + } ?> +
    +
    +
  • +
  • +
    +
    + Created: + +
    +
    +
  • +
  • +
    +
    + Last updated: + +
    +
    +
  • +
+
+
+ +
+
+
+ Manage Subscribers +
+
    +
  • +
    +
    +
    +
    + + + +
    + +
    +
    +
    +
  • +
  • +
    +
    +
    +
    + + + +
    + +
    +
    +
    +
  • +
+
+
+
+
+
+ + +
+
+

You are not authorised to see this page.

+
+
+ + +
+ + diff --git a/app/public/editsub.php.old b/app/public/editsub.php.old new file mode 100644 index 0000000..127379c --- /dev/null +++ b/app/public/editsub.php.old @@ -0,0 +1,154 @@ + + + + + +
+ + +
+
+ +
+
+ +
+
+

+

+

+
+
+
+
+
+
+
+
Information
+
    +
  • +
    +
    + Status: + +
    +
    +
  • +
  • +
    +
    + Created by: + +
    +
    +
  • +
  • +
    +
    + Assigned to: + " . get_user_name($db, $request['assignee']) . ""); + } else { + echo("None"); + } ?> +
    +
    +
  • +
  • +
    +
    + Created: + +
    +
    +
  • +
  • +
    +
    + Last updated: + +
    +
    +
  • +
+
+
+ +
+
+
Updates
+
    + No updates"); + } else { + foreach($updates as $update) { + ?> +
  • +
    +
    + +
    +
    + +
    +
    +
  • + +
+
+
+ +
+
+
+ +
+
+
+
+
+
Edit Subscriber
+
+
+ +
+
+ + + Cancel +
+
+
+
+
+
+
+ + +
+
+

You are not authorised to see this page.

+
+
+ + +
+ + diff --git a/app/public/view.php b/app/public/view.php index 65bb1e6..6d58f22 100644 --- a/app/public/view.php +++ b/app/public/view.php @@ -53,8 +53,9 @@

Update the request - Add attachment(s) - + Add attachment(s) + Manage subscribers +