diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index e684714..85921b7 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -13,7 +13,7 @@ height: auto; } -.admin-actions { +.admin-batchactions, .admin-groupbatchactions { display: inline-block; padding: 8px; vertical-align: top; diff --git a/website/queries/group_page.php b/website/queries/group_page.php index c6db01b..e0c8f17 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -94,6 +94,22 @@ function changeGroupStatusByID($db, $id, $status) { } +function changeMultipleGroupStatusByID($db, $ids, $status) { + $q = $db->prepare(" + UPDATE + `group_page` + SET + `status` = :status + WHERE + FIND_IN_SET (`groupID`, :ids) + "); + + $ids = implode(',', $ids); + $q->bindParam(':ids', $ids); + $q->bindParam(':status', $status); + $q->execute(); + return $q; +} ?> diff --git a/website/queries/user.php b/website/queries/user.php index bfd9579..d0d81bd 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -82,5 +82,21 @@ function changeUserStatusByID($db, $id, $status) { return $q; } +function changeMultipleUserStatusByID($db, $ids, $status) { + $q = $db->prepare(" + UPDATE + `user` + SET + `role` = :status + WHERE + FIND_IN_SET (`userID`, :ids) + "); + + $ids = implode(',', $ids); + $q->bindParam(':ids', $ids); + $q->bindParam(':status', $status); + $q->execute(); + return $q; +} ?> diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index ea9cea6..8b0990c 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -9,7 +9,7 @@ }; function checkAll(allbox) { - var checkboxes = document.getElementsByName('checkbox-user[]'); + var checkboxes = document.getElementsByClassName('checkbox-list'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox') { @@ -22,9 +22,15 @@ if (document.getElementById('group').checked) { document.getElementById('admin-filter').style.display = 'none'; document.getElementById('admin-groupfilter').style.display = 'inline-block'; + + document.getElementById('admin-batchactions').style.display = 'none'; + document.getElementById('admin-groupbatchactions').style.display = 'inline-block'; } else { document.getElementById('admin-filter').style.display = 'inline-block'; document.getElementById('admin-groupfilter').style.display = 'none'; + + document.getElementById('admin-batchactions').style.display = 'inline-block'; + document.getElementById('admin-groupbatchactions').style.display = 'none'; } } @@ -43,30 +49,40 @@ $listnr = 0; // TODO: add page functionality $status = $groupstatus = array(); $pagetype = "user"; -if (!empty($_GET["search"])) { +if (isset($_GET["search"])) { $search = test_input($_GET["search"]); } -if (!empty($_GET["pagetype"])) { +if (isset($_GET["pagetype"])) { $pagetype = test_input($_GET["pagetype"]); } -if (!empty($_GET["status"])) { +if (isset($_GET["status"])) { $status = $_GET["status"]; } -if (!empty($_GET["groupstatus"])) { +if (isset($_GET["groupstatus"])) { $groupstatus = $_GET["groupstatus"]; } if ($_SERVER["REQUEST_METHOD"] == "POST") { - if (!empty($_POST["actions"]) && !empty($_POST["userID"])) { + if (isset($_POST["actions"]) && isset($_POST["userID"])) { changeUserStatusByID($db, $_POST["userID"], $_POST["actions"]); - } elseif (!empty($_POST["actions"]) && !empty($_POST["groupID"])) { + } + + if (isset($_POST["actions"]) && isset($_POST["groupID"])) { changeGroupStatusByID($db, $_POST["groupID"], $_POST["actions"]); } + if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) { + changeMultipleUserStatusByID($db, $_POST["checkbox-user"], $_POST["batchactions"]); + } + + if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) { + changeMultipleGroupStatusByID($db, $_POST["checkbox-group"], $_POST["groupbatchactions"]); + } + } function test_input($data) { @@ -145,15 +161,36 @@ function test_input($data) { -
+

Batch Actions:

- -
- -
- -

- +
+ +
+ +
+ +

+ +
+
+ +
+

Batch Actions:

+
+ +
+ +
+ +

+ +

@@ -194,7 +231,9 @@ function test_input($data) { + class='checkbox-list' + value='$userID' + form='admin-batchform'> $username $role @@ -223,13 +262,15 @@ function test_input($data) { $name = $group['name']; $role = $group['status']; $description = $group['description']; - $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + $thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI'])); echo(" + class='checkbox-list' + value='$groupID' + form='admin-groupbatchform'> $name $role @@ -241,7 +282,7 @@ function test_input($data) { @@ -255,6 +296,7 @@ function test_input($data) {
+