You are here

function taxonomy_menu_save_menu_set_rtln in Taxonomy menu 6.3

Save a Term Set/mneugrpou Reltn

Parameters

array $menu_set = array('mgid' => number, 'tsid' => number, 'parent_item' => 'tsid:tid'):

1 call to taxonomy_menu_save_menu_set_rtln()
taxonomy_menu_group_term_submit in ./taxonomy_menu.admin.inc
Submit Handler for Add Term Set button

File

./taxonomy_menu.admin.inc, line 836
admin section for taxonomy menu

Code

function taxonomy_menu_save_menu_set_rtln($menu_set) {

  // @TODO CHeck for existance first
  drupal_write_record('taxonomy_menu_group_term_set', $menu_set);

  // Get the current menu group
  $menu_group = taxonomy_menu_get_group($menu_set['mgid']);

  // Cycle through the related terms
  $term_set = taxonomy_menu_get_term_set($menu_set['tsid']);

  // Add the new terms to the current menu group
  // Find the depth of the parent item
  if ($menu_set['parent_item']) {
    $depth = $menu_group->items[$menu_set['parent_item']]->depth + 1;
  }
  else {
    $depth = 0;
  }
  foreach ($term_set->items as $key => $item) {

    // Assign the new depth
    $item->depth = $item->depth + $depth;
    unset($item->parents);
    $item->parent = $menu_set['parent_item'];
    $menu_group->items[$item->tsid . ':' . $item->tid] = $item;
  }

  // Sort the items
  $menu_group->items = taxonomy_menu_build_menu_tree($menu_group->items);

  // Save the menu group.
  taxonomy_menu_save_menu_group($menu_group);
}