You are here

function og_menu_edit_menu_form_submit in Organic Groups Menu (OG Menu) 7.3

Same name and namespace in other branches
  1. 6.2 og_menu.module \og_menu_edit_menu_form_submit()
  2. 6 og_menu.module \og_menu_edit_menu_form_submit()
  3. 7.2 og_menu.module \og_menu_edit_menu_form_submit()

Submit handler used on various forms.

2 string references to 'og_menu_edit_menu_form_submit'
og_menu_edit_menu_form in ./og_menu.pages.inc
Menu callback.
og_menu_form_menu_edit_menu_alter in ./og_menu.module
Implements hook_form_FORMID_alter().

File

./og_menu.module, line 1083
Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.

Code

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

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