function loadProfile($view, $model) { try { if (!is_null(SessionUtils::getAuthorId()) && !is_null(SessionUtils::getPost()) && !SessionUtils::isAdmin()) { $postDto = $model->getPostModel(SessionUtils::getPost()); $view->setArg("notificationPost", $postDto); $commentPostList = $model->getCommentPostList(SessionUtils::getPost()); $commentListIndex = 'notificationCommentList' . SessionUtils::getPost(); $view->setArg($commentListIndex, $commentPostList); SessionUtils::setPost(NULL); SessionUtils::setAuthorId(NULL); } else { $userAlbumListDTO = $model->getUserAlbumList(SessionUtils::getDashboardId()); $view->setArg('userAlbumList', $userAlbumListDTO); $postList = $model->getPostsListModel(SessionUtils::getDashboardId()); $view->setArg('postList', $postList); if (!is_null($postList)) { for ($i = 0; $i < sizeof($postList); $i++) { $index = 'post' . $i; $postId = $postList[$index]->getPostId(); $commentPostList = $model->getCommentPostList($postId); $commentListIndex = 'commentPostList' . $postId; $view->setArg($commentListIndex, $commentPostList); } } if (!is_null(SessionUtils::getError())) { $view->setResponse(SessionUtils::getError()); if (!is_null(SessionUtils::getFormValue())) { $view->setFormData(SessionUtils::getFormValue(), WRITE_POST_FORM); } SessionUtils::setError(NULL); SessionUtils::setFormValue(NULL); } } $view->loadPage(); } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
private function init() { $urlArray = $this->getUrlArray(); if (is_null($urlArray)) { $userLogged = SessionUtils::getUserLogged(); if (!is_null($userLogged)) { // header('Location: ' . URL . SessionUtils::getLastPageVisited()); exit; } else { if (isset($_COOKIE[SHAREATRIPCOOKIE])) { header('Location: ' . URL . LOGIN_CONTROLLER . 'autoLogin'); exit; } else { header('Location: ' . URL . LOGIN_CONTROLLER); exit; } } } else { if ($urlArray[1] === 'index') { if ($urlArray[0] === 'Profile') { if (!is_null($urlArray[5])) { SessionUtils::setPost($urlArray[2]); SessionUtils::setAuthorId($urlArray[3]); SessionUtils::setDashboardId($urlArray[4]); SessionUtils::setComment($urlArray[5]); } else { if (!is_null($urlArray[4])) { SessionUtils::setPost($urlArray[2]); SessionUtils::setAuthorId($urlArray[3]); SessionUtils::setDashboardId($urlArray[4]); } else { if (!is_null($urlArray[2])) { SessionUtils::setPost(NULL); SessionUtils::setAuthorId(NULL); SessionUtils::setDashboardId($urlArray[2]); } } } header("Location: " . URL . PROFILE_CONTROLLER); exit; } else { if ($urlArray[0] === 'Photo') { if (!is_null($urlArray[4])) { SessionUtils::setAlbumId($urlArray[2]); SessionUtils::setPhotoId($urlArray[3]); SessionUtils::setDashboardId($urlArray[4]); } else { if (!is_null($urlArray[3])) { SessionUtils::setAlbumId($urlArray[2]); SessionUtils::setDashboardId($urlArray[3]); } else { if (!is_null($urlArray[2])) { SessionUtils::setAlbumId($urlArray[2]); } } } header("Location: " . URL . PHOTO_CONTROLLER); exit; } else { if ($urlArray[0] === 'Album') { if (!is_null($urlArray[3])) { SessionUtils::setAlbumId($urlArray[2]); SessionUtils::setDashboardId($urlArray[3]); } header("Location: " . URL . ALBUM_CONTROLLER); exit; } else { if ($urlArray[0] === 'ProfileSettings') { SessionUtils::setDashboardId($urlArray[2]); header("Location: " . URL . PROFILE_SETTINGS_CONTROLLER); exit; } } } } } $url = new UrlDTO($urlArray); $this->loadController($url->getController()); $this->callControllerMethod($url); } }