function qa_page_q_do_comment($question, $parent, $commentsfollows, $pagestart, $usecaptcha, &$cnewin, &$cnewerrors, &$formtype, &$formpostid, &$error)
{
    // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here
    // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...)
    $answer = $question['postid'] == $parent['postid'] ? null : $parent;
    $parentid = $parent['postid'];
    switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) {
        case 'login':
            $error = qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request());
            break;
        case 'confirm':
            $error = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request());
            break;
        case 'approve':
            $error = qa_lang_html('question/comment_must_be_approved');
            break;
        case 'limit':
            $error = qa_lang_html('question/comment_limit');
            break;
        default:
            $error = qa_lang_html('users/no_permission');
            break;
        case false:
            if (qa_clicked('c' . $parentid . '_doadd')) {
                $commentid = qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, $cnewin[$parentid], $cnewerrors[$parentid]);
                if (isset($commentid)) {
                    qa_page_q_refresh($pagestart, null, $parent['basetype'], $parentid);
                } else {
                    $formtype = 'c_add';
                    $formpostid = $parentid;
                    // show form again
                }
            } else {
                $formtype = 'c_add';
                $formpostid = $parentid;
                // show form first time
            }
            break;
    }
}
function qa_page_q_do_comment($question, $parent, $commentsfollows, $pagestart, $usecaptcha, &$cnewin, &$cnewerrors, &$formtype, &$formpostid, &$error)
{
    $answer = $question['postid'] == $parent['postid'] ? null : $parent;
    $parentid = $parent['postid'];
    switch (qa_user_permit_error('permit_post_c', QA_LIMIT_COMMENTS)) {
        case 'login':
            $error = qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request());
            break;
        case 'confirm':
            $error = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request());
            break;
        case 'limit':
            $error = qa_lang_html('question/comment_limit');
            break;
        default:
            $error = qa_lang_html('users/no_permission');
            break;
        case false:
            if (qa_clicked('c' . $parentid . '_doadd')) {
                $commentid = qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, $cnewin[$parentid], $cnewerrors[$parentid]);
                if (isset($commentid)) {
                    qa_page_q_refresh($pagestart, null, $parent['basetype'], $parentid);
                } else {
                    $formtype = 'c_add';
                    $formpostid = $parentid;
                    // show form again
                }
            } else {
                $formtype = 'c_add';
                $formpostid = $parentid;
                // show form first time
            }
            break;
    }
}