示例#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;
     }
 }
示例#2
0
 public function deleteCommentModel($commentId)
 {
     $responseDTO = new ResponseDTO(DELETE_COMMENT_FORM);
     try {
         $postDAO = new PostDAO();
         $deletedComment = $postDAO->deleteComment($commentId);
         if ($deletedComment != 1) {
             $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'eliminazione del commento");
             $responseDTO->setSubElementId($commentId);
         } else {
             if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
                 $responseDTO->setResponseSucc("#comment" . $commentId);
             } else {
                 $responseDTO->setResponseSucc("Commento eliminato con successo!");
             }
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#3
0
 public function commentAPostModel($commentForm, $postId = NULL)
 {
     $responseDTO = new ResponseDTO(WRITE_COMMENT_FORM);
     $formObjRaw = new FormDTO(WRITE_COMMENT_FORM, $commentForm);
     $formObjRaw->setSubElementId($postId);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $responseDTO->setSubElementId($formDataObj[WRITE_COMMENT_FORM . POSTID]);
         $validator = new FormValidator(WRITE_COMMENT_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $timestamp = date(DATE_FORMAT);
             $userLogged = SessionUtils::getUserLogged();
             $newCommentDTO = new CommentDTO(NULL, $formDataObj[WRITE_COMMENT_FORM . TEXT], $timestamp, $formDataObj[WRITE_COMMENT_FORM . POSTID], $userLogged);
             $postDAO = new PostDAO();
             $commentDTO = $postDAO->insertNewComment($newCommentDTO);
             if ($commentDTO->getCommentid() == 0) {
                 $responseDTO->setResponseSucc("Non è stato possibile inserire il commento del post");
             } else {
                 DataModelUtils::notifyAction($commentDTO->getCommentid() . SEPARATOR . $formDataObj[WRITE_COMMENT_FORM . POSTID] . SEPARATOR . $userLogged->getUserId() . SEPARATOR . SessionUtils::getDashboardId(), WRITE_COMMENT_FORM);
                 return $commentDTO;
             }
         } else {
             if (array_key_exists(TEXT, $validationError)) {
                 $responseDTO->setErrField(TEXT, $validationError[TEXT]);
             }
             return $responseDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#4
0
 function deletePhotoModel($photoId, $filename)
 {
     $responseDTO = new ResponseDTO(DELETE_PHOTO_FORM);
     try {
         $userLogged = SessionUtils::getUserLogged();
         $defaultUserPhotoProfileId = $userLogged->getProfilePhoto()->getPhotoId();
         $photoDAO = new PhotoDAO();
         if ($photoId == $defaultUserPhotoProfileId) {
             $uploadedPhoto = new PhotoDTO(1, DEFAULT_USER_PHOTOPROFILE_URL);
             $updateProfilePhoto = $photoDAO->updateProfilePhoto($uploadedPhoto);
             $userLogged = SessionUtils::getUserLogged();
             $userLogged->setProfilePhoto($uploadedPhoto);
             SessionUtils::setUserLogged($userLogged);
         }
         $deletedPhoto = $photoDAO->deletePhotoInAlbum($photoId);
         $deletedPhoto = $photoDAO->deletePhoto($photoId);
         if ($deletedPhoto != 1) {
             $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'eliminazione della foto");
             $responseDTO->setSubElementId($photoId);
         } else {
             FileUtils::deletePhotoOnServer($filename);
             $responseDTO->setResponseSucc("#photo" . $photoId);
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }