/** * @param $pageEntities * @param $pageEntity * @param $i */ private static function _setPage($pageEntities, $pageEntity, $i) { $parentIds = $pageEntity->parentIds; if (count($parentIds) > $i) { if ($pageEntities[$parentIds[$i]]->id == $pageEntity->parentId) { $pageEntities[$parentIds[$i]]->childPages[$pageEntity->id] = $pageEntity; } else { PageDAO::_setPage($pageEntities[$parentIds[$i]]->childPages, $pageEntity, $i + 1); } } }
/** * 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'; } } }