You are here

function i18n_taxonomy_update_7000 in Internationalization 7

Set vocabulary modes from D6 variable

1 call to i18n_taxonomy_update_7000()
i18n_taxonomy_install in i18n_taxonomy/i18n_taxonomy.install
Set language field in its own table. Do not drop node.language now, just in case. TO-DO: Drop old tables, fields

File

i18n_taxonomy/i18n_taxonomy.install, line 61
Installation file for i18n_taxonomy module.

Code

function i18n_taxonomy_update_7000() {
  if ($options = variable_get('i18ntaxonomy_vocabulary')) {
    foreach ($options as $vid => $mode) {
      $mode = $mode == 3 ? I18N_MODE_TRANSLATE : $mode;
      db_update('taxonomy_vocabulary')
        ->fields(array(
        'i18n_mode' => $mode,
      ))
        ->condition('vid', $vid)
        ->execute();
    }
    variable_del('i18ntaxonomy_vocabulary');
  }

  // Move to new translation set system
  if (db_field_exists('taxonomy_term_data', 'trid')) {
    $query = db_select('taxonomy_term_data', 't');
    $query
      ->join('taxonomy_vocabulary', 'v', 't.vid = v.vid');
    $query
      ->fields('t', array(
      'trid',
    ))
      ->fields('v', array(
      'machine_name',
    ))
      ->condition('t.trid', 0, '>')
      ->distinct();
    foreach ($query
      ->execute() as $record) {
      $tset = i18n_translation_set_create('taxonomy_term', $record->machine_name);
      db_update('taxonomy_term_data')
        ->fields(array(
        'trid' => 0,
        'i18n_tsid' => $tset->tsid,
      ))
        ->condition('trid', $record->trid)
        ->execute();
    }
    db_drop_field('taxonomy_term_data', 'trid');
  }
}