Index: taxonomy_menu.module
===================================================================
--- taxonomy_menu.module	(revision 290)
+++ taxonomy_menu.module	(working copy)
@@ -70,8 +70,8 @@
     );
 
     //get taxonomy menu form options
-    //$form['taxonomy_menu']['options'] = _taxonomy_menu_create_options($form['vid']['#value']);
-    //
+    $form['taxonomy_menu']['options'] = _taxonomy_menu_create_options($form['vid']['#value']);
+    
     //rebuild the menu
     $form['taxonomy_menu']['options']['rebuild'] = array(
       '#type' => 'checkbox',
@@ -80,14 +80,21 @@
       '#weight' => 20,
       '#description' => t('Rebuild the menu on submit. <strong>Warning</strong>: This will delete then re-create all of the menu items. Only use this option if you are experiencing issues like missing menu items or other inconsistencies.'),
     );
+
     // move the buttons to the bottom of the form
     $form['submit']['#weight'] = 49;
     $form['delete']['#weight'] = 50;
 
     // add an extra submit handler to save these settings
-    $form['#submit'][] = 'taxonomy_menu_vocab_submit';
+    $form['#submit'][] = 'taxonomy_menu_vocabulary_submit';
 
   }
+  elseif ($form_id == "taxonomy_overview_terms") {
+    // add an extra submit handler to sync the rearranged terms with menu
+    // @ TODO: using hook_taxonomy_vocabulary_update is nicer then callback, but gives less info and 
+    //         does not always fire.
+    $form['#submit'][] = 'taxonomy_menu_overview_submit';
+  }
 }
 
 /**
@@ -96,7 +103,7 @@
  * Check to see if the user has selected a different menu, and only rebuild
  * if this is the case.
  */
-function taxonomy_menu_vocab_submit($form, &$form_state) {
+function taxonomy_menu_vocabulary_submit(&$form, &$form_state, $form_id) {
   $vid = $form_state['values']['vid'];
   $changed = FALSE;
 
@@ -179,6 +186,30 @@
 }
 
 /**
+ * Submit handler, reacting on taxonomy term overview page
+ */
+function taxonomy_menu_overview_submit(&$form, &$form_state) {
+  // Only sync if taxonomy_menu is enabled for this vocab and the 'sync'
+  // option has been checked.
+  $vid = $form['#vocabulary']->vid;
+  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $vid), 0);
+  $sync = variable_get(_taxonomy_menu_build_variable('sync', $vid), 0);
+
+  if ($menu_name && $sync) {
+    // Update all menu items (do not rebuild the menu).
+    $message = _taxonomy_menu_update_link_items($vid);
+
+    // Report status.
+    if (isset($message)) {
+      drupal_set_message($message, 'status');
+    }
+
+    // Rebuild the menu.
+    menu_cache_clear($menu_name);
+  }
+}
+
+/**
  * rebuilds a menu
  *
  * @param $vid
@@ -245,7 +276,7 @@
     taxonomy_menu_handler('update', $args);
   }
 
-  return t('The Taxonomy Menu %menu_name has been updated.', array('%menu_name' => $menu_name));
+  return t('Updated taxonomy menu %menu_name.', array('%menu_name' => $menu_name));
 }
 
 /**
@@ -278,87 +309,32 @@
 }
 
 /**
+ * Implementation of hook_taxonomy_vocabulary_update().
+ */
+// @ TODO: using hook_taxonomy_vocabulary_update is nicer then callback, but gives less info and 
+//         does not always fire.
+//function taxonomy_menu_taxonomy_vocabulary_update($vocabulary) {
+//}
+
+/**
  * Implementation of hook_taxonomy_term_insert($term).
  */
 function taxonomy_menu_taxonomy_term_insert($term) {
-  // only sync if taxonomy_menu is enabled for this vocab and the 'sync'
-  // option has been checked.
-  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), 0);
-  $sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), 0);
-
-  if ($menu_name && $sync) {
-    //we have to pull from the args because using a taxonomy function pulls from the cache
-    $item = array(
-      'term' => $term,
-      'menu_name' => $menu_name,
-    );
-    $message = t('Term %term has been added to taxonomy menu %menu_name.', array('%term' => $term->name, '%menu_name' => $menu_name));
-
-    // Run function.
-    taxonomy_menu_handler('insert', $item);
-    // Report status.
-    drupal_set_message($message, 'status');
-
-    // Rebuild the menu.
-    menu_cache_clear($menu_name);
-  }
+  _taxonomy_menu_taxonomy_termapi_helper($term, 'insert');
 }
 
 /**
  * Implementation of hook_taxonomy_term_update().
  */
