function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error)
{
    require_once QA_INCLUDE_DIR . 'qa-app-post-update.php';
    require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
    $userid = qa_get_logged_in_userid();
    $handle = qa_get_logged_in_handle();
    $cookieid = qa_cookie_get();
    if (qa_page_q_clicked('q_doreopen') && $question['reopenable']) {
        qa_question_close_clear($question, $closepost, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_page_q_clicked('q_dohide') && $question['hideable'] || qa_page_q_clicked('q_doreject') && $question['moderatable']) {
        qa_question_set_hidden($question, true, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost);
        return true;
    }
    if (qa_page_q_clicked('q_doreshow') && $question['reshowable'] || qa_page_q_clicked('q_doapprove') && $question['moderatable']) {
        qa_question_set_hidden($question, false, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost);
        return true;
    }
    if (qa_page_q_clicked('q_doclaim') && $question['claimable']) {
        if (qa_limits_remaining($userid, QA_LIMIT_QUESTIONS)) {
            // already checked 'permit_post_q'
            qa_question_set_userid($question, $userid, $handle, $cookieid);
            return true;
        } else {
            $error = qa_lang_html('question/ask_limit');
        }
    }
    if (qa_page_q_clicked('q_doflag') && $question['flagbutton']) {
        require_once QA_INCLUDE_DIR . 'qa-app-votes.php';
        $error = qa_flag_error_html($question, $userid, qa_request());
        if (!$error) {
            if (qa_flag_set_tohide($question, $userid, $handle, $cookieid, $question)) {
                qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows, $closepost);
            }
            // hiding not really by this user so pass nulls
            return true;
        }
    }
    if (qa_page_q_clicked('q_dounflag') && $question['unflaggable']) {
        require_once QA_INCLUDE_DIR . 'qa-app-votes.php';
        qa_flag_clear($question, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_page_q_clicked('q_doclearflags') && $question['clearflaggable']) {
        require_once QA_INCLUDE_DIR . 'qa-app-votes.php';
        qa_flags_clear_all($question, $userid, $handle, $cookieid);
        return true;
    }
    return false;
}
Example #2
0
function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error)
{
    require_once QA_INCLUDE_DIR . 'app/post-update.php';
    require_once QA_INCLUDE_DIR . 'app/limits.php';
    $userid = qa_get_logged_in_userid();
    $handle = qa_get_logged_in_handle();
    $cookieid = qa_cookie_get();
    if (qa_clicked('q_doreopen') && $question['reopenable'] && qa_page_q_click_check_form_code($question, $error)) {
        qa_question_close_clear($question, $closepost, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_clicked('q_dohide') && $question['hideable'] || qa_clicked('q_doreject') && $question['moderatable']) {
        if (qa_page_q_click_check_form_code($question, $error)) {
            qa_question_set_hidden($question, true, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost);
            return true;
        }
    }
    if (qa_clicked('q_doreshow') && $question['reshowable'] || qa_clicked('q_doapprove') && $question['moderatable']) {
        if (qa_page_q_click_check_form_code($question, $error)) {
            if ($question['moderatable'] || $question['reshowimmed']) {
                $status = QA_POST_STATUS_NORMAL;
            } else {
                $in = qa_page_q_prepare_post_for_filters($question);
                $filtermodules = qa_load_modules_with('filter', 'filter_question');
                // run through filters but only for queued status
                foreach ($filtermodules as $filtermodule) {
                    $tempin = $in;
                    // always pass original question in because we aren't modifying anything else
                    $filtermodule->filter_question($tempin, $temperrors, $question);
                    $in['queued'] = $tempin['queued'];
                    // only preserve queued status in loop
                }
                $status = $in['queued'] ? QA_POST_STATUS_QUEUED : QA_POST_STATUS_NORMAL;
            }
            qa_question_set_status($question, $status, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost);
            return true;
        }
    }
    if (qa_clicked('q_doclaim') && $question['claimable'] && qa_page_q_click_check_form_code($question, $error)) {
        if (qa_user_limits_remaining(QA_LIMIT_QUESTIONS)) {
            // already checked 'permit_post_q'
            qa_question_set_userid($question, $userid, $handle, $cookieid);
            return true;
        } else {
            $error = qa_lang_html('question/ask_limit');
        }
    }
    if (qa_clicked('q_doflag') && $question['flagbutton'] && qa_page_q_click_check_form_code($question, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        $error = qa_flag_error_html($question, $userid, qa_request());
        if (!$error) {
            if (qa_flag_set_tohide($question, $userid, $handle, $cookieid, $question)) {
                qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows, $closepost);
            }
            // hiding not really by this user so pass nulls
            return true;
        }
    }
    if (qa_clicked('q_dounflag') && $question['unflaggable'] && qa_page_q_click_check_form_code($question, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        qa_flag_clear($question, $userid, $handle, $cookieid);
        return true;
    }
    if (qa_clicked('q_doclearflags') && $question['clearflaggable'] && qa_page_q_click_check_form_code($question, $error)) {
        require_once QA_INCLUDE_DIR . 'app/votes.php';
        qa_flags_clear_all($question, $userid, $handle, $cookieid);
        return true;
    }
    return false;
}
function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $handle, $cookieid)
{
    qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle, $cookieid);
    $postid = qa_db_post_create('NOTE', $oldquestion['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $note, '', null, null, $oldquestion['categoryid']);
    qa_db_posts_calc_category_path($postid);
    if ($oldquestion['type'] == 'Q') {
        qa_post_index($postid, 'NOTE', $oldquestion['postid'], $oldquestion['postid'], null, $note, '', $note, null, $oldquestion['categoryid']);
    }
    qa_db_post_set_closed($oldquestion['postid'], $postid, $userid, qa_remote_ip_address());
    qa_report_event('q_close', $userid, $handle, $cookieid, array('postid' => $oldquestion['postid'], 'oldquestion' => $oldquestion, 'reason' => 'other', 'note' => $note));
}
Example #4
0
function qa_post_set_closed($questionid, $closed = true, $originalpostid = null, $note = null, $byuserid = null)
{
    $oldquestion = qa_post_get_full($questionid, 'Q');
    $oldclosepost = qa_post_get_question_closepost($questionid);
    $byhandle = qa_post_userid_to_handle($byuserid);
    if ($closed) {
        if (isset($originalpostid)) {
            qa_question_close_duplicate($oldquestion, $oldclosepost, $originalpostid, $byuserid, $byhandle, null);
        } elseif (isset($note)) {
            qa_question_close_other($oldquestion, $oldclosepost, $note, $byuserid, $byhandle, null);
        } else {
            qa_fatal_error('Question must be closed as a duplicate or with a note');
        }
    } else {
        qa_question_close_clear($oldquestion, $oldclosepost, $byuserid, $byhandle, null);
    }
}