function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null, $silent = false)
{
    $oldpath = qa_db_post_get_category_path($oldquestion['postid']);
    qa_db_post_set_category($oldquestion['postid'], $categoryid, $silent ? null : $userid, $silent ? null : qa_remote_ip_address());
    qa_db_posts_calc_category_path($oldquestion['postid']);
    $newpath = qa_db_post_get_category_path($oldquestion['postid']);
    qa_db_category_path_qcount_update($oldpath);
    qa_db_category_path_qcount_update($newpath);
    $otherpostids = array();
    foreach ($answers as $answer) {
        $otherpostids[] = $answer['postid'];
    }
    foreach ($commentsfollows as $comment) {
        if ($comment['basetype'] == 'C') {
            $otherpostids[] = $comment['postid'];
        }
    }
    if (@$closepost['parentid'] == $oldquestion['postid']) {
        $otherpostids[] = $closepost['postid'];
    }
    qa_db_posts_set_category_path($otherpostids, $newpath);
    $searchmodules = qa_load_modules_with('search', 'move_post');
    foreach ($searchmodules as $searchmodule) {
        $searchmodule->move_post($oldquestion['postid'], $categoryid);
        foreach ($otherpostids as $otherpostid) {
            $searchmodule->move_post($otherpostid, $categoryid);
        }
    }
    qa_report_event('q_move', $userid, $handle, $cookieid, array('postid' => $oldquestion['postid'], 'oldquestion' => $oldquestion, 'categoryid' => $categoryid, 'oldcategoryid' => $oldquestion['categoryid']));
}
Ejemplo n.º 2
0
function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $cookieid, $answers, $commentsfollows)
{
    $oldpath = qa_db_post_get_category_path($oldquestion['postid']);
    qa_db_post_set_category($oldquestion['postid'], $categoryid);
    qa_db_posts_calc_category_path($oldquestion['postid']);
    $newpath = qa_db_post_get_category_path($oldquestion['postid']);
    qa_db_category_path_qcount_update($oldpath);
    qa_db_category_path_qcount_update($newpath);
    $otherpostids = array();
    foreach ($answers as $answer) {
        $otherpostids[] = $answer['postid'];
    }
    foreach ($commentsfollows as $comment) {
        if ($comment['basetype'] == 'C') {
            $otherpostids[] = $comment['postid'];
        }
    }
    qa_db_posts_set_category_path($otherpostids, $newpath);
    qa_report_event('q_move', $userid, $handle, $cookieid, array('postid' => $oldquestion['postid'], 'categoryid' => $categoryid, 'oldcategoryid' => $oldquestion['categoryid']));
}