Beispiel #1
0
 public function adminChangeStatus()
 {
     $session = new SessionHelper();
     $mail = new MailHelper();
     // Id of the user being changed
     $id = htmlspecialchars($_POST['id']);
     $thisuser = new User($id);
     if ($this->_authCheck() && $this->role == 1) {
         // Instance used for data on page
         $user = new User();
         // Instance used to use change status method
         $usermodel = new UserModel();
         if (isset($_POST['setactive']) && $_POST['setactive'] == true) {
             if ($usermodel->changeStatus($id, ['is_active' => 1])) {
                 $session->setMessage('Status changed', 4);
                 $mail->sendActiveMail($thisuser->username, $thisuser->email, $thisuser->username, $user->username);
                 redirectTo(BASE_URL . 'index.php?c=user&a=edituser&id=' . $id);
             } else {
                 $session->setMessage('Status not changed', 3);
                 redirectTo(BASE_URL . 'index.php?c=user&a=edituser&id=' . $id);
             }
         } elseif (isset($_POST['setinactive']) && $_POST['setinactive'] == true) {
             if ($usermodel->changeStatus($id, ['is_active' => 0])) {
                 $session->setMessage('Status changed', 4);
                 $mail->sendInactiveMail($thisuser->username, $thisuser->email, $thisuser->username, $user->username);
                 redirectTo(BASE_URL . 'index.php?c=user&a=edituser&id=' . $id);
             } else {
                 $session->setMessage('Status not changed', 3);
                 redirectTo(BASE_URL . 'index.php?c=user&a=edituser&id=' . $id);
             }
         } else {
             $session->setMessage('An error occured while changing the status', 3);
             redirectTo(BASE_URL . 'index.php?c=user&a=edituser&id=' . $id);
         }
     } else {
         $this->viewLoginPage();
     }
 }