You are here

function _blockgroup_tree_get_top in Block Group 7.2

Same name and namespace in other branches
  1. 7 blockgroup.module \_blockgroup_tree_get_top()

Given a block id and a forest structure, return the root.

1 call to _blockgroup_tree_get_top()
blockgroup_block_list_alter in ./blockgroup.module
Implements hook_block_list_alter().

File

./blockgroup.module, line 194
Add block groups to block configuration page

Code

function _blockgroup_tree_get_top($bid, $tree, $seen = array()) {
  if (isset($seen[$bid])) {

    // Return NULL when a cycle was detected.
    return NULL;
  }
  if (!isset($tree[$bid])) {

    // Return bid if we reached the top.
    return $bid;
  }

  // Apply function to children.
  $seen[$bid] = $bid;
  return _blockgroup_tree_get_top($tree[$bid], $tree, $seen);
}