Closed JN-Jones closed 9 years ago
Probably better:
$query = $db->simple_select('forums', '*', "type='f' AND parent=0 AND import_fid > 0");
if($db->num_rows($query) > 0)
{
$cid = // Create category
while($forum = $db->fetch_array($query))
{
// Update the parentlist of this forum.
$db->update_query("forums", array("parent" => $cid, "parentlist" => make_parent_list($forum['fid'])), "fid='{$forum['fid']}'"); // Probably need to be split in 2 queries
// Rebuild the parentlist of all of the subforums of this forum
switch($db->type)
{
case "sqlite":
case "pgsql":
$query = $db->simple_select("forums", "fid", "','||parentlist||',' LIKE '%,$forum['fid'],%'");
break;
default:
$query = $db->simple_select("forums", "fid", "CONCAT(',',parentlist,',') LIKE '%,$forum['fid'],%'");
}
while($child = $db->fetch_array($query))
{
$db->update_query("forums", array("parentlist" => make_parent_list($child['fid'])), "fid='{$child['fid']}'");
}
}
}
Some softwares allow forums without a parent category, however we require a category and forums without a category aren't shown. For some boards (like Vanilla) which have only categories the merge system already creates a parent category, however boards like phpBB have apparently both and only the category -> forum ones are correctly displayed. The merge system should loop through all imported forums, check whether there's a category as main parent and if not create a new category and move all of those forums below that.