You are here

function groupmenu_edit_menu_form_submit in Group Menu 7

Submit handler used on various forms.

1 string reference to 'groupmenu_edit_menu_form_submit'
groupmenu_edit_menu_form in ./groupmenu.pages.inc
Menu callback.

File

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

Code

function groupmenu_edit_menu_form_submit($form, &$form_state) {
  $menu_name = $form_state['values']['menu_name'];
  $gid = $form_state['values']['groupmenu_gid'];
  if (!empty($gid)) {

    // If this is a new menu.
    if ($form['#insert']) {
      $menu_name = 'menu-' . $menu_name;
    }
    if (is_numeric($gid)) {
      groupmenu_update_menu($menu_name, $gid);
    }
    else {
      preg_match('/^(?:\\s*|(.*) )?\\[\\s*gid\\s*:\\s*(\\d+)\\s*\\]$/', $gid, $matches);
      if (!empty($matches)) {
        $gid = $matches[count($matches) - 1];
        if (is_numeric($gid)) {
          groupmenu_update_menu($menu_name, $gid);
        }
      }
      else {
        drupal_set_message(t('Cannot assign menu to invalid group, please retry'), 'error');
      }
    }
  }
  else {
    db_delete('group_menu')
      ->condition('menu_name', $menu_name)
      ->execute();
  }
}