You are here

function advanced_menu_blocks_form_submit in Advanced Menu 7

Save block visibility settings.

1 string reference to 'advanced_menu_blocks_form_submit'
advanced_menu_blocks_form_alter in blocks/advanced_menu_blocks.module
Implementation of hook_form_alter().

File

blocks/advanced_menu_blocks.module, line 93
Provides block customization settings for menus.

Code

function advanced_menu_blocks_form_submit(&$form, $form_state) {
  $menu = $form_state['values'];
  $menu_name = '';
  switch ($menu['form_id']) {
    case 'menu_edit_menu':
      if ($form['#insert']) {
        $menu['menu_name'] = 'menu-' . $menu['menu_name'];
      }
      $menu_name = $menu['menu_name'];
      db_delete('advanced_menu_blocks')
        ->condition('menu_name', $menu_name)
        ->execute();
      foreach ($menu['blocks'] as $block) {
        if ($block != 0) {
          db_insert('advanced_menu_blocks')
            ->fields(array(
            'menu_name' => $menu_name,
          ))
            ->execute();
          db_delete('block')
            ->condition('delta', $menu_name)
            ->execute();
        }
      }
      break;
  }
  menu_rebuild();
}