You are here

function _tvi_convert_uuids_to_tids in Taxonomy Views Integrator 7

Massively convert all settings based on the uuids to tids.

As UUID is disabled we cannot use its functions to retreive the related tid so we have to get the value from the database.

1 call to _tvi_convert_uuids_to_tids()
tvi_modules_disabled in ./tvi.module
Implements hook_modules_disabled().

File

includes/tvi.query.inc, line 208
Database interface for the tvi module.

Code

function _tvi_convert_uuids_to_tids() {
  $variables = db_select('variable', 'v')
    ->fields('v')
    ->condition('v.name', 'tvi_' . TVI_TYPE_TERM . '_%', 'LIKE')
    ->execute()
    ->fetchAll();
  foreach ($variables as $variable) {
    $uuid = drupal_substr($variable->name, drupal_strlen('tvi_' . TVI_TYPE_TERM . '_'));
    $tid = db_select('taxonomy_term_data', 'ttd')
      ->fields('ttd', array(
      'tid',
    ))
      ->condition('ttd.uuid', $uuid)
      ->execute()
      ->fetchColumn();
    if (!empty($tid) && $tid != $uuid) {
      db_update('variable')
        ->fields(array(
        'name' => 'tvi_' . TVI_TYPE_TERM . '_' . $tid,
      ))
        ->condition('name', $variable->name)
        ->execute();
    }
  }
}