You are here

function og_ui_get_group_admin in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og_ui/og_ui.module \og_ui_get_group_admin()

Get all the group admin menu items.

1 call to og_ui_get_group_admin()
og_ui_group_admin_overview in og_ui/og_ui.admin.inc
Provide an overview of the administrator menu items.
1 string reference to 'og_ui_get_group_admin'
og_ui_menu in og_ui/og_ui.module
Implements hook_menu().

File

og_ui/og_ui.module, line 1101
Organic groups UI.

Code

function og_ui_get_group_admin($entity_type, $etid) {

  // We cache the values, as this function is also used as an access
  // callback, so we don't want to trigger it many times.
  $cache =& drupal_static(__FUNCTION__);
  if (isset($cache["{$entity_type}:{$etid}"])) {
    return $cache["{$entity_type}:{$etid}"];
  }

  // This function is also used as access callback for menu items, so we need to
  // make sure that the user supplied $etid is actually an integer.
  if (!ctype_digit($etid)) {
    return array();
  }

  // ensure we are invoking this on something worth doing it on
  $entity = entity_load_single($entity_type, $etid);
  if (!$entity) {

    // It is a non-existing group Id, giving up.
    return FALSE;
  }
  $entity_info = entity_get_info($entity_type);

  // if this isn't a group type, skip invoking admin modules
  if (empty($entity_info['entity keys']['bundle']) || !og_is_group_type($entity_type, $entity->{$entity_info['entity keys']['bundle']})) {
    $cache["{$entity_type}:{$etid}"] = FALSE;
    return FALSE;
  }
  $data = module_invoke_all('og_ui_get_group_admin', $entity_type, $etid);

  // Sort the results.
  uasort($data, 'drupal_sort_title');

  // Allow other modules to alter the menu items.
  $context = array(
    'entity_type' => $entity_type,
    'etid' => $etid,
  );
  drupal_alter('og_ui_get_group_admin', $data, $context);
  $cache["{$entity_type}:{$etid}"] = $data;
  return $data;
}