public function index() { try { $this->getNotifications(); $this->loadDashboardUser(); $view = $this->getView(); $model = $this->getModel(); $view->uploadJS(); if (!is_null(SessionUtils::getError())) { $view->setResponse(SessionUtils::getError()); SessionUtils::setError(NULL); } else { $view->setArg("searchFriendsList", NULL); } $userLogged = SessionUtils::getUserLogged(); $userProfile = SessionUtils::getDashboardId() !== $userLogged->getUserId() ? SessionUtils::getDashboardId() : $userLogged->getUserId(); $friendList = $model->getUserFriendsList($userProfile); $view->setArg('friendsList', $friendList); SessionUtils::setLastPageVisited(FRIENDS_CONTROLLER); $view->setArg(LAST_NAV_ITEM_SELECTED, 6); $view->loadPage(); } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { SessionUtils::logout(); header("Location:" . URL . LOGIN_CONTROLLER); } catch (Exception $e) { throw $e; } }
public function setAllNotificationsAsRead() { if (!is_null(SessionUtils::getUserLogged())) { $notificationDAO = new NotificationDAO(); $notificationDAO->setAllNotificationsAsRead(); $this->view->setArg('unreadNotification', 0); } }
public function testSession() { try { $userLogged = SessionUtils::getUserLogged(); $username = $userLogged->getUserName(); $sessionToken = SessionUtils::getSessionToken(); $query = "select * from sat_user where USERNAME = {$username} and SESSION_TOKEN = {$sessionToken}"; return $this->execQuery($query); } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
public function insertNewUserAddressVisited(\AddressDTO $addressDTO) { try { $this->userAutentication(); $userLogged = SessionUtils::getUserLogged(); $newAddress = array(":" . USERID => $userLogged->getUserId(), ":" . LONGITUDE => $addressDTO->getLongitude(), ":" . LATITUDE => $addressDTO->getLatitude(), ":" . TIMESTAMP => date(DATE_FORMAT)); $newAddressId = $this->getDB()->insert(USER_ADDRESS_VISITED_TABLE, $newAddress); return $newAddressId; } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
public function confirmFriendship($friendId) { $userLogged = SessionUtils::getUserLogged(); $query = "update sat_user_friends set friendssince = '" . date(DATE_FORMAT) . "' where (userid = {$friendId} and friendid = " . $userLogged->getUserId() . ") OR (userid = " . $userLogged->getUserId() . " and friendid = {$friendId} )"; try { $this->userAutentication(); $result = $this->getDB()->execQuery($query); return $result; } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
function addAlbumModel($albumForm) { $formObjRaw = new FormDTO(ADD_ALBUM_FORM, $albumForm); $responseDTO = new ResponseDTO(ADD_ALBUM_FORM); try { $formDataObj = $formObjRaw->getFormData(); $validator = new FormValidator(ADD_ALBUM_FORM, $formDataObj); $validationError = $validator->checkAll(); // $validationError = array(); if (sizeof($validationError) == 0) { $userLogged = SessionUtils::getUserLogged(); $uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_ALBUM_FORM . COVER], NULL, ADD_ALBUM_FORM); if (get_class($uploadedPhoto) === PHOTODTO) { $userDAO = new UserDAO(); $userDTO = $userDAO->getUserByUserId($userLogged->getUserId()); $albumDAO = new AlbumDAO(); $albumDTO = new AlbumDTO(null, date(DATE_FORMAT), $formDataObj[ADD_ALBUM_FORM . TITLE], $uploadedPhoto, $userDTO); $albumDTO = $albumDAO->insertNewAlbum($albumDTO); if ($albumDTO->getAlbumId() != 0) { $photoAlbumPath = FileUtils::createAlbumDirOnServer($userDTO->getUserId(), $albumDTO->getAlbumId()); DataModelUtils::notifyAction($albumDTO->getCover()->getPhotoId() . SEPARATOR . $albumDTO->getCover()->getPhotoUrl() . SEPARATOR . $albumDTO->getAlbumId() . SEPARATOR . $albumDTO->getTitle(), ADD_ALBUM_FORM); return $albumDTO; } else { $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento dell'album"); } } else { $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto profilo"); } } else { if (array_key_exists(TITLE, $validationError)) { $responseDTO->setErrField(TITLE, $validationError[TITLE]); } if (array_key_exists(PHOTO, $validationError)) { $responseDTO->setErrField(COVER, $validationError[PHOTO]); } SessionUtils::setFormValue($formDataObj); } return $responseDTO; } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
public function updateProfilePhoto(\PhotoDTO $userProfilePhotoDTO) { $userLogged = SessionUtils::getUserLogged(); $set = array(PROFILEPHOTO => $userProfilePhotoDTO->getPhotoId()); $where = array(USERID => $userLogged->getUserId()); try { $this->userAutentication(); $userPhoto = $this->getDB()->update(USER_TABLE, $set, $where); DataModelUtils::notifyAction($userProfilePhotoDTO->getPhotoId() . SEPARATOR . $userProfilePhotoDTO->getPhotoUrl(), PROFILE_SETTINGS_PHOTO_FORM); return $userProfilePhotoDTO; } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
function index() { try { $this->getNotifications(); $this->loadDashboardUser(); $userLogged = SessionUtils::getUserLogged(); $view = $this->getView(); $model = $this->getModel(); $view->setArg(LAST_NAV_ITEM_SELECTED, 4); $view->setArg('userCanWrite', SessionUtils::userCanWrite()); SessionUtils::setLastPageVisited(PROFILE_CONTROLLER); // $view->uploadJS(); if (SessionUtils::isAdmin()) { $this->loadProfile($view, $model); } else { if (!$view->getArg('userCanWrite')) { $friendDao = new FriendsDAO(); $isFriendshipLoading = $friendDao->checkFriendship($userLogged->getUserId(), SessionUtils::getDashboardId()); if ($isFriendshipLoading === false) { $view->setArg('friendship_loading', false); $view->loadPage('ProfileNotVisible'); } else { if (substr($isFriendshipLoading[0][FRIENDSSINCE], 0, 4) === "0000") { $view->setArg('friendship_loading', true); $view->loadPage('ProfileNotVisible'); } else { $this->loadProfile($view, $model); } } } else { $this->loadProfile($view, $model); } } } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { SessionUtils::logout(); header("Location:" . URL . LOGIN_CONTROLLER); } catch (Exception $e) { throw $e; } }
public static function uploadPhotoModel($uploadedPhoto, $albumId, $formType, $latitude = NULL, $longitude = NULL) { $responseDTO = new ResponseDTO($formType); try { $userLogged = SessionUtils::getUserLogged(); $fileName = $uploadedPhoto["name"]; $fileType = $uploadedPhoto["type"]; $tmpFileName = $uploadedPhoto["tmp_name"]; $rawImage = FileUtils::getRawImage($fileType, $tmpFileName); $fileName = FileUtils::getFileName($fileName, $userLogged->getUserId(), $albumId); $redimImage = FileUtils::getRedimensionedImage($tmpFileName, $rawImage); if (imagejpeg($redimImage, $fileName, 100)) { $photoDAO = new PhotoDAO(); $newPhotoDTO = new PhotoDTO(NULL, $fileName, $latitude, $longitude); $newPhotoDTO = $photoDAO->insertNewPhoto($newPhotoDTO); if ($newPhotoDTO->getPhotoId() == 0) { $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto [" . $newPhotoDTO->getPhotoUrl() . "]"); } else { $albumDAO = new AlbumDAO(); if (is_null($albumId)) { $albumId = $albumDAO->getDefaultAlbumId($userLogged->getUserId()); } if ($formType !== ADD_ALBUM_FORM) { $photoInAlbumId = $albumDAO->insertNewUserPhotoAlbum($userLogged->getUserId(), $albumId, $newPhotoDTO->getPhotoId()); } if (!is_null($latitude) && !is_null($longitude)) { $uploadedAddress = FileUtils::saveAddressModel($latitude, $longitude, $formType); } return $newPhotoDTO; } } else { $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante la copia del file sul server PHP"); } } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $userAuth) { throw $userAuth; } catch (Exception $e) { throw $e; } }
function userAutentication() { try { $userLogged = SessionUtils::getUserLogged(); $sessionToken = SessionUtils::getSessionToken(); if (!is_null($userLogged)) { $query = "select * from sat_user where userid = " . $userLogged->getUserId() . " and SESSION_TOKEN = '" . $sessionToken . "'"; $objectArray = $this->getDB()->execQuery($query); if (is_null($objectArray)) { $myException = new UserNotAuthenticatedExceptionDTO(URL . LOGIN_CONTROLLER); throw $myException; } } } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $userAuth) { throw $userAuth; } catch (Exception $e) { throw $e; } }
public function getUnreadNotificationList($limit = NULL) { $userLogged = SessionUtils::getUserLogged(); if (is_null($limit)) { $query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc "; } else { $query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc "; } try { $objectArray = $this->getDB()->execQuery($query); if (is_null($objectArray)) { return NULL; } else { $objectListDTO = DataModelUtils::getObjectList(NOTIFICATIONDTO, $objectArray); return $objectListDTO; } } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
function index() { try { $this->getNotifications(); $userLogged = SessionUtils::getUserLogged(); $view = $this->getView(); $model = $this->getModel(); SessionUtils::setDashboardId($userLogged->getUserId()); $view->uploadJS(); if (!is_null(SessionUtils::getError())) { $view->setResponse(SessionUtils::getError()); SessionUtils::setError(NULL); } SessionUtils::setLastPageVisited(HOME_CONTROLLER); $homePostList = $model->getHomePostsListModel($userLogged->getUserId()); $view->setArg('homePostList', $homePostList); if (!is_null($homePostList)) { for ($i = 0; $i < sizeof($homePostList); $i++) { $index = 'post' . $i; $postId = $homePostList[$index]->getPostId(); $commentPostList = $model->getCommentPostList($postId); $commentListIndex = 'commentPostList' . $postId; $view->setArg($commentListIndex, $commentPostList); } } $userInfo = $model->getUserInfoModel(SessionUtils::getDashboardId()); $view->setArg('userInfo', $userInfo); $view->setArg(LAST_NAV_ITEM_SELECTED, 0); $view->loadPage(); } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { SessionUtils::logout(); header("Location:" . URL . LOGIN_CONTROLLER); } catch (Exception $e) { throw $e; } }
function addFriendModel($friendId) { try { $responseDTO = new ResponseDTO(ADD_FRIEND_FORM); $friendsDAO = new FriendsDAO(); $userDAO = new UserDAO(); $newFriendDTO = $userDAO->getUserByUserId($friendId); $userLogged = SessionUtils::getUserLogged(); $userDTO = $userDAO->getUserByUserId($userLogged->getUserId()); $newFriend = $friendsDAO->addNewFriend($friendId); SessionUtils::addFriendInUserLoggedFriendList($newFriendDTO); DataModelUtils::notifyAction($newFriendDTO->getUserId() . SEPARATOR . $newFriendDTO->getUserName(), ADD_FRIEND_FORM); $result = DataModelUtils::sendMail($userDTO, ADD_FRIEND_FORM, $newFriendDTO); $responseDTO->setResponseSucc("friend" . $friendId); return $responseDTO; } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
<?php if (!is_null(SessionUtils::getUserLogged())) { ?> <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3 " id="notificationList" > <div class="thumbnail"> <button class="btn btn-info btn-block" id="showNotification" name="showNotification" type="button"> <!-- <span class="glyphicon glyphicon-pushpin"></span> --> <span>Mostra / Nascondi notifiche</span> </button> <br> <?php $userNotificationList = $this->getArg('userNotificationListFooter'); ?> <table class="table table-striped" id="notificationTable"> <tbody> <?php if (!is_null($userNotificationList)) { $i = 0; foreach ($userNotificationList as $key => $value) { $notificationId = $value->getNotificationId(); $userId = $value->getUserId(); $subjectId = $value->getSubjectId(); $message = $value->getMessage(); $isRead = $value->getIsRead(); $sentAt = $value->getSentAt(); $context = $value->getContext(); ?>
<div id="photoCurtain"> <button class="btn btn-info " id="closePhotoButton" name="closePhotoButton" type="button"> <span class="glyphicon glyphicon-remove"></span> </button> <div id="fullScreenPhotoDiv"> <img id="fullScreenImg" src="#" alt=""/> </div> </div> <div id="content" class="container container-fluid"> <div> <?php $navigationItemSelected = SessionUtils::getNavigationSelectedItem(); $userLogged = SessionUtils::getUserLogged(); if (!is_null($userLogged)) { ?> <nav class="navbar"> <ul id="headerNavItem" class="nav nav-tabs"> <li> <a href="<?php echo URL . HOME_CONTROLLER; ?> "> <span class="glyphicon glyphicon-home"></span> <span class="headerNavItemName"></span> </a>
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); } }
function changeUserPwdModel($pwdForm) { $formObjRaw = new FormDTO(CHANGE_PWD_FORM, $pwdForm); $responseDTO = new ResponseDTO(CHANGE_PWD_FORM); try { $formDataObj = $formObjRaw->getFormData(); $validator = new FormValidator(CHANGE_PWD_FORM, $formDataObj); $validationError = $validator->checkAll(); if (sizeof($validationError) == 0) { $userLogged = SessionUtils::getUserLogged(); $hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . PASSWORD]); $userDTO = new UserDTO($userLogged->getUserId(), NULL, $hashedPwd, NULL, NULL, NULL, NULL, NULL); $userDAO = new UserDAO(); $userLoggedDTO = $userDAO->checkPassword($userDTO); if (is_null($userLoggedDTO)) { $responseDTO->setResponseSucc("Questa password non esiste"); return $responseDTO; } $hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . NEW_PASSWORD]); $userDTO->setPassword($hashedPwd); $userPwdUpdated = $userDAO->updateUserPassword($userDTO); return $userDTO; } else { if (array_key_exists(PASSWORD, $validationError)) { $responseDTO->setErrField(PASSWORD, $validationError[PASSWORD]); } if (array_key_exists(NEW_PASSWORD, $validationError)) { $responseDTO->setErrField(NEW_PASSWORD, $validationError[NEW_PASSWORD]); } if (array_key_exists(CONFIRM_PASSWORD, $validationError)) { $responseDTO->setErrField(CONFIRM_PASSWORD, $validationError[CONFIRM_PASSWORD]); } // var_dump($validationError); // var_dump($responseDTO);die; } return $responseDTO; } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
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; } }
public function denyFriendship($notificationId) { try { $userLogged = SessionUtils::getUserLogged(); $deleteFriendAjax = NULL; $model = $this->getModel(); if (isset($_POST["denyFriendshipForm"])) { $deleteFriendAjax = json_decode($_POST["denyFriendshipForm"], true); $deletedFriend = $model->denyFriendshipModel($notificationId, $deleteFriendAjax); echo json_encode($deletedFriend->jsonSerialize()); } else { $deletedFriend = $model->denyFriendshipModel($notificationId, $deleteFriendAjax); SessionUtils::setError($responseDTO); header("Location: " . URL . NOTIFICATION_CONTROLLER); exit; } } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
public static function getNotificationMessage($object, $context, $direction = NULL) { $message = ""; $userLogged = SessionUtils::getUserLogged(); if ($context === REGISTRATION_FORM) { $user = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $user[0] . '">' . $user[1] . '</a> si vuole registrare su sharetrip.com</label>'; } else { if ($context === PROFILE_SETTINGS_PHOTO_FORM) { $userProfilePhotoDTO = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_SETTINGS_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha cambiato la propria foto del profilo</label>'; } else { if ($context === ADD_ALBUM_FORM) { $album = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</a> ha aggiunto l\' album ' . '<a href="' . URL . ALBUM_CONTROLLER . INDEX . $album[2] . "/" . $userLogged->getUserId() . '">' . $album[3] . '</a></label>'; } else { if ($context === CHANGE_SETTINGS_FORM) { $message = '<label><a href="' . URL . PROFILE_SETTINGS_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</a> ha modificato alcune info del profilo.</label>'; } else { if ($context === WRITE_POST_FORM) { $post = explode(SEPARATOR, $object); $message = ""; if ($userLogged->getUserId() === $post[2]) { $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha scritto un nuovo <a href="' . URL . PROFILE_CONTROLLER . INDEX . $post[0] . '/' . $post[1] . '/' . $post[2] . '"> post </a> sulla sua bacheca</label>'; } else { $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</a> ha scritto un nuovo <a href="' . URL . PROFILE_CONTROLLER . INDEX . $post[0] . '/' . $post[1] . '/' . $post[2] . '"> post </a> sulla bacheca di <a href="' . URL . PROFILE_CONTROLLER . INDEX . $post[2] . '">' . $post[3] . '</a></label>'; } } else { if ($context === WRITE_COMMENT_FORM) { $comment = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha commentato un <a href="' . URL . PROFILE_CONTROLLER . INDEX . $comment[1] . '/' . $comment[2] . '/' . $comment[3] . '/' . $comment[0] . '"> post </a></label>.'; } else { if ($context === ADD_PHOTO_FORM) { $album = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha aggiunto una nuova <a href="' . URL . PHOTO_CONTROLLER . INDEX . $album[2] . '/' . $album[0] . '/' . $userLogged->getUserId() . '">foto</a> nell\' <a href="' . URL . ALBUM_CONTROLLER . INDEX . $album[2] . '/' . $userLogged->getUserId() . '"> album </a></label>'; } else { if ($context === ADD_FRIEND_FORM) { $friend = explode(SEPARATOR, $object); $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> vuole stringere amicizia con te</label>'; } else { if ($context === CONFIRM_FRIENDSHIP_FORM) { $friend = explode(SEPARATOR, $object); if ($direction === TOMYSELF) { $message = '<label>Hai stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '">' . $friend[1] . '</a><label>'; } else { if ($direction === TOMINENEWFRIEND) { $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha stretto amicizia con te.</label>'; } else { if ($direction === TOMYFRIENDSLIST) { $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a> ha stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '">' . $friend[1] . '</a></label>'; } else { if ($direction === TOMINENEWFRIENDFRIENDLIST) { $message = '<label><a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '">' . $friend[1] . '</a> ha stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '">' . $userLogged->getUsername() . '</a></label>'; } } } } } } } } } } } } } return $message; }
function updateProfilePhotoModel($photoId, $filename) { $responseDTO = new ResponseDTO(UPDATE_PROFILE_PHOTO_FORM); try { $photoDAO = new PhotoDAO(); $photoDTO = new PhotoDTO($photoId, $filename); $updateProfilePhoto = $photoDAO->updateProfilePhoto($photoDTO); $userLogged = SessionUtils::getUserLogged(); $userLogged->setProfilePhoto($photoDTO); SessionUtils::setUserLogged($userLogged); $responseDTO->setResponseSucc("Foto profilo aggiornata con successo!"); return $responseDTO; } catch (PDOException $pdoe) { throw $pdoe; } catch (UserNotAuthenticatedExceptionDTO $authExp) { throw $authExp; } catch (Exception $e) { throw $e; } }
public function commentAPostModel($commentForm, $postId) { $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) { $errorDTO = new ErrDTO(WRITE_COMMENT_FORM); $responseDTO->setResponseErr("Non รจ stato possibile inserire il commento del post"); $responseDTO->setSubElementId($formDataObj[WRITE_COMMENT_FORM . POSTID]); return $errorDTO; } 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 (Exception $e) { throw $e; } }
public static function checkUserId() { $userLogged = SessionUtils::getUserLogged(); return is_null(SessionUtils::getSession(USER)) ? NULL : $userLogged->getUserId(); }
public function saveUserToken($token) { $userLogged = SessionUtils::getUserLogged(); try { $set = array(SESSION_TOKEN => $token); $where = array(USERID => $userLogged->getUserId()); $result = $this->getDB()->update(USER_TABLE, $set, $where); return $result; } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
public function loadPage($customPage = NULL) { $userLogged = SessionUtils::getUserLogged(); if (is_null($userLogged)) { $this->render('Header'); } else { if ($userLogged->getRole() == ADMIN) { $this->render('HeaderAdmin'); } else { $this->render('Header'); } } if (!is_null($customPage)) { $this->render($customPage); } else { $this->render($this->controllerName); } $this->render('Footer'); }