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) {+ +