コード例 #1
0
ファイル: UserList.php プロジェクト: sbadi/shareatrip
 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;
     }
 }
コード例 #2
0
ファイル: Friends.php プロジェクト: sbadi/shareatrip
 public function searchUser()
 {
     $model = $this->getModel();
     $searchCriteriaFormAjax = NULL;
     $jsonUserDTOList = [];
     try {
         if (isset($_GET["searchForm"])) {
             $searchCriteriaFormAjax = json_decode($_GET["searchForm"], true);
             $foundedResources = $model->searchResourceModel($searchCriteriaFormAjax);
             for ($i = 0; $i < sizeof($foundedResources); $i++) {
                 $index = 'friends' . $i;
                 $jsonUserDTOList[$index] = $foundedResources[$index]->jsonSerialize();
             }
             echo json_encode($jsonUserDTOList);
         } else {
             $foundedResources = $model->searchResourceModel($searchCriteriaFormAjax);
             if (get_class($foundedResources) === RESPONSEDTO) {
                 SessionUtils::setError($foundedResources);
             } else {
                 if (!is_null($foundedResources)) {
                     $responseDTO = new ResponseDTO(SEARCH_USER_FORM);
                     $responseDTO->setResponseSucc($foundedResources);
                     SessionUtils::setError($responseDTO);
                 }
             }
             header("Location: " . URL . FRIENDS_CONTROLLER);
             exit;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #3
0
ファイル: Profile.php プロジェクト: sbadi/shareatrip
 function commentAPost($postId = NULL)
 {
     try {
         $model = $this->getModel();
         $newCommentPostAjax = NULL;
         if (isset($_POST["commentAPostForm"])) {
             $newCommentPostAjax = json_decode($_POST["commentAPostForm"], true);
             $newComment = $model->commentAPostModel($newCommentPostAjax, $postId);
             echo json_encode($newComment->jsonSerialize());
         } else {
             $newComment = $model->commentAPostModel($newCommentPostAjax, $postId);
             if (get_class($newComment) !== COMMENTDTO) {
                 SessionUtils::setError($newComment);
             } else {
                 $responseDTO = new ResponseDTO(WRITE_POST_FORM);
                 $responseDTO->setResponseSucc("Commento aggiunto con successo");
                 SessionUtils::setError($responseDTO);
             }
             header("Location: " . URL . PROFILE_CONTROLLER);
             exit;
             //
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #4
0
ファイル: Album.php プロジェクト: sbadi/shareatrip
 public function deleteAlbum($albumId)
 {
     try {
         $model = $this->getModel();
         $deletedAlbum = $model->deleteAlbumModel($albumId);
         if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
             echo json_encode($deletedAlbum->jsonSerialize());
         } else {
             SessionUtils::setError($deletedAlbum);
             header("Location: " . URL . ALBUM_CONTROLLER);
             exit;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #5
0
ファイル: Photo.php プロジェクト: sbadi/shareatrip
 public function addPhoto()
 {
     try {
         $model = $this->getModel();
         $newPhotoAjax = NULL;
         if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
             $newPhoto = $model->addPhotoModel($newPhotoAjax, SessionUtils::getAlbumId());
             echo json_encode($newPhoto->jsonSerialize());
         } else {
             $newPhoto = $model->addPhotoModel($newPhotoAjax, SessionUtils::getAlbumId());
             if (get_class($newPhoto) === PHOTODTO) {
                 $responseDTO = new ResponseDTO(ADD_PHOTO_FORM);
                 $responseDTO->setResponseSucc("Foto aggiunta con successo!");
                 SessionUtils::setError($responseDTO);
             } else {
                 SessionUtils::setError($newPhoto);
             }
             header("Location: " . URL . PHOTO_CONTROLLER);
             exit;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #6
0
ファイル: ProfileSettings.php プロジェクト: sbadi/shareatrip
 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;
     }
 }
コード例 #7
0
ファイル: Home.php プロジェクト: sbadi/shareatrip
 function deleteComment($commentId)
 {
     try {
         $model = $this->getModel();
         $deletedComment = $model->deleteCommentModel($commentId);
         if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
             echo json_encode($deletedComment);
         } else {
             SessionUtils::setError($deletedComment);
             header("Location: " . URL . HOME_CONTROLLER);
             exit;
         }
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         parent::userNotLogged($authExp);
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }