예제 #1
0
 public function DeleteUser()
 {
     if (isset($_POST["userID"]) && $_SESSION['form_timer'] + 300 > time()) {
         parent::model("accounts");
         $account = new accounts();
         $user = $account->ShowUserByID($_POST["userID"]);
         $advisors = $account->ShowUsersByRank(0);
         if ($_POST['userID'] != $_SESSION['ID']) {
             if ($user->rank == 0 && Count($advisors) >= 2 || $user->rank == 2) {
                 try {
                     if ($user->rank == 2) {
                         parent::model("docs");
                         $model = new docs();
                         parent::model("ratings");
                         $model1 = new ratings();
                         $model1->DeleteRatingsIntern($_POST["userID"]);
                         $account->DeleteUser($_POST["userID"]);
                         $model->DeleteXML($_POST["userID"]);
                     } else {
                         $account->DeleteUser($_POST["userID"]);
                     }
                     $data['alert'] = "alert-success";
                     $data['message'] = "Cet utilisateur a bien été supprimé.";
                 } catch (exception $ex) {
                     $data['alert'] = "alert-warning";
                     $data['message'] = "Cet utilisateur n'a pu être supprimé.";
                 }
             } else {
                 $data['alert'] = "alert-warning";
                 $data['message'] = "Il ne reste qu'un coordonnateur: vous ne pouvez le supprimer.";
             }
         } else {
             $data['alert'] = "alert-warning";
             $data['message'] = "Vous ne pouvez pas vous supprimer.";
         }
     }
     $this->ShowUsers($data);
 }