Пример #1
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;
     }
 }