improve adminpanel w/ ajax, enum fixes, misc fixes
This commit is contained in:
20
website/public/API/adminChangeUser.php
Normal file
20
website/public/API/adminChangeUser.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
|
||||
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
|
||||
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
|
||||
} else if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
|
||||
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
|
||||
} else if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
|
||||
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
|
||||
} else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
|
||||
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
|
||||
}
|
||||
|
||||
//header("location: ../admin.php");
|
||||
print_r($_POST);
|
||||
28
website/public/API/adminPageNumber.php
Normal file
28
website/public/API/adminPageNumber.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
$pagetype = "user";
|
||||
if (isset($_POST['pagetype'])) {
|
||||
$pagetype = test_input($_POST['pagetype']);
|
||||
}
|
||||
|
||||
$status = array();
|
||||
if (isset($_POST['status'])) {
|
||||
$status = $_POST["status"];
|
||||
}
|
||||
|
||||
if ($pagetype == "user") {
|
||||
include ("../../views/adminpanel-page.php");
|
||||
} else {
|
||||
echo "Pagenumber failed!";
|
||||
}
|
||||
44
website/public/API/adminSearchUsers.php
Normal file
44
website/public/API/adminSearchUsers.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
|
||||
$offset = 0;
|
||||
if (isset($_POST["n"])) {
|
||||
$offset = (int) test_input($_POST["n"]);
|
||||
}
|
||||
$entries = 20;
|
||||
if (isset($_POST["m"])) {
|
||||
$entries = (int) test_input($_POST["m"]);
|
||||
}
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
$pagetype = "user";
|
||||
if (isset($_POST['pagetype'])) {
|
||||
$pagetype = test_input($_POST['pagetype']);
|
||||
}
|
||||
|
||||
$status = array();
|
||||
if (isset($_POST['status'])) {
|
||||
$status = $_POST["status"];
|
||||
}
|
||||
|
||||
$groupstatus = array();
|
||||
if (isset($_POST['groupstatus'])) {
|
||||
$groupstatus = $_POST["groupstatus"];
|
||||
}
|
||||
|
||||
if ($pagetype == "user") {
|
||||
include ("../../views/adminpanel-table.php");
|
||||
} else if ($pagetype == "group") {
|
||||
include ("../../views/adminpanel-grouptable.php");
|
||||
} else {
|
||||
echo "Search failed!";
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<?php
|
||||
require_once ("../queries/user.php");
|
||||
require_once ("../queries/group_page.php");
|
||||
require_once ("../views/head.php"); ?>
|
||||
<style>
|
||||
@import url("styles/adminpanel.css");
|
||||
</style>
|
||||
<script src="js/admin.js" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
@@ -14,6 +18,7 @@
|
||||
*/
|
||||
include_once ("../queries/user.php");
|
||||
|
||||
// auth
|
||||
$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') {
|
||||
|
||||
@@ -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);
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user