From 71dc7bae2cb0b137a72ae24019e02bc9f7bcea98 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Wed, 18 Jan 2017 15:19:07 +0100 Subject: [PATCH] add group search, add user individual actions --- website/public/styles/adminpanel.css | 4 + website/queries/group_page.php | 31 +++++++- website/queries/user.php | 13 ++++ website/views/adminpanel.php | 108 +++++++++++++++++++-------- 4 files changed, 124 insertions(+), 32 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index c8e29b6..d5b740e 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -58,6 +58,10 @@ float: right; } +.usertitle { + width: 150px; +} + .usertable { width: 100%; } diff --git a/website/queries/group_page.php b/website/queries/group_page.php index d8bab8f..8f04ca3 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -53,4 +53,33 @@ function select20GroupsByStatusFromN($db, $n, $status) { "); } -?> \ No newline at end of file +function search20GroupsFromNByStatus($db, $n, $keyword, $status) { + $q = $db->prepare(" + SELECT + `groupID`, + `name`, + `status`, + `description` + FROM + `group_page` + WHERE + `name` LIKE :keyword AND + FIND_IN_SET (`status`, :statuses) + ORDER BY + `name` + LIMIT + :n, 20 + "); + + $keyword = "%$keyword%"; + $q->bindParam(':keyword', $keyword); + $q->bindParam(':n', $n, PDO::PARAM_INT); + $statuses = implode(',', $status); + $q->bindParam(':statuses', $statuses); + $q->execute(); + return $q; +} + + + +?> diff --git a/website/queries/user.php b/website/queries/user.php index 42d90bc..de8c52b 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -68,5 +68,18 @@ function search20UsersFromNByStatus($db, $n, $keyword, $status) { return $q; } +function changeUserStatusByID($db, $id, $status) { + $q = $db->query(" + UPDATE + `user` + SET + `role` = $status + WHERE + `userID` = $id + "); + + return $q; +} + ?> diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 8ce9fb1..d478003 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -29,7 +29,10 @@ } - + @@ -57,6 +60,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $groupstatus = $_POST["groupstatus"]; } + if (!empty($_POST["actions"]) && !empty($_POST["userID"])) { + changeUserStatusByID($db, $_POST["userID"], $_POST["actions"]); + } } @@ -153,7 +159,7 @@ function test_input($data) {
-

Users:

+

Users:

@@ -174,44 +180,84 @@ function test_input($data) { fetch(PDO::FETCH_ASSOC)) { - $userID = $user['userID']; - $username = $user['username']; - $role = $user['role']; - $bancomment = $user['bancomment']; - $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + while($user = $q->fetch(PDO::FETCH_ASSOC)) { + $userID = $user['userID']; + $username = $user['username']; + $role = $user['role']; + $bancomment = $user['bancomment']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); - echo(" + echo(" - - - $username - $role - $bancomment - -
- - - -
- + + + $username + $role + $bancomment + +
+ + + +
+ - "); + "); + } + } else { + $q = search20GroupsFromNByStatus($db, $listnr, $search, $groupstatus); + + while ($group = $q->fetch(PDO::FETCH_ASSOC)) { + $groupID = $group['groupID']; + $name = $group['name']; + $role = $group['status']; + $description = $group['description']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + + echo(" + + + + $name + $role + $description + +
+ + + +
+ + + "); + } } ?>
+
+            
+