You are here

function groupmenu_get_group_menus in Group Menu 7

Returns accessible menus for a given user or gids in a structured array.

Parameters

array $gids: An optional array of group ids.

Return value

array A structured array with menus list.

6 calls to groupmenu_get_group_menus()
groupmenu_block_view in ./groupmenu.module
Implements hook_block_view().
groupmenu_edit_item_form in ./groupmenu.pages.inc
Form callback; Build the menu link editing form.
groupmenu_entity_update in ./groupmenu.module
Implements hook_entity_update().
groupmenu_form_group_form_alter in ./groupmenu.module
Implements hook_form_FORM_ID_alter().
groupmenu_node_prepare in ./groupmenu.module
Implements hook_node_prepare().

... See full list

File

./groupmenu.module, line 546
Integrates menu with Group.

Code

function groupmenu_get_group_menus($gids = array()) {
  if (empty($gids)) {
    $gids = _groupmenu_get_user_group_ids();
  }
  if (empty($gids)) {
    return array();
  }
  $query = db_select('group_menu', 'gm');
  $query
    ->join('menu_custom', 'm', 'gm.menu_name = m.menu_name');
  $query
    ->fields('gm', array(
    'gid',
    'menu_name',
  ))
    ->fields('m', array(
    'title',
  ))
    ->condition('gm.gid', $gids, 'IN');
  $result = $query
    ->execute();
  $menus = array();
  while ($record = $result
    ->fetchAssoc()) {
    $menus[] = $record;
  }
  return $menus;
}