function og_menu_node_form_validate in Organic Groups Menu (OG Menu) 6
Same name and namespace in other branches
- 6.2 og_menu.module \og_menu_node_form_validate()
- 7.3 og_menu.module \og_menu_node_form_validate()
- 7.2 og_menu.module \og_menu_node_form_validate()
1 string reference to 'og_menu_node_form_validate'
- og_menu_form_alter in ./og_menu.module
- Implementation of hook_form_alter().
File
- ./og_menu.module, line 437
- Integrates Menu with Organic Groups.
Lots of menu forms duplication in OG context.
Code
function og_menu_node_form_validate($form, &$form_state) {
$menus = og_menu_get_menus();
$parents = explode(':', $form_state['values']['menu']['parent']);
$parent = $parents[0];
$gids = array();
$has_menu_access = FALSE;
foreach ($form_state['values']['og_groups'] as $gid => $enabled) {
if ($enabled) {
$gids[] = $gid;
}
}
foreach ($menus as $menu) {
if ($menu['menu_name'] == $parent) {
$has_menu_access = TRUE;
if (!in_array($menu['gid'], $gids)) {
form_set_error('og_groups', t('The menu you chose does not belong to the selected groups.'));
}
}
}
if (!$has_menu_access) {
form_set_error('menu][parent', t('You cannot add menu items to this menu. Choose another parent menu.'));
}
}