function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $notify, $userid, $handle, $cookieid, $question, $answers, $commentsfollows, $name = null, $remoderate = false, $silent = false) { $parent = isset($answers[$parentid]) ? $answers[$parentid] : $question; qa_post_unindex($oldanswer['postid']); $wasqueued = $oldanswer['type'] == 'A_QUEUED'; $contentchanged = strcmp($oldanswer['content'], $content) || strcmp($oldanswer['format'], $format); $setupdated = $contentchanged && !$wasqueued && !$silent; if ($setupdated && $remoderate) { $newtype = 'C_QUEUED'; } else { $newtype = substr_replace($oldanswer['type'], 'C', 0, 1); } qa_db_post_set_type($oldanswer['postid'], $newtype, $wasqueued || $silent ? null : $userid, $wasqueued || $silent ? null : qa_remote_ip_address(), QA_UPDATE_TYPE); qa_db_post_set_parent($oldanswer['postid'], $parentid); qa_db_post_set_content($oldanswer['postid'], $oldanswer['title'], $content, $format, $oldanswer['tags'], $notify, $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_CONTENT, $name); foreach ($commentsfollows as $commentfollow) { if ($commentfollow['parentid'] == $oldanswer['postid']) { // do same thing for comments and follows qa_db_post_set_parent($commentfollow['postid'], $parentid); } } qa_update_q_counts_for_a($question['postid']); qa_db_ccount_update(); qa_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds', 'cposts')); if ($setupdated && $remoderate) { qa_db_queuedcount_update(); if ($oldanswer['flagcount']) { qa_db_flaggedcount_update(); } } elseif ($oldanswer['type'] == 'A' && $question['type'] == 'Q' && ($parent['type'] == 'Q' || $parent['type'] == 'A')) { // only if all fully visible qa_post_index($oldanswer['postid'], 'C', $question['postid'], $parentid, null, $content, $format, $text, null, $oldanswer['categoryid']); } $eventparams = array('postid' => $oldanswer['postid'], 'parentid' => $parentid, 'parenttype' => $parent['basetype'], 'parent' => $parent, 'questionid' => $question['postid'], 'question' => $question, 'content' => $content, 'format' => $format, 'text' => $text, 'name' => $name, 'oldanswer' => $oldanswer); qa_report_event('a_to_c', $userid, $handle, $cookieid, $eventparams + array('silent' => $silent, 'oldcontent' => $oldanswer['content'], 'oldformat' => $oldanswer['format'], 'contentchanged' => $contentchanged)); if ($setupdated && $remoderate) { qa_report_event('c_requeue', $userid, $handle, $cookieid, $eventparams); } // a-to-c conversion can be detected by presence of $event['oldanswer'] instead of $event['oldcomment'] }
function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $queued = false, $name = null) { $postid = qa_db_post_create($queued ? 'A_QUEUED' : 'A', $question['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $content, $format, null, qa_combine_notify_email($userid, $notify, $email), $question['categoryid'], isset($userid) ? null : $name); qa_db_posts_calc_category_path($postid); if ($queued) { qa_db_queuedcount_update(); } else { if ($question['type'] == 'Q') { // don't index answer if parent question is hidden or queued qa_post_index($postid, 'A', $question['postid'], $question['postid'], null, $content, $format, $text, null, $question['categoryid']); } qa_update_q_counts_for_a($question['postid']); qa_db_points_update_ifuser($userid, 'aposts'); } qa_report_event($queued ? 'a_queue' : 'a_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => $question['postid'], 'parent' => $question, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $question['categoryid'], 'name' => $name, 'notify' => $notify, 'email' => $email)); return $postid; }