menu_delete_item

Versions
4.6
menu_delete_item($mid)
4.7 – 5
menu_delete_item($item)

Menu callback; delete a single custom item.

Code

modules/menu.module, line 180

<?php
function menu_delete_item($mid) {
  $op = $_POST['op'];
  $result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid);
  $menu = db_fetch_object($result);
  if (!$menu) {
    drupal_goto('admin/menu');
  }
  switch ($op) {
    case t('Delete'):
      db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
      if ($menu->type & MENU_IS_ROOT) {
        drupal_set_message(t('Menu deleted.'));
      }
      else {
        drupal_set_message(t('Menu item deleted.'));
      }
      drupal_goto('admin/menu');
      break;
    default:
      if ($menu->type & MENU_IS_ROOT) {
        $message = t('Are you sure you want to delete the menu %item?', array('%item' => theme('placeholder', $menu->title)));
      }
      else {
        $message = t('Are you sure you want to delete the custom menu item %item?', array('%item' => theme('placeholder', $menu->title)));
      }
      $output = theme('confirm', $message, 'admin/menu', t('This action cannot be undone.'), t('Delete'));
      print theme('page', $output);
  }
}
?>
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.