Projekt

Obecné

Profil

« Předchozí | Další » 

Revize ad5ad0be

Přidáno uživatelem Tomáš Pašek před téměř 4 roky(ů)

Enhancement #8757 Refactoring, server-side

Zobrazit rozdíly:

application/controller/DeleteUserController.php
5 5

  
6 6
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
7 7
    $DB = new DB();
8
    $result = $DB->deleteUser($_POST['userId']);
8
    $results = $DB->select("SELECT id, username, role from USERS WHERE role = 'admin'", array());
9
    if (sizeof($results) == 1) { //at least one admin must still exist
10
        if ($results[0]["id"] != $_POST['userId']) {
11
            $result = $DB->deleteUser($_POST['userId']);
12
        }
13
    } else if (sizeof($results) > 1) {
14
        $result = $DB->deleteUser($_POST['userId']);
15
    }
9 16
}

Také k dispozici: Unified diff