You are here

function nodehierarchy_children_form_submit in Node Hierarchy 7.4

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \nodehierarchy_children_form_submit()
  2. 6.2 nodehierarchy.module \nodehierarchy_children_form_submit()
  3. 7.2 nodehierarchy.module \nodehierarchy_children_form_submit()

Submit the children tab form.

File

./nodehierarchy.admin.inc, line 365
Admin functions for Node Hierarchy

Code

function nodehierarchy_children_form_submit($form, &$form_state) {
  $updated_items = array();
  foreach (element_children($form['children']) as $nhid) {
    if (isset($form['children'][$nhid]['child'])) {
      $element = $form['children'][$nhid];
      $child = $element['child']['#value'];
      if ($element['cweight']['#value'] != $child->cweight) {
        $child->cweight = $element['cweight']['#value'];
        $updated_items[$nhid] = $child;
      }
    }
  }

  // Save all our changed items to the database.
  foreach ($updated_items as $item) {

    // Skip the save function wrapper as we don't need child weights recalculated.
    _nodehierarchy_record_write($item);
  }
  module_invoke_all('nodehierarchy_reorder_children', $updated_items);
}