function delete_user($user_id)
{
    if (!check_app_admin()) {
        $_SESSION['notifications'][] = "You are not an administrator!";
    } else {
        if ($user_id == $_SESSION['user_id']) {
            $_SESSION['notifications'][] = "You cannot deactivate yourself!";
        } else {
            if (check_app_admin($user_id)) {
                unmake_admin($user_id);
            }
            if (check_supervisor($user_id)) {
                unmake_super($user_id);
            }
            $sql = "UPDATE users SET inactive=1 WHERE user_id=" . $user_id;
            $_SESSION['dbconn']->query($sql) or die("Error deactivating user: "******"Successfully removed user!";
        }
    }
}
Example #2
0
//Any pre-page logic should go here!
//If a user was deleted...
if (isset($_POST['deluser-submit'])) {
    delete_user($_POST['deluser-id']);
}
//If a user was undeleted...
if (isset($_POST['undeluser-submit'])) {
    undelete_user($_POST['undeluser-id']);
}
//If a user was made admin
if (isset($_POST['makeadmin-submit'])) {
    make_admin($_POST['makeadmin-id']);
}
//If a user was unmade admin
if (isset($_POST['unmakeadmin-submit'])) {
    unmake_admin($_POST['unmakeadmin-id']);
}
//If a user was made super
if (isset($_POST['makesuper-submit'])) {
    make_super($_POST['makesuper-id']);
}
//If a user was unmade super
if (isset($_POST['unmakesuper-submit'])) {
    unmake_super($_POST['unmakesuper-id']);
}
//If a user had his password reset
if (isset($_POST['pwreset-submit'])) {
    $newpass = reset_password($_POST['pwreset-id']);
    draw_newpass_success($newpass);
}
if (isset($_POST['edituser-submit'])) {