コード例 #1
0
ファイル: create.php プロジェクト: sebadorn/aestas3
/**
 * Update the comment.
 * @return {int} ID of the comment.
 */
function updateComment()
{
    if (!isset($_POST['edit-id'], $_POST['comment-author-name'], $_POST['comment-author-email'], $_POST['comment-author-url'], $_POST['comment-content'], $_POST['comment-user']) || $_POST['comment-content'] === '') {
        header('Location: ../admin.php?error=missing_data_for_comment');
        exit;
    }
    $content = nl2br($_POST['comment-content']);
    $comment = new ae_CommentModel();
    $comment->load($_POST['edit-id']);
    $comment->setAuthorName($_POST['comment-author-name']);
    $comment->setAuthorEmail($_POST['comment-author-email']);
    $comment->setAuthorUrl($_POST['comment-author-url']);
    $comment->setContent($content);
    $comment->setUserId($_POST['comment-user']);
    if (!$comment->save()) {
        return FALSE;
    }
    return $comment->getId();
}
コード例 #2
0
 public function testSetContent()
 {
     $c = new ae_CommentModel();
     $c->setContent('  lorem  <strong>ipsum</strong>   ');
     $this->assertEquals($c->getContent(), 'lorem  <strong>ipsum</strong>');
 }
コード例 #3
0
ファイル: comment.php プロジェクト: sebadorn/aestas3
$content = nl2br($content);
$co = new ae_CommentModel();
// Bad errors
try {
    $co->setPostId($_POST['comment-post']);
} catch (Exception $exc) {
    header('Location: ../?p=' . $_POST['comment-post'] . '&error=invalid_data#comment-form');
    exit;
}
// Forgivable errors with default values for fallback
try {
    $co->setAuthorName($_POST['comment-author-name']);
    $co->setAuthorEmail($_POST['comment-author-email']);
    $co->setAuthorUrl($url);
    $co->setAuthorIp($_SERVER['REMOTE_ADDR']);
    $co->setContent($content);
    $co->setStatus(COMMENT_DEFAULT_STATUS);
    if (ae_Security::isLoggedIn()) {
        $co->setUserId(ae_Security::getCurrentUserId());
    }
    $filter = array('LIMIT' => FALSE, 'WHERE' => 'cf_status = :status');
    $params = array(':status' => ae_CommentfilterModel::STATUS_ACTIVE);
    $cfList = new ae_CommentfilterList($filter, $params, FALSE);
    $keep = $cfList->applyFilters($co);
    if (!$keep) {
        header('Location: ../?p=' . $_POST['comment-post'] . '&error=comment_deleted_by_filter');
        exit;
    }
    $co->save();
} catch (Exception $exc) {
    header('Location: ../?p=' . $_POST['comment-post'] . '&error=failed_to_save#comment-form');