Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 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;
     }
 }