You are here

function _tvi_convert_tids_to_uuids in Taxonomy Views Integrator 7

Massively convert all settings based on the tid to uuids.

1 call to _tvi_convert_tids_to_uuids()
tvi_modules_enabled in ./tvi.module
Implements hook_modules_enabled().

File

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

Code

function _tvi_convert_tids_to_uuids() {
  module_load_include('module', 'uuid');
  uuid_sync_all();
  $variables = db_select('variable', 'v')
    ->fields('v')
    ->condition('v.name', 'tvi_' . TVI_TYPE_TERM . '_%', 'LIKE')
    ->execute()
    ->fetchAll();
  foreach ($variables as $variable) {
    $tid = drupal_substr($variable->name, drupal_strlen('tvi_' . TVI_TYPE_TERM . '_'));
    $uuid = reset(entity_get_uuid_by_id('taxonomy_term', array(
      $tid,
    )));
    if (!empty($uuid) && $tid != $uuid) {
      db_update('variable')
        ->fields(array(
        'name' => 'tvi_' . TVI_TYPE_TERM . '_' . $uuid,
      ))
        ->condition('name', $variable->name)
        ->execute();
    }
  }
}