function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $parent)
{
    qa_comment_set_status($oldcomment, $hidden ? QA_POST_STATUS_HIDDEN : QA_POST_STATUS_NORMAL, $userid, $handle, $cookieid, $question, $parent);
}
Ejemplo n.º 2
0
function qa_page_q_single_click_c($comment, $question, $parent, &$error)
{
    $userid = qa_get_logged_in_userid();
    $handle = qa_get_logged_in_handle();
    $cookieid = qa_cookie_get();
    $prefix = 'c' . $comment['postid'] . '_';
    if (qa_clicked($prefix . 'dohide') && $comment['hideable'] || qa_clicked($prefix . 'doreject') && $comment['moderatable']) {
        if (qa_page_q_click_check_form_code($parent, $error)) {
            qa_comment_set_hidden($comment, true, $userid, $handle, $cookieid, $question, $parent);
            return true;
        }
    }
    if (qa_clicked($prefix . 'doreshow') && $comment['reshowable'] || qa_clicked($prefix . 'doapprove') && $comment['moderatable']) {
        if (qa_page_q_click_check_form_code($parent, $error)) {
            if ($comment['moderatable'] || $comment['reshowimmed']) {
                $status = QA_POST_STATUS_NORMAL;
            } else {
                $in = qa_page_q_prepare_post_for_filters($comment);
                $filtermodules = qa_load_modules_with('filter', 'filter_comment');
                // run through filters but only for queued status
                foreach ($filtermodules as $filtermodule) {
                    $tempin = $in;
                    // always pass original comment in because we aren't modifying anything else
                    $filtermodule->filter_comment($tempin, $temperrors, $question, $parent, $comment);
                    $in['queued'] = $tempin['queued'];
                    // only preserve queued status in loop
                }
                $status = $in['queued'] ? QA_POST_STATUS_QUEUED : QA_POST_STATUS_NORMAL;
            }
            qa_comment_set_status($comment, $status, $userid, $handle, $cookieid, $question, $parent);
            return true;
        }
    }
    if (qa_clicked($prefix . 'dodelete') && $comment['deleteable'] && qa_page_q_click_check_form_code($parent, $error)) {
        qa_comment_delete($comment, $question, $parent, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_clicked($prefix . 'doclaim') && $comment['claimable'] && qa_page_q_click_check_form_code($parent, $error)) {
        if (qa_user_limits_remaining(QA_LIMIT_COMMENTS)) {
            qa_comment_set_userid($comment, $userid, $handle, $cookieid);
            return true;
        } else {
            $error = qa_lang_html('question/comment_limit');
        }
    }
    if (qa_clicked($prefix . 'doflag') && $comment['flagbutton'] && qa_page_q_click_check_form_code($parent, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        $error = qa_flag_error_html($comment, $userid, qa_request());
        if (!$error) {
            if (qa_flag_set_tohide($comment, $userid, $handle, $cookieid, $question)) {
                qa_comment_set_hidden($comment, true, null, null, null, $question, $parent);
            }
            // hiding not really by this user so pass nulls
            return true;
        }
    }
    if (qa_clicked($prefix . 'dounflag') && $comment['unflaggable'] && qa_page_q_click_check_form_code($parent, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        qa_flag_clear($comment, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_clicked($prefix . 'doclearflags') && $comment['clearflaggable'] && qa_page_q_click_check_form_code($parent, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        qa_flags_clear_all($comment, $userid, $handle, $cookieid);
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
function qa_post_set_status($postid, $status, $byuserid = null)
{
    $oldpost = qa_post_get_full($postid, 'QAC');
    $byhandle = qa_post_userid_to_handle($byuserid);
    switch ($oldpost['basetype']) {
        case 'Q':
            $answers = qa_post_get_question_answers($postid);
            $commentsfollows = qa_post_get_question_commentsfollows($postid);
            $closepost = qa_post_get_question_closepost($postid);
            qa_question_set_status($oldpost, $status, $byuserid, $byhandle, null, $answers, $commentsfollows, $closepost);
            break;
        case 'A':
            $question = qa_post_get_full($oldpost['parentid'], 'Q');
            $commentsfollows = qa_post_get_answer_commentsfollows($postid);
            qa_answer_set_status($oldpost, $status, $byuserid, $byhandle, null, $question, $commentsfollows);
            break;
        case 'C':
            $parent = qa_post_get_full($oldpost['parentid'], 'QA');
            $question = qa_post_parent_to_question($parent);
            qa_comment_set_status($oldpost, $status, $byuserid, $byhandle, null, $question, $parent);
            break;
    }
}