Exemplo n.º 1
0
 public function getAction($request, $db)
 {
     $comment_id = $this->getItemId($request);
     // verbosity
     $verbose = $this->getVerbosity($request);
     // pagination settings
     $start = $this->getStart($request);
     $resultsperpage = $this->getResultsPerPage($request);
     $mapper = new EventCommentMapper($db, $request);
     if ($comment_id) {
         $list = $mapper->getCommentById($comment_id, $verbose);
         return $list;
     }
     return false;
 }
 public function reportComment($request, $db)
 {
     // must be logged in to report a comment
     if (!isset($request->user_id) || empty($request->user_id)) {
         throw new Exception('You must log in to report a comment');
     }
     $comment_mapper = new EventCommentMapper($db, $request);
     $commentId = $this->getItemId($request);
     $commentInfo = $comment_mapper->getCommentInfo($commentId);
     if (false === $commentInfo) {
         throw new Exception('Comment not found', 404);
     }
     $eventId = $commentInfo['event_id'];
     $comment_mapper->userReportedComment($commentId, $request->user_id);
     // notify event admins
     $comment = $comment_mapper->getCommentById($commentId, true, true);
     $event_mapper = new EventMapper($db, $request);
     $recipients = $event_mapper->getHostsEmailAddresses($eventId);
     $event = $event_mapper->getEventById($eventId, true, true);
     $emailService = new EventCommentReportedEmailService($this->config, $recipients, $comment, $event);
     $emailService->sendEmail();
     // send them to the comments collection
     $uri = $request->base . '/' . $request->version . '/events/' . $eventId . "/comments";
     header("Location: " . $uri, true, 202);
     exit;
 }