Example #1
0
 public function index()
 {
     try {
         $this->getNotifications();
         $this->loadDashboardUser();
         SessionUtils::setLastPageVisited(ALBUM_CONTROLLER);
         $view = $this->getView();
         $model = $this->getModel();
         $view->uploadJS();
         $view->setArg('userCanWrite', SessionUtils::userCanWrite());
         $view->setArg('albumOwnerId', SessionUtils::getDashboardId());
         if (!is_null(SessionUtils::getAlbumId())) {
             $albumDTO = $model->getAlbumModel(SessionUtils::getAlbumId());
             $view->setArg("notificationAlbum", $albumDTO);
             SessionUtils::setAlbumId(NULL);
         } else {
             $userAlbums = $model->getUserAlbumsModel(SessionUtils::getDashboardId());
             $view->setArg('userAlbumList', $userAlbums);
             if (!is_null(SessionUtils::getError())) {
                 $view->setResponse(SessionUtils::getError());
                 $view->setFormData(SessionUtils::getFormValue(), ADD_ALBUM_FORM);
                 SessionUtils::setError(NULL);
                 SessionUtils::setFormValue(NULL);
             }
         }
         $view->setArg(LAST_NAV_ITEM_SELECTED, 5);
         $view->loadPage();
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         SessionUtils::logout();
         header("Location:" . URL . LOGIN_CONTROLLER);
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #2
0
 public static function userCanReadAlbum()
 {
     $albumId = SessionUtils::getAlbumId();
     $albumList = SessionUtils::getUserLoggedAlbumList();
     return array_key_exists($albumId, $albumList);
 }
Example #3
0
 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;
     }
 }