break; case 'confirm': $pageerror = qa_insert_login_links(qa_lang_html('question/answer_must_confirm'), qa_request()); break; case 'approve': $pageerror = qa_lang_html('question/answer_must_be_approved'); break; case 'limit': $pageerror = qa_lang_html('question/answer_limit'); break; default: $pageerror = qa_lang_html('users/no_permission'); break; case false: if (qa_clicked('a_doadd')) { $answerid = qa_page_q_add_a_submit($question, $answers, $usecaptcha, $anewin, $anewerrors); if (isset($answerid)) { qa_page_q_refresh(0, null, 'A', $answerid); } else { $formtype = 'a_add'; } // show form again } else { $formtype = 'a_add'; } // show form as if first time break; } } } // Process close buttons for question
function ra_ajax_add_answer() { // Load relevant information about this question $questionid = qa_post_text('a_questionid'); $userid = qa_get_logged_in_userid(); list($question, $childposts) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid)); // Check if the question exists, is not closed, and whether the user has permission to do this if (@$question['basetype'] == 'Q' && !isset($question['closedbyid']) && !qa_user_post_permit_error('permit_post_a', $question, QA_LIMIT_ANSWERS)) { require_once QA_INCLUDE_DIR . 'qa-app-captcha.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-post-create.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-page-question-view.php'; require_once QA_INCLUDE_DIR . 'qa-page-question-submit.php'; // Try to create the new answer $usecaptcha = qa_user_use_captcha(qa_user_level_for_post($question)); $answers = qa_page_q_load_as($question, $childposts); $answerid = qa_page_q_add_a_submit($question, $answers, false, $in, $errors); if ($answerid) { return true; } } die; }