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;
}
Esempio n. 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;
}
}
if (qa_clicked('doshowq') && $question['reshowable']) {
    qa_question_set_hidden($question, false, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $answers, $commentsfollows);
    qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_reshow', $questionid, null, null);
    qa_redirect($qa_request);
}
if (qa_clicked('dodeleteq') && $question['deleteable']) {
    qa_question_delete($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid);
    qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_delete', $questionid, null, null);
    qa_redirect('');
    // redirect since question has gone
}
if (qa_clicked('doclaimq') && $question['claimable']) {
    if (qa_limits_remaining($qa_login_userid, 'Q')) {
        // already checked 'permit_post_q'
        qa_question_set_userid($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid);
        qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_claim', $questionid, null, null);
        qa_redirect($qa_request);
    } else {
        $pageerror = qa_lang_html('question/ask_limit');
    }
}
//	Process flag or unflag button for question
if (qa_clicked('doflagq') && $question['flagbutton']) {
    require_once QA_INCLUDE_DIR . 'qa-app-votes.php';
    $pageerror = qa_flag_error_html($question, $qa_login_userid, $qa_request);
    if (!$pageerror) {
        if (qa_flag_set_tohide($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question)) {
            qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows);
        }
        // hiding not really by this user so pass nulls