menu_enable

Versions
6 – 7
menu_enable()

Implementation of hook_enable()

Add a link for each custom menu.

▾ 1 function calls menu_enable()

system_update_6021 in modules/system/system.install
Migrate the menu items from the old menu system to the new menu_links table.

Code

modules/menu/menu.module, line 163

<?php
function menu_enable() {
  menu_rebuild();
  $base_link = db_fetch_array(db_query("SELECT mlid AS plid, menu_name from {menu_links} WHERE link_path = 'admin/build/menu' AND module = 'system'"));
  $base_link['router_path'] = 'admin/build/menu-customize/%';
  $base_link['module'] = 'menu';
  $result = db_query("SELECT * FROM {menu_custom}");
  while ($menu = db_fetch_array($result)) {
    // $link is passed by reference to menu_link_save(), so we make a copy of $base_link.
    $link = $base_link;
    $link['mlid'] = 0;
    $link['link_title'] = $menu['title'];
    $link['link_path'] = 'admin/build/menu-customize/'. $menu['menu_name'];
    if (!db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = %d", $link['link_path'], $link['plid']))) {
      menu_link_save($link);
    }
  }
  menu_cache_clear_all();
}
?>
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.