You are here

function lineage_update_all in Taxonomy Lineage 7

Same name and namespace in other branches
  1. 5 lineage.module \lineage_update_all()
  2. 6 lineage.module \lineage_update_all()

Updates all lineage records.

Parameters

$vid=false If passed, limit to records for only one vocabulary.:

Return value

$count The number of records updated.

3 calls to lineage_update_all()
lineage_enable in ./lineage.module
lineage_taxonomy_overview_terms_submit in ./lineage.module
Submit handler for taxonomy_overview_terms (the admin term reordering form). Overrides handling so that we can update lineages after the new term weights are processed. This function is mostly a clone of taxonomy_overview_terms_submit, with the…
lineage_update_term in ./lineage.module

File

./lineage.module, line 171
lineage.module Module code for taxonomy term hierarchy lineage.

Code

function lineage_update_all($vid = FALSE) {
  $query = db_select('taxonomy_term_data', 'td');
  $query
    ->join('taxonomy_term_hierarchy', 'th', 'th.tid = td.tid');
  $query
    ->fields('td', array(
    'tid',
    'name',
    'weight',
    'vid',
  ));
  $query
    ->fields('th', array(
    'parent',
  ));
  $query
    ->condition('th.parent', 0);

  // If we are only updating one vocabulary, select only those terms.
  if ($vid) {
    $query
      ->condition('td.vid', $vid);
  }
  $result = $query
    ->execute();
  $count = 0;
  foreach ($result as $term) {
    $count += lineage_update_term($term, TRUE);
  }
  return $count;
}