You are here

function i18n_block_update_7000 in Internationalization 7

Drupal 6 update from old i18nblocks module.

1 call to i18n_block_update_7000()
i18n_block_install in i18n_block/i18n_block.install
Implements hook_install().

File

i18n_block/i18n_block.install, line 77
Installation file for i18nblocks module.

Code

function i18n_block_update_7000() {

  // D6-D7 updates, to be written
  // move block language from i18n_blocks into i18n_block_language
  // Move block type from i18n_blocks into block table (i18n_mode)
  if (db_table_exists('i18n_blocks')) {
    foreach (db_query("SELECT * FROM {i18n_blocks}")
      ->fetchAll() as $block) {
      if ($block->language) {

        // Set language for block
        db_merge('i18n_block_language')
          ->key(array(
          'module' => $block->module,
          'delta' => $block->delta,
        ))
          ->fields(array(
          'language' => $block->language,
        ))
          ->execute();
      }
      else {

        // Mark block as translatable
        db_update('block')
          ->fields(array(
          'i18n_mode' => 1,
        ))
          ->condition('module', $block->module)
          ->condition('delta', $block->delta)
          ->execute();
      }
    }
  }
}