*************** *** 130,144 **** function menu_enable() { menu_rebuild(); $result = db_query("SELECT * FROM {menu_custom}"); - $link['module'] = 'menu'; - $link['plid'] = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", 'admin/build/menu', 'system')); $link['router_path'] = 'admin/build/menu-customize/%'; - while ($menu = db_fetch_array($result)) { $link['mlid'] = 0; $link['link_title'] = $menu['title']; $link['link_path'] = 'admin/build/menu-customize/'. $menu['menu_name']; - menu_link_save($link); } menu_cache_clear_all(); } --- 130,146 ---- function menu_enable() { menu_rebuild(); $result = db_query("SELECT * FROM {menu_custom}"); + $link = db_fetch_array(db_query("SELECT mlid AS plid, menu_name from {menu_links} WHERE link_path = 'admin/build/menu' AND module = 'system'")); $link['router_path'] = 'admin/build/menu-customize/%'; + $link['module'] = 'menu'; + $result = db_query("SELECT * FROM {menu_custom}"); while ($menu = db_fetch_array($result)) { $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(); } *************** *** 460,465 **** $form['menu_name'] = array( '#type' => 'textfield', '#title' => t('Menu name'), '#description' => t('The machine-readable name of this menu. This text will be used for constructing the URL of the menu overview page for this menu. This name may consist of only of lowercase letters, numbers, and hyphens, and must be unique.'), '#required' => TRUE, ); --- 462,468 ---- $form['menu_name'] = array( '#type' => 'textfield', '#title' => t('Menu name'), + '#maxsize' => 27, '#description' => t('The machine-readable name of this menu. This text will be used for constructing the URL of the menu overview page for this menu. This name may consist of only of lowercase letters, numbers, and hyphens, and must be unique.'), '#required' => TRUE, ); *************** *** 559,564 **** if (preg_match('/[^a-z0-9-]/', $item['menu_name'])) { form_set_error('menu_name', t('Menu name may consist only of lowercase letters, numbers, and hyphens.')); } if ($form['#insert']) { // We will add 'menu-' to the menu name to help avoid name-space conflicts. $item['menu_name'] = 'menu-'. $item['menu_name']; --- 562,570 ---- if (preg_match('/[^a-z0-9-]/', $item['menu_name'])) { form_set_error('menu_name', t('Menu name may consist only of lowercase letters, numbers, and hyphens.')); } + if (strlen($item['menu_name']) > 27) { + form_set_error('menu_name', t('Menu name can not be longer than 27 characters.')); + } if ($form['#insert']) { // We will add 'menu-' to the menu name to help avoid name-space conflicts. $item['menu_name'] = 'menu-'. $item['menu_name'];