['regexp' => POLL_REGEX]]); $poll = $pollService->findById($poll_id); } if (!$poll) { $message = new Message('error', __('Error', 'This poll doesn\'t exist !')); } else if ($poll && !$securityService->canAccessPoll($poll)) { $message = new Message('error', __('Password', 'Wrong password')); } else { $name = $inputService->filterName($_POST['name']); $comment = $inputService->filterComment($_POST['comment']); if ($name == null) { $message = new Message('danger', __('Error', 'The name is invalid.')); } if ($message == null) { // Add comment $result = $pollService->addComment($poll_id, $name, $comment); if ($result) { $message = new Message('success', __('Comments', 'Comment added')); $notificationService->sendUpdateNotification($poll, $mailService, $name, NotificationService::ADD_COMMENT); } else { $message = new Message('danger', __('Error', 'Comment failed')); } } $comments = $pollService->allCommentsByPollId($poll_id); } error_reporting(E_ALL & ~E_NOTICE); $smarty->error_reporting = E_ALL & ~E_NOTICE; $smarty->assign('comments', $comments); $comments_html = $smarty->fetch('part/comments_list.tpl'); $response = array('result' => $result, 'message' => $message, 'comments' => $comments_html); echo json_encode($response);