Exemple #1
0
 /**
  * POST: /main/create-comment
  */
 public function createCommentPost()
 {
     $pageId = $_REQUEST['PageId'];
     $commentId = $_REQUEST['CommentId'];
     $body = $_REQUEST['Body'];
     $pageDAO = new PageDAO();
     $page = $pageDAO->getPage($pageId);
     if ($page->feedbackType != PageEntity::$FEEDBACK_COMMENTS_AUTH || Authentication::isAuthenticated()) {
         $captcha = true;
         if ($page->feedbackType == PageEntity::$FEEDBACK_COMMENTS_CAPTCHA && !Authentication::isAuthenticated()) {
             $captcha = Captcha::getCaptcha($commentId) == $_REQUEST['Captcha'];
         }
         if ($captcha) {
             $commentId = $commentId == 0 ? null : $commentId;
             $browsingId = Browsing::getBrowsingId();
             $userId = Authentication::isAuthenticated() ? Authentication::getUserEntity()->id : null;
             $commentOnPageDAO = new CommentOnPageDAO();
             $newCommentId = $commentOnPageDAO->createCommentOnPage($pageId, $commentId, $browsingId, $userId, $body);
             $newComment = $commentOnPageDAO->getCommentOnPage($newCommentId);
             echo CommentOnPageHelper::comment($newComment, $page->feedbackType);
         } else {
             echo 'captcha';
         }
     }
 }