PHPFusion\Forums\Admin\ForumAdminInterface::prune_forums PHP 메소드

prune_forums() 보호된 메소드

Remove the entire forum branch, image and order updated
protected prune_forums ( boolean $index = FALSE, boolean $time = FALSE )
$index boolean
$time boolean
    protected function prune_forums($index = FALSE, $time = FALSE)
    {
        // delete forums - wipeout branch, image, order updated.
        $index = $index ? $index : 0;
        // need to refetch a new index after moving, else the id will be targetted
        $branch_data = $this->get_forum_index();
        //print_p($branch_data[$index]);
        //print_p("Index is $index");
        $index_data = dbarray(dbquery("SELECT forum_id, forum_image, forum_order FROM " . DB_FORUMS . " " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $index . "'"));
        // check if there is a sub for this node.
        if (isset($branch_data[$index])) {
            foreach ($branch_data[$index] as $forum_id) {
                $data = dbarray(dbquery("SELECT forum_id, forum_image, forum_order FROM " . DB_FORUMS . " " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $forum_id . "'"));
                if ($data['forum_image'] && file_exists(IMAGES . "forum/" . $data['forum_image'])) {
                    unlink(IMAGES . "forum/" . $data['forum_image']);
                }
                dbquery("UPDATE " . DB_FORUMS . " SET forum_order=forum_order-1 " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $forum_id . "' AND forum_order>'" . $data['forum_order'] . "'");
                dbquery("DELETE FROM " . DB_FORUMS . " " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='{$forum_id}' " . ($time ? "AND forum_lastpost < '" . $time . "'" : '') . " ");
                if (isset($branch_data[$data['forum_id']])) {
                    self::prune_forums($branch_data, $data['forum_id'], $time);
                }
                // end foreach
            }
            // finally remove itself.
            if ($index_data['forum_image'] && file_exists(IMAGES . "forum/" . $index_data['forum_image'])) {
                unlink(IMAGES . "forum/" . $data['forum_image']);
                //print_p("unlinked ".$index_data['forum_image']."");
            }
            dbquery("UPDATE " . DB_FORUMS . " SET forum_order=forum_order-1 " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $index . "' AND forum_order>'" . $index_data['forum_order'] . "'");
            //print_p("deleted ".$index."");
            dbquery("DELETE FROM " . DB_FORUMS . " " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $index . "' " . ($time ? "AND forum_lastpost < '" . $time . "'" : '') . " ");
        } else {
            if ($index_data['forum_image'] && file_exists(IMAGES . "forum/" . $index_data['forum_image'])) {
                unlink(IMAGES . "forum/" . $index_data['forum_image']);
                //print_p("unlinked ".$index_data['forum_image']."");
            }
            dbquery("UPDATE " . DB_FORUMS . " SET forum_order=forum_order-1 " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $index . "' AND forum_order>'" . $index_data['forum_order'] . "'");
            //print_p("deleted ".$index."");
            dbquery("DELETE FROM " . DB_FORUMS . " " . (multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "' AND" : "WHERE") . " forum_id='" . $index . "' " . ($time ? "AND forum_lastpost < '" . $time . "'" : '') . " ");
        }
    }