Пример #1
0
 public function confirmFriendshipModel($notificationId, $userForm)
 {
     $formObjRaw = new FormDTO(CONFIRM_FRIENDSHIP_FORM, $userForm);
     $formObjRaw->setSubElementId($notificationId);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $friendDAO = new FriendsDAO();
         $result = $friendDAO->confirmFriendship($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
         $userDAO = new UserDAO();
         $friendDTO = $userDAO->getUserByUserId($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
         $friendDTO->setPassword(NULL);
         $notificationDAO = new NotificationDAO();
         $result = $notificationDAO->setNotificationAsRead($formDataObj[CONFIRM_FRIENDSHIP_FORM . NOTIFICATIONID]);
         SessionUtils::addFriendInUserLoggedFriendList($friendDTO, date(DATE_FORMAT));
         DataModelUtils::notifyAction($friendDTO->getUserId() . SEPARATOR . $friendDTO->getUserName(), CONFIRM_FRIENDSHIP_FORM);
         return $friendDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #2
0
 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;
     }
 }