function og_menu_single_form_menu_edit_item_alter in OG Menu Single 7
Implements hook_form_FORMID_alter().
File
- ./
og_menu_single.module, line 54 - Creates a single menu per organic group on a site.
Code
function og_menu_single_form_menu_edit_item_alter(&$form, $form_state) {
$item = menu_get_item();
// @TODO
// Don't want to define new form for menu edit so any contrib editing main one
// edits this also, but no way other than using 'menu_override_parent_selector
// but there's no way to know where else outside of core menu_parent_options
// has been used. Bah!!
if ($item['path'] == 'group/%/%/admin/menu/item/%/edit' || $item['path'] == 'group/%/%/admin/menu/add') {
$plid = og_menu_single_get_link_mlid_or_create($item['map'][1], $item['map'][2]);
$link = $form['original_item']['#value'];
$options[OG_MENU_SINGLE_MENU_NAME . ':' . $plid] = '<' . t('None') . '>';
if ($plid && ($tree = og_menu_single_children_items($plid))) {
_menu_parents_recurse($tree, OG_MENU_SINGLE_MENU_NAME, '--', $options, $link['mlid'] ? $link['mlid'] : 0, 8);
}
$form['parent']['#options'] = $options;
$form['enabled']['#access'] = FALSE;
$form['expanded']['#access'] = FALSE;
$menu_path = 'group/' . $item['map'][1] . '/' . $item['map'][2] . '/admin/menu';
if ($link['mlid']) {
$breadcrumb = drupal_get_breadcrumb();
array_pop($breadcrumb);
$breadcrumb[] = l('Group Menu', 'group/' . $item['map'][1] . '/' . $item['map'][2] . '/admin/menu');
drupal_set_breadcrumb($breadcrumb);
}
$form['#submit'][] = 'og_menu_single_menu_form_new_redirect';
$form['#og_menu_redirect'] = $menu_path;
}
}