mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-06-07 00:47:00 +03:00
Modified users jtable to use id & fixed user deletion.
This commit is contained in:
parent
b16af25052
commit
083cb9429c
3 changed files with 41 additions and 25 deletions
17
users.php
17
users.php
|
@ -64,20 +64,13 @@ case "create":
|
|||
break;
|
||||
|
||||
case "update":
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : '';
|
||||
$emailaddress = isset($_POST['emailaddress']) ? $_POST['emailaddress'] : '';
|
||||
$isadmin = isset($_POST['isadmin']) ? $_POST['isadmin'] : '0';
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
|
||||
if (!valid_user($emailaddress)) {
|
||||
jtable_respond(null, 'error', "Please only use ^[a-z0-9@_.-]+$ for usernames");
|
||||
}
|
||||
|
||||
if (!user_exists($emailaddress)) {
|
||||
jtable_respond(null, 'error', 'Cannot update not existing user');
|
||||
}
|
||||
|
||||
if (update_user($emailaddress, $isadmin, $password)) {
|
||||
$result = array('emailaddress' => $emailaddress, 'isadmin' => $isadmin);
|
||||
if ($id != '' and update_user($id, $isadmin, $password)) {
|
||||
$result = array('isadmin' => $isadmin);
|
||||
jtable_respond($result, 'single');
|
||||
} else {
|
||||
jtable_respond(null, 'error', 'Could not update user');
|
||||
|
@ -85,7 +78,9 @@ case "update":
|
|||
break;
|
||||
|
||||
case "delete":
|
||||
if ($emailaddress != '' and delete_user($emailaddress) !== FALSE) {
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : '';
|
||||
|
||||
if ($id != '' and delete_user($id) !== FALSE) {
|
||||
jtable_respond(null, 'delete');
|
||||
} else {
|
||||
jtable_respond(null, 'error', 'Could not delete user');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue