menu_node_edit_node_form_submit

Versions
menu_node_edit
menu_node_edit_node_form_submit($form, &$form_state)

Submit handler for menu_node_edit node forms.

Code

./menu_node_edit.module, line 557

<?php
function menu_node_edit_node_form_submit($form, &$form_state) {
  // Check if we tried to set a new parent or remove the item.
  if (empty($form_state['values']['mlid'])) {
    return;
  }
  
  // The current menu item is stored in the menu element.
  if (!empty($form_state['values']['menu']['mlid'])) {
    $current = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $form_state['values']['menu']['mlid']));
  }

  // The new item is stored as mlid.
  $mlid = $form_state['values']['mlid'];
  // Check for a change in the visibility.
  if (isset($form_state['values']['hidden'])) {
    $hidden = (int) $form_state['values']['hidden'];
  }
  // If no change, then do nothing except alter visibility.
  if ($current['mlid'] == $mlid) {
    if (isset($hidden)) {
      $form_state['values']['menu']['hidden'] = $hidden;
    }
    return;
  }

  // If we set or change a menu item using limited permissions, then prepare the new menu item for saving.
  $item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $mlid));

  $menu = array();
  $menu['mlid'] = !empty($current['mlid']) ? $current['mlid'] : 0;
  $menu['plid'] = $item['mlid'];
  $menu['customized'] = 1;
  $menu['menu_name'] = $item['menu_name'];
  $menu['parent'] = $item['mlid'] .':'. $item['menu_name'];
  $menu['hidden'] = $hidden;
  // Do not allow editors to change a custom title.
  $menu['link_title'] = (isset($current['link_title']) && $current['link_title'] != $form['#node']->title) ? $current['link_title'] : $form_state['values']['title'];

  $form_state['values']['menu'] = $menu;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List