function deleteFriendModel($friendId) { try { $responseDTO = new ResponseDTO(DELETE_FRIEND_FORM); $friendsDAO = new FriendsDAO(); $oldFriend = $friendsDAO->deleteFriend($friendId); SessionUtils::deleteFriendInUserLoggedFriendList($friendId); $responseDTO->setResponseSucc("friend" . $friendId); return $responseDTO; } 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 function denyFriendshipModel($notificationId, $userForm) { $formObjRaw = new FormDTO(DENY_FRIENDSHIP_FORM, $userForm); $formObjRaw->setSubElementId($notificationId); try { $formDataObj = $formObjRaw->getFormData(); $friendDAO = new FriendsDAO(); $friendId = $friendDAO->deleteFriend($formDataObj[DENY_FRIENDSHIP_FORM . FRIENDID]); $notificationDAO = new NotificationDAO(); $notificationDAO->deleteNotificationByNotificationId($notificationId); $responseDTO = new ResponseDTO(DENY_REGISTRATION_FORM); $responseDTO->setResponseSucc($notificationId); return $notificationId; } catch (PDOException $pdoe) { throw $pdoe; } catch (Exception $e) { throw $e; } }
/** * * @param <User> $user * @return <Array> */ public function getFriends(User $user) { $friendDAO = new FriendsDAO(); return $friendDAO->getAllFriends($user); }
public static function notifyAction($object, $context) { $notificationDAO = new NotificationDAO(); $timestamp = date(DATE_FORMAT); $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList(); if ($context === REGISTRATION_FORM) { $user = explode(SEPARATOR, $object); $message = DataModelUtils::getNotificationMessage($object, $context); $notificationDTO = new NotifyDTO(NULL, $user[0], 1, $message, 0, $timestamp, $context, $user[0] . SEPARATOR . $user[1]); $notificationDAO->saveNewNotification($notificationDTO); } else { if ($context === ADD_FRIEND_FORM) { $userLogged = SessionUtils::getUserLogged(); $friend = explode(SEPARATOR, $object); $message = DataModelUtils::getNotificationMessage($object, $context); $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]); $notificationDAO->saveNewNotification($notificationDTO); } else { if ($context === CONFIRM_FRIENDSHIP_FORM) { $userLogged = SessionUtils::getUserLogged(); $friend = explode(SEPARATOR, $object); $message = DataModelUtils::getNotificationMessage($object, $context, TOMYSELF); $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $userLogged->getUserId(), $message, 1, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]); $result = $notificationDAO->saveNewNotification($notificationDTO); $message = DataModelUtils::getNotificationMessage($object, $context, TOMINENEWFRIEND); $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]); $result = $notificationDAO->saveNewNotification($notificationDTO); $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList(); SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp, TOMYFRIENDSLIST); $friendsDAO = new FriendsDAO(); $myfriendFriendList = $friendsDAO->getNewFriendsFriendList($userLogged->getUserId(), $friend[0]); SessionUtils::prepareNotificationToFriends($object, $context, $myfriendFriendList, $timestamp, TOMINENEWFRIENDFRIENDLIST); $message = '<a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</label></a> ha stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '"><label>' . $friend[1] . '</label></a>'; $adminNotificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), 1, $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]); $notificationDAO->saveNewNotification($adminNotificationDTO); } else { $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList(); SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp); } } } }
public static function prepareLoginSession($userDTO) { $userFriendsList = array(); SessionUtils::setUserLogged($userDTO); SessionUtils::setDashboardId($userDTO->getUserId()); SessionUtils::setNavigationSelectedItem(0); $friendsDAO = new FriendsDAO(); $userFriends = $friendsDAO->getFriendsList($userDTO->getUserId()); if (!is_null($userFriends)) { foreach ($userFriends as $key => $friendDTO) { $userFriendsList[$friendDTO->getFriendId()->getUserId()] = $friendDTO; } } SessionUtils::setUserLoggedFriendsList($userFriendsList); }
function prepareAndDoLogin($userLoggedDTO, $rememberMe) { $userDAO = new UserDAO(); $userLoggedDTO = SessionUtils::clearSensibleDataForSession($userLoggedDTO); SessionUtils::setUserLogged($userLoggedDTO); SessionUtils::setDashboardId($userLoggedDTO->getUserId()); SessionUtils::setNavigationSelectedItem(0); SessionUtils::generateToken(); $userDAO->saveUserToken(SessionUtils::getSessionToken()); if ($rememberMe) { $userDAO = new UserDAO(); $setCookieBoolValue = setcookie(SHAREATRIPCOOKIE, SessionUtils::getSessionToken(), time() + 60 * 60 * 24 * 300, "/", NULL, NULL, TRUE); SessionUtils::setRememberMe(true); } else { SessionUtils::setRememberMe(false); } $userFriendsList = array(); $friendsDAO = new FriendsDAO(); $userFriends = $friendsDAO->getFriendsList($userLoggedDTO->getUserId()); if (!is_null($userFriends)) { foreach ($userFriends as $key => $friendDTO) { $userFriendsList[$friendDTO->getFriendId()->getUserId()] = $friendDTO; } } SessionUtils::setUserLoggedFriendsList($userFriendsList); }