} } } // Process adding a comment to question (shows form or processes it) if ($question['commentbutton']) { if (qa_clicked('q_docomment')) { qa_page_q_refresh($pagestart, 'comment-' . $questionid); } if (qa_clicked('c' . $questionid . '_doadd') || $pagestate == 'comment-' . $questionid) { qa_page_q_do_comment($question, $question, $commentsfollows, $pagestart, $usecaptcha, $cnewin, $cnewerrors, $formtype, $formpostid, $pageerror); } } // Process clicked buttons for answers foreach ($answers as $answerid => $answer) { $prefix = 'a' . $answerid . '_'; if (qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, true, $pageerror)) { qa_page_q_refresh($pagestart, null, 'A', $answerid); } if ($answer['editbutton']) { if (qa_clicked($prefix . 'doedit')) { qa_page_q_refresh($pagestart, 'edit-' . $answerid); } elseif (qa_clicked($prefix . 'dosave') && qa_page_q_permit_edit($answer, 'permit_edit_a', $pageerror)) { $editedtype = qa_page_q_edit_a_submit($answer, $question, $answers, $commentsfollows, $aeditin[$answerid], $aediterrors[$answerid]); if (isset($editedtype)) { qa_page_q_refresh($pagestart, null, $editedtype, $answerid); } else { $formtype = 'a_edit'; $formpostid = $answerid; // keep editing if an error } } elseif ($pagestate == 'edit-' . $answerid && qa_page_q_permit_edit($answer, 'permit_edit_a', $pageerror)) {
require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-page-question-view.php'; require_once QA_INCLUDE_DIR . 'qa-page-question-submit.php'; // Load relevant information about this answer $answerid = qa_post_text('answerid'); $questionid = qa_post_text('questionid'); $userid = qa_get_logged_in_userid(); list($answer, $question, $qchildposts, $achildposts) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $answerid), qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $answerid)); // Check if there was an operation that succeeded if (@$answer['basetype'] == 'A' && @$question['basetype'] == 'Q') { $answers = qa_page_q_load_as($question, $qchildposts); $question = $question + qa_page_q_post_rules($question, null, null, $qchildposts); // array union $answer = $answer + qa_page_q_post_rules($answer, $question, $qchildposts, $achildposts); if (qa_page_q_single_click_a($answer, $question, $answers, $achildposts, false, $error)) { list($answer, $question) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $answerid), qa_db_full_post_selectspec($userid, $questionid)); // If so, page content to be updated via Ajax echo "QA_AJAX_RESPONSE\n1\n"; // Send back new count of answers $countanswers = $question['acount']; if ($countanswers == 1) { echo qa_lang_html('question/1_answer_title'); } else { echo qa_lang_html_sub('question/x_answers_title', $countanswers); } // If the answer was not deleted.... if (isset($answer)) { $question = $question + qa_page_q_post_rules($question, null, null, $qchildposts); // array union $answer = $answer + qa_page_q_post_rules($answer, $question, $qchildposts, $achildposts);