function qa_page_q_edit_a_submit($answer, $question, $answers, $commentsfollows, &$in, &$errors) { $answerid = $answer['postid']; $prefix = 'a' . $answerid . '_'; $in = array('dotoc' => qa_post_text($prefix . 'dotoc'), 'commenton' => qa_post_text($prefix . 'commenton')); if ($answer['isbyuser']) { $in['notify'] = qa_post_text($prefix . 'notify') ? true : false; $in['email'] = qa_post_text($prefix . 'email'); } qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $errors = array(); $filtermodules = qa_load_modules_with('filter', 'filter_answer'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_answer($in, $errors, $question, $answer); qa_update_post_text($in, $oldin); } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); $setnotify = $answer['isbyuser'] ? qa_combine_notify_email($answer['userid'], $in['notify'], $in['email']) : $answer['notify']; if ($in['dotoc'] && ($in['commenton'] == $question['postid'] && $question['commentable'] || $in['commenton'] != $answerid && @$answers[$in['commenton']]['commentable'])) { // convert to a comment if (qa_limits_remaining($userid, QA_LIMIT_COMMENTS)) { // already checked 'permit_post_c' qa_answer_to_comment($answer, $in['commenton'], $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, $answers, $commentsfollows); return 'C'; // to signify that redirect should be to the comment } else { $errors['content'] = qa_lang_html('question/comment_limit'); } // not really best place for error, but it will do } else { qa_answer_set_content($answer, $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question); return 'A'; } } return null; }
function qa_page_q_edit_a_submit($answer, $question, $answers, $commentsfollows, &$in, &$errors) { $answerid = $answer['postid']; $prefix = 'a' . $answerid . '_'; $in = array('dotoc' => qa_post_text($prefix . 'dotoc'), 'commenton' => qa_post_text($prefix . 'commenton')); if ($answer['isbyuser']) { $in['name'] = qa_post_text($prefix . 'name'); $in['notify'] = qa_post_text($prefix . 'notify') ? true : false; $in['email'] = qa_post_text($prefix . 'email'); } if (!qa_user_post_permit_error('permit_edit_silent', $answer)) { $in['silent'] = qa_post_text($prefix . 'silent'); } qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']); // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters $errors = array(); if (!qa_check_form_security_code('edit-' . $answerid, qa_post_text($prefix . 'code'))) { $errors['content'] = qa_lang_html('misc/form_security_again'); } else { $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason(qa_user_level_for_post($answer)); $filtermodules = qa_load_modules_with('filter', 'filter_answer'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_answer($in, $errors, $question, $answer); qa_update_post_text($in, $oldin); } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); if (!isset($in['silent'])) { $in['silent'] = false; } $setnotify = $answer['isbyuser'] ? qa_combine_notify_email($answer['userid'], $in['notify'], $in['email']) : $answer['notify']; if ($in['dotoc'] && ($in['commenton'] == $question['postid'] && $question['commentable'] || $in['commenton'] != $answerid && @$answers[$in['commenton']]['commentable'])) { // convert to a comment if (qa_user_limits_remaining(QA_LIMIT_COMMENTS)) { // already checked 'permit_post_c' qa_answer_to_comment($answer, $in['commenton'], $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, $answers, $commentsfollows, @$in['name'], $in['queued'], $in['silent']); return 'C'; // to signify that redirect should be to the comment } else { $errors['content'] = qa_lang_html('question/comment_limit'); } // not really best place for error, but it will do } else { qa_answer_set_content($answer, $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, @$in['name'], $in['queued'], $in['silent']); return 'A'; } } } return null; }
} elseif (qa_clicked('doedita_' . $answerid)) { qa_redirect($qa_request, array('state' => 'edit-' . $answerid)); } elseif (qa_clicked('dosavea_' . $answerid) && qa_page_q_permit_edit($answer, 'permit_edit_a')) { $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); $intocomment = qa_post_text('tocomment'); $incommenton = qa_post_text('commenton'); qa_get_post_content('editor', 'acontent', $ineditor, $inacontent, $inaformat, $inatext); $aerrors = qa_answer_validate($inacontent, $inaformat, $inatext, $innotify, $inemail); if (empty($aerrors)) { $setnotify = $answer['isbyuser'] ? qa_combine_notify_email($answer['userid'], $innotify, $inemail) : $answer['notify']; if ($intocomment && ($incommenton == $questionid && $question['commentable'] || $incommenton != $answerid && @$answers[$incommenton]['commentable'])) { // convert to a comment if (qa_limits_remaining($qa_login_userid, 'C')) { // already checked 'permit_post_c' qa_answer_to_comment($answer, $incommenton, $inacontent, $inaformat, $inatext, $setnotify, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question, $answers, $commentsfollows); qa_report_write_action($qa_login_userid, $qa_cookieid, 'a_to_c', $questionid, $answerid, null); qa_redirect($qa_request, null, null, null, qa_anchor('C', $answerid)); } else { $pageerror = qa_lang_html('question/comment_limit'); } } else { qa_answer_set_content($answer, $inacontent, $inaformat, $inatext, $setnotify, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question); qa_report_write_action($qa_login_userid, $qa_cookieid, 'a_edit', $questionid, $answerid, null); qa_redirect($qa_request, null, null, null, qa_anchor('A', $answerid)); } } else { $formtype = 'a_edit'; $formpostid = $answerid; // keep editing if an error }