diff --git a/website/public/API/adminChangeUser.php b/website/public/API/adminChangeUser.php new file mode 100644 index 0000000..067a7ba --- /dev/null +++ b/website/public/API/adminChangeUser.php @@ -0,0 +1,20 @@ + - + + fetch(PDO::FETCH_ASSOC); + +if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') { + header("location:profile.php"); +} + include("../views/main.php"); /* Add your view files here. */ diff --git a/website/public/js/admin.js b/website/public/js/admin.js index e3dfdd7..140c99a 100644 --- a/website/public/js/admin.js +++ b/website/public/js/admin.js @@ -1,6 +1,18 @@ -window.onload = function() { +$(window).on("load", function () { changeFilter(); -}; + $(".admin-searchinput").keyup(function(){ + adminSearch(); + }); + // all inputs and labels directly under admin filter and groupfilter + $("#admin-filter, #admin-groupfilter > input, label").click(function(){ + adminSearch(); + }); + $("#pagetype").change(function(){ + adminSearch(); + }); + + adminSearch(); +}); function checkAll(allbox) { var checkboxes = document.getElementsByClassName('checkbox-list'); @@ -32,13 +44,32 @@ function changeFilter() { 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'; + document.getElementById('admin-batchform').style.display = 'none'; + document.getElementById('admin-groupbatchform').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'; + document.getElementById('admin-batchform').style.display = 'inline-block'; + document.getElementById('admin-groupbatchform').style.display = 'none'; } } + +function adminSearch() { + $.post( + "API/adminSearchUsers.php", + $("#admin-searchform").serialize() + ).done(function (data) { + console.log(data); + $("#usertable").html(data); + }) +} + +function updatePageN() { + $.post( + "API/adminPageNumber.php", + $("#admin-searchform").serialize() + ).done(function (data) { + $("#admin-pageinfo").html(data); + }) +} \ No newline at end of file diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 91ed550..5652e37 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -196,15 +196,18 @@ function countSomeGroupsByStatus($keyword, $status) { } function changeGroupStatusByID($id, $status) { - $q = $GLOBALS["db"]->query(" + $q = $GLOBALS["db"]->prepare(" UPDATE `group_page` SET - `status` = $status + `status` = :status WHERE - `groupID` = $id + `groupID` = :id "); + $q->bindParam(':status', $status); + $q->bindParam(':id', $id); + $q->execute(); return $q; } diff --git a/website/queries/user.php b/website/queries/user.php index b9ba986..1d075ef 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -387,3 +387,18 @@ function countSomeUsers($search) { $q->execute(); return $q; } + +function getRoleByID($userID) { + $stmt = $GLOBALS['db']->prepare(" + SELECT + `role` + FROM + `user` + WHERE + `userID` = :userID + "); + + $stmt->bindParam(':userID', $userID); + $stmt->execute(); + return $stmt; +} \ No newline at end of file diff --git a/website/views/adminpanel-grouptable.php b/website/views/adminpanel-grouptable.php new file mode 100644 index 0000000..4999666 --- /dev/null +++ b/website/views/adminpanel-grouptable.php @@ -0,0 +1,48 @@ + + + Gebruikersnaam + Status + Aantekening + Actie + + +fetch(PDO::FETCH_ASSOC)) { + $groupID = $group['groupID']; + $name = $group['name']; + $role = $group['status']; + $description = $group['description']; + $function = "checkCheckAll(document.getElementById('checkall'))"; + + echo(" + + + + $name + $role + $description + +
+ + + +
+ + + "); +} \ No newline at end of file diff --git a/website/views/adminpanel-page.php b/website/views/adminpanel-page.php new file mode 100644 index 0000000..a17ce50 --- /dev/null +++ b/website/views/adminpanel-page.php @@ -0,0 +1,31 @@ +fetchColumn(); +$mincount = min($listm, $countresults); +$minlist = min($listn + 1, $countresults); +?> + Pagina:
+ +
+ \ No newline at end of file diff --git a/website/views/adminpanel-table.php b/website/views/adminpanel-table.php new file mode 100644 index 0000000..a21c9d6 --- /dev/null +++ b/website/views/adminpanel-table.php @@ -0,0 +1,47 @@ + + + Gebruikersnaam + Status + Aantekening + Actie + + + +fetch(PDO::FETCH_ASSOC)) { + $userID = $user['userID']; + $username = $user['username']; + $role = $user['role']; + $bancomment = $user['bancomment']; + $function = "checkCheckAll(document.getElementById('checkall'))"; + + echo(" + + + + + $username + $role + $bancomment + +
+ + + +
+ + + "); +} diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index d97a9e8..c48a28d 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -1,14 +1,11 @@ - - +
@@ -61,19 +38,21 @@ $listm = $currentpage * $perpage;
Zoek naar gebruikers of groepen:
" + id="admin-searchform" + action="javascript:adminSearch();" method="get"> +
Type gebruiker:
- > -
> -
+ > +
> -
+ > +
> -
+ > +
> + >
> -
+ > +
> + >
Type groep:
- > -
- > -
- > -
- > -
+ > +
+ > +
+ > +
-
-
-
-

Resultaat:

- - fetchColumn(); - $mincount = min($listm, $countresults); - $minlist = min($listn + 1, $countresults); - ?> - Pagina:
- -
- -
+
+ +
+
+

Resultaat:

+ + +
-
- - - - - - - - + - - fetch(PDO::FETCH_ASSOC)) { - $userID = $user['userID']; - $username = $user['username']; - $role = $user['role']; - $bancomment = $user['bancomment']; - $thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI'])); - $function = "checkCheckAll(document.getElementById('checkall'))"; - - echo(" - - - - - - - - "); - } - } else { - $q = searchSomeGroupsByStatus($listn, $listm, $search, $groupstatus); - - while ($group = $q->fetch(PDO::FETCH_ASSOC)) { - $groupID = $group['groupID']; - $name = $group['name']; - $role = $group['status']; - $description = $group['description']; - $thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI'])); - $function = "checkCheckAll(document.getElementById('checkall'))"; - - echo(" - - - - - - - - "); - } - } - ?> -
GebruikersnaamStatusAantekeningActie
- $username$role$bancomment - - - - - -
- $name$role$description -
- - - -
-
+ + + +
+ + + +
+
- + \ No newline at end of file