1 menu.admin.inc | menu_edit_menu_submit($form, &$form_state) |
Submit function for adding or editing a custom menu.
File
- core/
modules/ menu/ menu.admin.inc, line 675 - Admin page callbacks for the Menu module.
Code
function menu_edit_menu_submit($form, &$form_state) {
$menu = $form_state['values'];
$path = 'admin/structure/menu/manage/';
if ($form['#insert']) {
// Add 'menu-' to the menu name to help avoid name-space conflicts.
$menu['menu_name'] = 'menu-' . $menu['menu_name'];
$link['link_title'] = $menu['title'];
$link['link_path'] = $path . $menu['menu_name'];
$link['router_path'] = $path . '%';
$link['module'] = 'menu';
$link['plid'] = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :link AND module = :module", array(
':link' => 'admin/structure/menu',
':module' => 'system'
))
->fetchField();
menu_link_save($link);
menu_save($menu);
}
else {
menu_save($menu);
$result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path", array(':path' => $path . $menu['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $m) {
$link = menu_link_load($m['mlid']);
$link['link_title'] = $menu['title'];
menu_link_save($link);
}
}
backdrop_set_message(t('Your configuration has been saved.'));
$form_state['redirect'] = 'admin/structure/menu';
}