You are here

function og_subgroups_hs_hierarchical_select_root_level in Subgroups for Organic groups 6

Implementation of hook_hierarchical_select_root_level().

File

modules/og_subgroups_hs/og_subgroups_hs.module, line 65
Implementation of the Hierarchical Select API for the OG Subgroups module.

Code

function og_subgroups_hs_hierarchical_select_root_level($params) {
  og_subgroups_include('tree');
  og_subgroups_include('form');
  $root = $params['optional'] ? array(
    OG_SUBGROUPS_HS_ANY_OPTION => '<' . t('Any') . '>',
  ) : array();

  // Get the tree
  if ($tree = og_subgroups_get_tree()) {

    // Iterate the tree and only get the root elements
    foreach ($tree as $branch) {

      // Check access to use this group
      if (!og_subgroups_mask_group($branch, TRUE)) {

        // Add the initial group as an option
        $root[$branch->nid] = $branch->title;
      }
    }
  }

  // Add the groups that don't have children
  $root += _og_subgroups_group_select_options_without_family();

  // Don't include the given group in the hierarchy!
  unset($root[$params['nid']]);
  return $root;
}