Refactoring

This commit is contained in:
Henjo Hoeksma 2014-05-23 11:48:19 +02:00
parent 1abfadf28c
commit 296e83fb88
811 changed files with 16877 additions and 147663 deletions

37
users.php Normal file
View file

@ -0,0 +1,37 @@
<?php
include_once('includes/config.inc.php');
include_once('includes/session.inc.php');
include_once('includes/misc.inc.php');
if (!is_logged_in()) {
header("Location: index.php");
}
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
_jtable_respond(null, 'error', 'No action given');
}
if ($action == "list") {
$users = get_all_users();
_jtable_respond($users);
} elseif ($action == "create" or $action == "update") {
$isadmin = $_POST['isadmin'] ? $_POST['isadmin'] : '0';
if (add_user($_POST['emailaddress'], $isadmin, $_POST['password']) === TRUE) {
unset($_POST['password']);
_jtable_respond($_POST, 'single');
} else {
_jtable_respond(null, 'error', 'Could not add/change this user');
}
} elseif ($action == "delete") {
if (delete_user($_POST['id']) === TRUE) {
_jtable_respond(null, 'delete');
} else {
_jtable_respond(null, 'error', 'Could not delete this user');
}
}
?>