You are here

function ack_menu_overview_form_submit in Access Control Kit 7

Submit handler for editing the menu tree for a realm.

See also

ack_menu_overview_form()

File

ack_menu/ack_menu.pages.inc, line 267
Page callbacks for managing menu links in assigned realms.

Code

function ack_menu_overview_form_submit($form, &$form_state) {
  foreach (element_children($form) as $mlid) {

    // Save the descendant links.
    if (isset($form[$mlid]['subtree'])) {

      // Undo the depth adjustment from ack_menu_overview_form().
      $depth = $form_state['values'][$mlid]['depth'];
      $subtree =& $form[$mlid]['subtree'];
      foreach (element_children($subtree) as $key) {
        if (isset($subtree[$key]['#item'])) {
          $subtree[$key]['#item']['depth'] += $depth;
        }
      }

      // Prepare a faux $form_state array that represents the subtree in the
      // format expected by menu_overview_form_submit().
      $subtree_form_state = array(
        'input' => $form_state['input'][$mlid]['subtree'],
        'values' => $form_state['values'][$mlid]['subtree'],
      );
      menu_overview_form_submit($subtree, $subtree_form_state);
    }
  }
}