-function taxonomy_menu_taxonomy_menu_term_update($term) {
-  // Only sync if taxonomy_menu is enabled for this vocab and the 'sync'
-  // option has been checked.
-  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), 0);
-  $sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), 0);
-
-  if ($menu_name && $sync) {
-    $item = array(
-      'term' => $term,
-      'menu_name' => $menu_name,
-      'mlid' => _taxonomy_menu_get_mlid($term->tid, $term->vid),
-    );
-    $message = t('Term %term has been updated in taxonomy menu %menu_name.', array('%term' => $term->name, '%menu_name' => $menu_name));
-    break;
-
-    // run function
-    taxonomy_menu_handler('update', $item);
-    // report status
-    drupal_set_message($message, 'status');
-
-    // rebuild the menu
-    menu_cache_clear($menu_name);
-  }
+function taxonomy_menu_taxonomy_term_update($term) {
+  _taxonomy_menu_taxonomy_termapi_helper($term, 'update');
 }
 
 /**
  * Implementation of hook_taxonomy_term_delete()
  */
 function taxonomy_menu_taxonomy_term_delete($term) {
-      // only sync if taxonomy_menu is enabled for this vocab and the 'sync'
-  // option has been checked.
-  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), 0);
-  $sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), 0);
-
-  if ($menu_name && $sync) {
-    $item = array(
-      'tid' => $term->tid,
-      'vid' => $term->vid,
-      'menu_name' => $menu_name,
-      'term' => $term,
-      'mlid' => _taxonomy_menu_get_mlid($term->tid, $term->vid),
-    );
-    $message = t('Term %term has been deleted from taxonomy menu %menu_name.', array('%term' => $term->name, '%menu_name' => $menu_name));
-
-      // run function
-    taxonomy_menu_handler('delete', $item);
-    // report status
-    drupal_set_message($message, 'status');
-
-    // rebuild the menu
-    menu_cache_clear($menu_name);
-  }
+  _taxonomy_menu_taxonomy_termapi_helper($term, 'delete');
 }
 
 /**
@@ -479,6 +455,48 @@
 }
 
 /**
+ * Abstraction of hook_taxonomy_term_<operation>()
+ */
+function _taxonomy_menu_taxonomy_termapi_helper($term, $operation) {
+  // Only sync if taxonomy_menu is enabled for this vocab and the 'sync'
+  // option has been checked.
+  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), 0);
+  $sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), 0);
+
+  if ($menu_name && $sync) {
+    $item = array(
+      'tid' => $term->tid,
+      'vid' => $term->vid,
+      'menu_name' => $menu_name,
+      'term' => $term,
+      'mlid' => _taxonomy_menu_get_mlid($term->tid, $term->vid),
+    );
+
+    switch ($operation) {
+      case 'insert':
+        $text = 'Added term %term to taxonomy menu %menu_name.';
+        break;
+      case 'update':
+        $text = 'Updated term %term in taxonomy menu %menu_name.';
+        break;
+      case 'delete':
+        $text = 'Deleted term %term from taxonomy menu %menu_name.';
+        break;
+    }
+    $message = t($text, array('%term' => $term->name, '%menu_name' => $menu_name));
+
+      // run function
+    taxonomy_menu_handler($operation, $item);
+
+    // report status
+    drupal_set_message($message, 'status');
+
+    // rebuild the menu
+    menu_cache_clear($menu_name);
+  }
+}
+
+/**
  * HANDLING
  *
  * @param $op
@@ -737,7 +755,6 @@
  *  The node object.
  */
 function _taxonomy_menu_create_item($args = array(), $node) {
-
   //if tid = 0 then we are creating a vocab item
 
   if (isset($args['tid']) && isset($args['vid']) && $args['tid'] == 0 && variable_get(_taxonomy_menu_build_variable('voc_item', $args['vid']), 0)) {
@@ -759,19 +776,29 @@
     $term = $args['term'];
   }
 
-  // get the first parent
-  if (is_array($term->parents)) {
-    foreach ($term->parents as $key => $val) {
-      $ptid = $val;
+  // Sometimes $term->parents is not set so we find it.
+  if (!isset($term->parent)) {
+    $parents = taxonomy_get_parents($term->tid);
+    foreach ($parents as $index => $parent) {
+      $term->parent = array($index);
       break;
     }
   }
+  if (isset($term->parent)) {
+    if (is_array($term->parent)) {
+      foreach ($term->parent as $parent) {
+        if (!empty($parent)) {
+          $ptid = $parent;
+          break;
+        }
+      }
+    }
+    else {
+      $ptid = $term->parent ? $term->parent : 0;
+    }
+  }
+  // If ptid is empty, then set it to 0.
   else {
-    $ptid = $term->parents;
-  }
-
-  //if ptid is empty, then set it to 0
-  if (empty($ptid)) {
     $ptid = 0;
   }
 
@@ -952,6 +979,7 @@
     'default' => TRUE,
   );
 
+/*
   $options['display_num'] = array(
     '#title' => t('Display number of items'),
     '#description' => t('Display the number of items per taxonomy terms. Will not show up for vocabulary menu items.'),
@@ -995,6 +1023,7 @@
     'default' => FALSE,
     '#description' => t('This changes tid+tid+tid to "All" in term when <em>Display descendants</em> has been selected.<br />Only used if <em>Menu path type</em> is "Default path".<br />Works with default taxonomy page.'),
   );
+*/
 
   return $options;
 }
