/** * Correctly associate any forums with their correct parent ids. This is automagically run after importing * forums. */ function cleanup() { global $db; $query = $db->simple_select("forums", "fid", "pid != 0 AND import_fid != 0"); while ($forum = $db->fetch_array($query)) { $db->update_query("forums", array('parentlist' => make_parent_list_pid($forum['fid'])), "fid='{$forum['fid']}'", 1); } }
/** * Builds a CSV parent list for a particular forum. * * @param int The forum ID * @param string Optional separator - defaults to comma for CSV list * @return string The built parent list */ function make_parent_list_pid($fid, $navsep = ",", $parent_list = "") { global $pforumcache, $db; if (!$pforumcache) { $query = $db->simple_select("forums", "fid, pid", "import_fid > 0", array("order_by" => "pid")); while ($forum = $db->fetch_array($query)) { $pforumcache[$forum['fid']] = array("fid" => $forum['fid'], "pid" => $forum['pid']); } } if (is_array($pforumcache[$fid])) { if ($pforumcache[$fid]['pid'] && $pforumcache[$pforumcache[$fid]['pid']]) { $parent_list = make_parent_list_pid($pforumcache[$fid]['pid'], $navsep, $parent_list) . $parent_list; } if ($parent_list) { $parent_list .= ','; } $parent_list .= $pforumcache[$fid]['fid']; } return $parent_list; }