Ejemplo n.º 1
0
 function deleteAlbumModel($albumId)
 {
     $responseDTO = new ResponseDTO(DELETE_ALBUM_FORM);
     try {
         $userLogged = SessionUtils::getUserLogged();
         $defaultAlbumId = $userLogged->getDefaultAlbumId();
         if ($defaultAlbumId == $albumId) {
             $responseDTO->setErrField(ERROR_RESPONSE, "Non puoi eliminare il tuo album di default");
             return $responseDTO;
         }
         $albumDAO = new AlbumDAO();
         $deletePhotoInAlbum = $albumDAO->deletePhotoInAlbum($albumId);
         $deletedAlbum = $albumDAO->deleteAlbumById($albumId);
         if ($deletedAlbum != 1) {
             $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'eliminazione dell'album");
             $responseDTO->setSubElementId($albumId);
         } else {
             $userLogged = SessionUtils::getUserLogged();
             FileUtils::deleteAlbumDirOnServer($userLogged->getUserId(), $albumId);
             if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
                 $responseDTO->setResponseSucc("#album" . $albumId);
             } else {
                 $responseDTO->setResponseSucc("Album eliminato con successo!");
             }
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 2
0
 public function deleteUser($userId)
 {
     try {
         $model = $this->getModel();
         $deletedUser = $model->deleteUserModel($userId);
         FileUtils::deleteAlbumDirOnServer($userId, NULL);
         if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
             echo json_encode($deletedUser->jsonSerialize());
         } else {
             $responseDTO = new ResponseDTO(DELETE_USER_FORM);
             $responseDTO->setResponseSucc("Utente eliminato con successo");
             SessionUtils::setError($responseDTO);
             header("Location: " . URL . USERLIST_CONTROLLER);
             exit;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 3
0
 public function deleteUserForm()
 {
     try {
         $model = $this->getModel();
         $deletedUser = $model->deleteUserModel();
         $userLogged = SessionUtils::getUserLogged();
         FileUtils::deleteAlbumDirOnServer($userLogged->getUserId(), NULL);
         SessionUtils::logout();
         if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
             echo json_encode($deletedUser->jsonSerialize());
         } else {
             header("Location: " . URL . LOGIN_CONTROLLER);
             exit;
         }
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }