You are here

function lingotek_update_7607 in Lingotek Translation 7.7

Convert 'create_lingotek_document' and 'sync_method' to 'auto_upload' and 'auto_download', respectively.

1 call to lingotek_update_7607()
lingotek_install in ./lingotek.install
Implements hook_install().
1 string reference to 'lingotek_update_7607'
lingotek_check_for_updates in ./lingotek.module

File

./lingotek.install, line 1017

Code

function lingotek_update_7607(&$sandbox) {

  // convert the profile settings
  $profiles = variable_get('lingotek_profiles', array());
  foreach ($profiles as &$profile) {
    if (isset($profile['sync_method'])) {
      $profile['auto_download'] = $profile['sync_method'];
      unset($profile['sync_method']);
    }
    if (isset($profile['create_lingotek_document'])) {
      $profile['auto_upload'] = $profile['create_lingotek_document'];
      unset($profile['create_lingotek_document']);
    }
  }
  variable_set('lingotek_profiles', $profiles);
  cache_clear_all();

  // modify the custom lines from the database
  db_update('lingotek_entity_metadata')
    ->fields(array(
    'entity_key' => 'auto_download',
  ))
    ->condition('entity_key', 'sync_method')
    ->execute();
  db_update('lingotek_entity_metadata')
    ->fields(array(
    'entity_key' => 'auto_upload',
  ))
    ->condition('entity_key', 'create_lingotek_document')
    ->execute();
  variable_set('lingotek_update_7607', TRUE);
  return t('Converted profile references of "sync method" to "auto-download" and references of "create lingotek document" to "auto-upload".');
}