You are here

function groupmenu_form_group_form_alter in Group Menu 7

Implements hook_form_FORM_ID_alter().

File

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

Code

function groupmenu_form_group_form_alter(&$form, &$form_state) {
  $group = $form_state['build_info']['args'][0];
  if (empty($group->gid)) {

    // We don't get the option to add to a menu when the group is
    // created as there are no groups at the moment.
    return;
  }

  // If there is no menu already available on the group, then add it.
  if (empty($group->menu)) {
    $group->menu = _groupmenu_get_group_menu_link($group);
  }
  $menus = groupmenu_get_group_menus(array(
    $group->gid,
  ));
  if (empty($menus)) {
    return;
  }
  $list = array();
  foreach ($menus as $menu) {
    $list[$menu['menu_name']] = $menu['title'];
  }
  $options = menu_parent_options($list, array(
    'mlid' => 0,
  ));
  $link = $group->menu;
  _groupmenu_add_menufieldset($form, $options, $link);
}