コード例 #1
0
 public function testSetAction()
 {
     $c = new ae_CommentfilterModel();
     $c->setAction(ae_CommentfilterModel::ACTION_DROP);
     $this->assertTrue($c->getAction() === ae_CommentfilterModel::ACTION_DROP);
     $this->setExpectedException('Exception');
     $c->setAction(TRUE);
 }
コード例 #2
0
ファイル: create.php プロジェクト: sebadorn/aestas3
/**
 * Create the comment filter.
 * @return {int} ID of the comment filter.
 */
function createCommentfilter()
{
    if (!isset($_POST['cf-name'], $_POST['cf-target'], $_POST['cf-match'], $_POST['cf-action'], $_POST['submit'])) {
        header('Location: ../admin.php?error=missing_data_for_cofilter');
        exit;
    }
    $cf = new ae_CommentfilterModel();
    if (isset($_POST['edit-id'])) {
        $cf->setId($_POST['edit-id']);
    }
    $cf->setName($_POST['cf-name']);
    $cf->setMatchTarget($_POST['cf-target']);
    try {
        $cf->setMatchRule($_POST['cf-match']);
    } catch (Exception $exc) {
        header('Location: ../admin.php?area=settings&cofilter&error=invalid_regex');
        exit;
    }
    $cf->setAction($_POST['cf-action']);
    $cf->setStatus(isset($_POST['cf-status']) ? $_POST['cf-status'] : ae_CommentfilterModel::STATUS_ACTIVE);
    $cf->save();
    return $cf->getId();
}