You are here

function og_subgroups_get_tree in Subgroups for Organic groups 6

Get a hierarchy tree of all groups on the site

param $reset TRUE if the tree should be regenerated. Default to FALSE.

6 calls to og_subgroups_get_tree()
og_subgroups_get_group_tree in includes/tree.inc
Get a hierarchy tree just for a given group
og_subgroups_group_select_options in includes/form.inc
Create form select options for the subgroup selector
og_subgroups_hs_hierarchical_select_item_get_label in modules/og_subgroups_hs/og_subgroups_hs.module
Implementation of hook_hierarchical_select_item_get_label().
og_subgroups_hs_hierarchical_select_root_level in modules/og_subgroups_hs/og_subgroups_hs.module
Implementation of hook_hierarchical_select_root_level().
og_subgroups_hs_hierarchical_select_valid_item in modules/og_subgroups_hs/og_subgroups_hs.module
Implementation of hook_hierarchical_select_valid_item().

... See full list

File

includes/tree.inc, line 14
Functions to generate and use the group hierarchy trees

Code

function og_subgroups_get_tree($reset = FALSE) {
  static $tree = FALSE;
  $cache_key = 'og_subgroups:tree';

  // Check if our static cache hasn't yet been populated
  // or if a reset has been requested
  if ($reset || $tree === FALSE) {

    // If no reset is requested, attempt to fetch a cached tree
    // from the database
    if (!$reset) {
      $cache = cache_get($cache_key);

      // See if the cache has data
      if (isset($cache->data)) {

        // Use the cached tree
        $tree = $cache->data;
      }
    }

    // If we don't yet have a tree, we must generate one
    if ($reset || !$tree) {
      $tree = _og_subgroups_get_tree();

      // Cache this tree in the database
      cache_set($cache_key, $tree);
    }
  }
  return $tree;
}