function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $notify, $userid, $handle, $cookieid, $question, $answers, $commentsfollows) { $parent = isset($answers[$parentid]) ? $answers[$parentid] : $question; qa_post_unindex($oldanswer['postid']); $setupdated = strcmp($oldanswer['content'], $content) || strcmp($oldanswer['format'], $format); $setuserid = $setupdated ? $userid : null; $setip = $setupdated ? qa_remote_ip_address() : null; qa_db_post_set_type($oldanswer['postid'], $oldanswer['hidden'] ? 'C_HIDDEN' : 'C', $setuserid, $setip); qa_db_post_set_parent($oldanswer['postid'], $parentid, $setuserid, $setip); qa_db_post_set_content($oldanswer['postid'], $oldanswer['title'], $content, $format, $oldanswer['tags'], $notify, $setuserid, $setip); foreach ($commentsfollows as $commentfollow) { if ($commentfollow['parentid'] == $oldanswer['postid']) { // do same thing for comments and follows qa_db_post_set_parent($commentfollow['postid'], $parentid, null, null); } } qa_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds', 'cposts')); qa_db_post_acount_update($question['postid']); qa_db_hotness_update($question['postid']); qa_db_acount_update(); qa_db_ccount_update(); qa_db_unaqcount_update(); if (!($oldanswer['hidden'] || $question['hidden'] || $parent['hidden'])) { // only index if none of the things it depends on are hidden require_once QA_INCLUDE_DIR . 'qa-app-format.php'; qa_post_index($oldanswer['postid'], 'C', $question['postid'], null, $text, null); } qa_report_event('a_to_c', $userid, $handle, $cookieid, array('postid' => $oldanswer['postid'], 'parentid' => $parentid, 'parenttype' => $parent['basetype'], 'questionid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'oldcontent' => $oldanswer['content'], 'oldformat' => $oldanswer['format'])); }
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_to_comment($oldanswer, $parentid, $content, $format, $text, $notify, $userid, $handle, $cookieid, $question, $answers, $commentsfollows) { $parent = isset($answers[$parentid]) ? $answers[$parentid] : $question; qa_post_unindex($oldanswer['postid']); $contentchanged = strcmp($oldanswer['content'], $content) || strcmp($oldanswer['format'], $format); qa_db_post_set_type($oldanswer['postid'], substr_replace($oldanswer['type'], 'C', 0, 1), $userid, 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, $contentchanged ? $userid : null, $contentchanged ? qa_remote_ip_address() : null); 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_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds', 'cposts')); qa_db_post_acount_update($question['postid']); qa_db_hotness_update($question['postid']); qa_db_acount_update(); qa_db_ccount_update(); qa_db_unaqcount_update(); qa_db_unupaqcount_update(); if ($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']); } qa_report_event('a_to_c', $userid, $handle, $cookieid, array('postid' => $oldanswer['postid'], 'parentid' => $parentid, 'parenttype' => $parent['basetype'], 'questionid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'oldcontent' => $oldanswer['content'], 'oldformat' => $oldanswer['format'], 'oldanswer' => $oldanswer, 'contentchanged' => $contentchanged)); }