function xthreads_breadcrumb_hack($fid) { global $pforumcache, $forum_cache; if (!$pforumcache) { if (!is_array($forum_cache)) { cache_forums(); } foreach ($forum_cache as &$val) { // MyBB does this very weirdly... I mean, like // ...the second dimension of the array is useless, since fid // is pulling a unique $val already... $pforumcache[$val['fid']][$val['pid']] = $val; } } if (!is_array($pforumcache[$fid])) { return; } // our strategy works by rewriting parents of forums below hidden forums foreach ($pforumcache[$fid] as &$pforum) { // will only ever loop once if ($pforum['fid'] != $fid) { continue; } // paranoia // we can't really hide the active breadcrumb, so ignore current forum... // (actually, it might be possible if we rewrite forum ids) if ($pforum['pid'] && !empty($pforumcache[$pforum['pid']])) { $prevforum =& $pforum; $forum =& xthreads_get_array_first($pforumcache[$pforum['pid']]); while ($forum) { if (!$forum['xthreads_hidebreadcrumb']) { // rewrite parent fid (won't actually change if there's no hidden breadcrumbs in-between) $prevforum['pid'] = $forum['fid']; $prevforum =& $forum; } if (!$forum['pid'] || empty($pforumcache[$forum['pid']])) { break; } $forum =& xthreads_get_array_first($pforumcache[$forum['pid']]); } $prevforum['pid'] = 0; } } }
function xthreads_breadcrumb_hack_printthread() { global $pforumcache; //if(!is_array($pforumcache)) { // need to override because we want the 'xthreads_hidebreadcrumb' field global $forum, $db, $fid; $parlist = build_parent_list($fid, 'fid', 'OR', $forum['parentlist']); $query = $db->simple_select('forums', 'name, fid, pid, xthreads_hidebreadcrumb', $parlist, array('order_by' => 'pid, disporder')); while ($forumnav = $db->fetch_array($query)) { $pforumcache[$forumnav['pid']][$forumnav['fid']] = $forumnav; } unset($forumnav, $forum, $fid); // unsetting the global references //} if (!is_array($pforumcache[0])) { return; } // do the same as xthreads_breadcrumb_hack() but in reverse foreach ($pforumcache[0] as &$pforum) { // will only ever loop once if ($pforum['pid']) { continue; } // paranoia // firstly, skip any hidden top-level parents $prevforum =& $pforum; while ($prevforum && $prevforum['xthreads_hidebreadcrumb'] && !empty($pforumcache[$prevforum['fid']])) { $prevforum =& xthreads_get_array_first($pforumcache[$prevforum['fid']]); } if ($prevforum) { if ($prevforum['pid']) { $prevforum['pid'] = 0; $pforum = $prevforum; } $forum = null; if ($pforumcache[$prevforum['fid']]) { $forum =& xthreads_get_array_first($pforumcache[$prevforum['fid']]); } while ($forum) { if (!$forum['xthreads_hidebreadcrumb']) { // rewrite parent fid (won't actually change if there's no hidden breadcrumbs in-between) $forum['pid'] = $prevforum['fid']; $pforumcache[$forum['pid']] = array($forum['fid'] => $forum); $prevforum =& $forum; } if (!$pforumcache[$forum['fid']]) { // we always display the active breadcrumb, so set this if hidden if ($forum['xthreads_hidebreadcrumb']) { $forum['pid'] = $prevforum['fid']; $pforumcache[$forum['pid']] = array($forum['fid'] => $forum); } break; } $forum =& xthreads_get_array_first($pforumcache[$forum['fid']]); } } } }