You are here

function taxonomy_manager_update_weights in Taxonomy Manager 7

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \taxonomy_manager_update_weights()
  2. 6.2 taxonomy_manager.admin.inc \taxonomy_manager_update_weights()
  3. 6 taxonomy_manager.admin.inc \taxonomy_manager_update_weights()

callback for updating weights data send through AJAX, $_POST $_POST[$tid] => $weight

1 string reference to 'taxonomy_manager_update_weights'
taxonomy_manager_menu in ./taxonomy_manager.module
Implements hook_menu().

File

./taxonomy_manager.admin.inc, line 2680

Code

function taxonomy_manager_update_weights() {
  $submitted_data = $_POST;
  if (isset($submitted_data['form_token']) && isset($submitted_data['form_id']) && !empty($submitted_data['weights']) && is_array($submitted_data['weights'])) {
    if (drupal_valid_token($submitted_data['form_token'], $submitted_data['form_id'])) {
      foreach ($submitted_data['weights'] as $tid => $weight) {
        if (is_numeric($tid) && is_numeric($weight)) {
          $term = taxonomy_term_load($tid);
          $term->weight = $weight;
          taxonomy_term_save($term);
        }
      }
    }
  }
  exit;
}