Changeset 953
- Timestamp:
- 10/06/2007 09:15:15 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/bb-includes/functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-includes/functions.php
r952 r953 26 26 /* Forums */ 27 27 28 function bb_get_forums_hierarchical( $root = 0, $depth = 0, $_leaves = false, $_recursed = false ) { 28 function bb_get_forums_hierarchical( $root = 0, $depth = 0, $leaves = false, $_recursed = false ) { 29 static $_leaves = false; 29 30 $root = (int) $root; 30 31 31 32 if ( false === $_leaves ) 32 $_leaves = get_forums();33 $_leaves = $leaves ? $leaves : get_forums(); 33 34 34 35 if ( !$_leaves ) … … 37 38 $branch = array(); 38 39 39 foreach ( $_leaves as $l => $leaf ) { 40 reset($_leaves); 41 42 while ( list($l, $leaf) = each($_leaves) ) { 40 43 if ( $root == $leaf->forum_parent ) { 41 44 $new_root = (int) $leaf->forum_id; 42 45 unset($_leaves[$l]); 43 $branch[$new_root] = 1 == $depth ? true : bb_get_forums_hierarchical( $new_root, $depth - 1, $_leaves, true ); 46 $branch[$new_root] = 1 == $depth ? true : bb_get_forums_hierarchical( $new_root, $depth - 1, false, true ); 47 reset($_leaves); 44 48 } 45 49 } 46 50 47 if ( !$_recursed ) 51 if ( !$_recursed ) { 52 foreach ( $_leaves as $leaf ) // Attach orphans to root 53 $branch[$leaf->forum_id] = true; 54 $_leaves = false; 48 55 return $tree = empty($branch) ? false : $branch; 56 } 49 57 50 58 return $branch ? $branch : true;
Note: See TracChangeset
for help on using the changeset viewer.