menu_edit_item_save

Versions
4.6 – 5
menu_edit_item_save($edit)

Save changes to a menu item into the database.

▾ 2 functions call menu_edit_item_save()

menu_add_menu in modules/menu.module
Menu callback; handle the adding of a new menu.
menu_edit_item in modules/menu.module
Menu callback; dispatch to the appropriate menu item edit function.

Code

modules/menu.module, line 350

<?php
function menu_edit_item_save($edit) {
  $menu = menu_get_menu();

  if ($edit['expanded']) {
    $edit['type'] |= MENU_EXPANDED;
  }
  else {
    $edit['type'] &= ~MENU_EXPANDED;
  }

  if ($edit['mid']) {
    db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['description'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN, $edit['mid']);
    drupal_set_message(t('Updated menu item %title.', array('%title' => theme('placeholder', $edit['title']))));
  }
  else {
    $mid = db_next_id('{menu}_mid');
    db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)", $mid, $edit['pid'], $edit['path'], $edit['title'], $edit['description'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN);
    drupal_set_message(t('Created new menu item %title.', array('%title' => theme('placeholder', $edit['title']))));
    if (array_key_exists($edit['path'], $menu['path index'])) {
      $old_mid = $menu['path index'][$edit['path']];
      $old_item = $menu['items'][$old_mid];
      drupal_set_message(t('Since a menu item %old already exists for %path, this new menu item was created as a shortcut to that location.', array('%old' => l(theme('placeholder', $old_item['title']), 'admin/menu/item/edit/'. $old_mid, array(), NULL, NULL, FALSE, TRUE), '%path' => theme('placeholder', $edit['path']))));
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.