You are here

globallink.install in GlobalLink Connect for Drupal 7.7

Installation file for GlobalLink module.

File

globallink.install
View source
<?php

/**
 * @file
 * Installation file for GlobalLink module.
 */

/**
 * Implements hook_schema().
 */
function globallink_schema() {
  $schema = array();
  $schema['globallink_submission'] = array(
    'description' => 'GlobalLink Submission Table',
    'fields' => array(
      'rid' => array(
        'description' => 'The row id',
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => FALSE,
      ),
      'submission' => array(
        'description' => 'The submission name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'pd_submission_id' => array(
        'description' => 'The PD submission ID',
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
      ),
      'submission_ticket' => array(
        'description' => 'The submission ticket',
        'type' => 'varchar',
        'length' => 45,
        'not null' => TRUE,
      ),
      'source_lang_code' => array(
        'description' => 'The source language code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => TRUE,
      ),
      'source_lang_name' => array(
        'description' => 'The source language name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'sub_target_lang_code' => array(
        'description' => 'The submission target language code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => TRUE,
      ),
      'sub_target_lang_name' => array(
        'description' => 'The submission target language name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'project_code' => array(
        'description' => 'The project code',
        'type' => 'varchar',
        'length' => 45,
        'not null' => TRUE,
      ),
      'project_name' => array(
        'description' => 'The project name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'due_date' => array(
        'description' => 'The due date for the submission',
        'type' => 'varchar',
        'length' => 50,
        'not null' => FALSE,
      ),
      'status' => array(
        'description' => 'The status of submission',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'created' => array(
        'description' => 'The created date',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'updated' => array(
        'description' => 'The updated date',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
    ),
  );
  $schema['globallink_document'] = array(
    'description' => 'Globallink Document Table',
    'fields' => array(
      'rid' => array(
        'description' => 'The row id',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'submission_rid' => array(
        'description' => 'The submission id as foreign key',
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
      ),
      'document_ticket' => array(
        'description' => 'The document ticket',
        'type' => 'varchar',
        'length' => 50,
        'not null' => FALSE,
        'default' => '',
      ),
      'entity_type' => array(
        'description' => 'The entity type',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'entity_type_name' => array(
        'description' => 'The entity type display name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_type' => array(
        'description' => 'the object type',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_type_name' => array(
        'description' => 'the object type display name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_id' => array(
        'description' => 'The object ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_parent_id' => array(
        'description' => 'The object parent ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_version_id' => array(
        'description' => 'The object version ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_title' => array(
        'description' => 'The object title',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_lang_code' => array(
        'description' => 'The target langauge code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => FALSE,
      ),
      'target_status' => array(
        'description' => 'The target status',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_ticket' => array(
        'description' => 'The target ticket',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_last_sent' => array(
        'description' => 'Target was sent last',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'target_last_updated' => array(
        'description' => 'Target last updated',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'indexes' => array(
      'submission_rid' => array(
        'submission_rid',
      ),
      'entity_type' => array(
        'entity_type',
      ),
      'target_status' => array(
        'target_status',
      ),
    ),
  );
  $schema['globallink_core'] = array(
    'description' => 'GlobalLink Core Table for Node and Entity Change Detection',
    'fields' => array(
      'rid' => array(
        'description' => 'The row ID',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'The node id',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'vid' => array(
        'description' => 'The current {node_revisions}.vid version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'source' => array(
        'description' => 'The origin language of the requested translation',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
      ),
      'target' => array(
        'description' => 'The target language of the requested translation',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
      ),
      'last_modified' => array(
        'description' => 'Last Modified Date for Source Node',
        'type' => 'int',
        'length' => 14,
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'changed' => array(
        'description' => 'Boolean Flag indicating whether source node has changed',
        'type' => 'int',
        'length' => 1,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  $schema['globallink_locale'] = array(
    'description' => 'GlobalLink Locale Table',
    'fields' => array(
      'locale_code' => array(
        'description' => 'ISO locale code',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
      ),
      'locale_desc' => array(
        'description' => 'ISO locale description',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
      ),
      'drupal_locale_code' => array(
        'description' => 'Drupal locale code',
        'type' => 'varchar',
        'length' => 10,
        'not null' => FALSE,
      ),
      'drupal_locale_desc' => array(
        'description' => 'Drupal locale description',
        'type' => 'varchar',
        'length' => 50,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'locale_code',
    ),
    'indexes' => array(
      'drupal_locale_code' => array(
        'drupal_locale_code',
      ),
    ),
  );
  $schema['globallink_field_config'] = array(
    'description' => 'GlobalLink Field Configuration Table',
    'fields' => array(
      'fid' => array(
        'description' => 'The row ID',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'content_type' => array(
        'description' => 'The content type for the field',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The entity type for the field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'bundle' => array(
        'description' => 'The node type for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_name' => array(
        'description' => 'The field_name for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_type' => array(
        'description' => 'The field_type for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_label' => array(
        'description' => 'The field_label for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'field_format' => array(
        'description' => 'The field_format for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'translatable' => array(
        'description' => 'Is this field translatable?',
        'type' => 'int',
        'length' => 1,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'fid',
    ),
    'indexes' => array(
      'field_name' => array(
        'field_name',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function globallink_install() {
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'aa',
    'locale_desc' => 'Afar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'aa_DJ',
    'locale_desc' => 'Afar, Djibouti',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'aa_ER',
    'locale_desc' => 'Afar, Eritrea',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'aa_ET',
    'locale_desc' => 'Afar, Ethiopia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ab_GE',
    'locale_desc' => 'Abkhazian, Georgia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ae_ES',
    'locale_desc' => 'Spain, Aranese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'af',
    'locale_desc' => 'Afrikaans',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'af_NA',
    'locale_desc' => 'Afrikaans, Namibia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'af_ZA',
    'locale_desc' => 'Afrikaans, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'am',
    'locale_desc' => 'Amharic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'am_ET',
    'locale_desc' => 'Amharic, Ethiopia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'an',
    'locale_desc' => 'Aragonese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'an_ES',
    'locale_desc' => 'Aragonese, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar',
    'locale_desc' => 'Arabic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_AE',
    'locale_desc' => 'Arabic, United Arab Emirates',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_BH',
    'locale_desc' => 'Arabic, Bahrain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_DZ',
    'locale_desc' => 'Arabic, Algeria',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_EG',
    'locale_desc' => 'Arabic, Egypt',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_IQ',
    'locale_desc' => 'Arabic, Iraq',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_JO',
    'locale_desc' => 'Arabic, Jordan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_KW',
    'locale_desc' => 'Arabic, Kuwait',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_LB',
    'locale_desc' => 'Arabic, Lebanon',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_LY',
    'locale_desc' => 'Arabic, Libya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_MA',
    'locale_desc' => 'Arabic, Morocco',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_OM',
    'locale_desc' => 'Arabic, Oman',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_QA',
    'locale_desc' => 'Arabic, Qatar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_SA',
    'locale_desc' => 'Arabic, Saudi Arabia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_SD',
    'locale_desc' => 'Arabic, Sudan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_SY',
    'locale_desc' => 'Arabic, Syria',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_TN',
    'locale_desc' => 'Arabic, Tunisia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar_YE',
    'locale_desc' => 'Arabic, Yemen',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'as',
    'locale_desc' => 'Assamese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'as_IN',
    'locale_desc' => 'Assamese, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ay',
    'locale_desc' => 'Aymara',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ay_BO',
    'locale_desc' => 'Aymara, Bolivia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ay_PE',
    'locale_desc' => 'Aymara, Peru',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az',
    'locale_desc' => 'Azerbaijani',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az_AZ',
    'locale_desc' => 'Azerbaijani, Azerbaijan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az-XC',
    'locale_desc' => 'Azerbaijani-Cyrillic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az-XE',
    'locale_desc' => 'Azerbaijani-Latin',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ba',
    'locale_desc' => 'Bashkir',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ba_RU',
    'locale_desc' => 'Bashkir, Russia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bd_ID',
    'locale_desc' => 'Bahasa, Indonesia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bd_MY',
    'locale_desc' => 'Bahasa, Malaysia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'be',
    'locale_desc' => 'Belarusian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'be_BY',
    'locale_desc' => 'Byelorussian, Byelorussia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bg',
    'locale_desc' => 'Bulgarian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bg_BG',
    'locale_desc' => 'Bulgarian, Bulgaria',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bh',
    'locale_desc' => 'Bihari',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bi',
    'locale_desc' => 'Bislama',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bn',
    'locale_desc' => 'Bengali',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bn_BD',
    'locale_desc' => 'Bengali, Bangladesh',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bn_IN',
    'locale_desc' => 'Bengali, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bo_CN',
    'locale_desc' => 'Tibetan, China',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'br',
    'locale_desc' => 'Breton',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bs',
    'locale_desc' => 'Bosnian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bs-BA',
    'locale_desc' => 'Bosnian, Bosnien und Herzegowina',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ca',
    'locale_desc' => 'Catalan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ca_ES',
    'locale_desc' => 'Catalan, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cb',
    'locale_desc' => 'Cebuano',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cb_PH',
    'locale_desc' => 'Cebuano, Philippines',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ce',
    'locale_desc' => 'Chechen',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ch',
    'locale_desc' => 'Chamorro',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'co',
    'locale_desc' => 'Corsican',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cs',
    'locale_desc' => 'Czech',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cs_CZ',
    'locale_desc' => 'Czech, Czech Republic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cy',
    'locale_desc' => 'Welsh',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cy_GB',
    'locale_desc' => 'Welsh, United Kingdom',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'da',
    'locale_desc' => 'Danish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'da_DK',
    'locale_desc' => 'Danish, Denmark',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de',
    'locale_desc' => 'German',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de_AT',
    'locale_desc' => 'German, Austria',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de_CH',
    'locale_desc' => 'German, Switzerland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de_DE',
    'locale_desc' => 'German, Germany',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de_LI',
    'locale_desc' => 'German, Liechtenstein',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de_LU',
    'locale_desc' => 'German, Luxembourg',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'dz',
    'locale_desc' => 'Dzongkha',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'el',
    'locale_desc' => 'Greek',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'el_CY',
    'locale_desc' => 'Greek, Cyprus',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'el_GR',
    'locale_desc' => 'Greek, Greece',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en',
    'locale_desc' => 'English',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_AU',
    'locale_desc' => 'English, Australia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_BZ',
    'locale_desc' => 'English, Belize',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_CA',
    'locale_desc' => 'English, Canada',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_CB',
    'locale_desc' => 'English, Caribbean',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_GB',
    'locale_desc' => 'English, United Kingdom',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_ID',
    'locale_desc' => 'English, Indonesia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_IE',
    'locale_desc' => 'English, Ireland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_IN',
    'locale_desc' => 'English, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_JM',
    'locale_desc' => 'English, Jamaica',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_MT',
    'locale_desc' => 'English, Malta',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_NZ',
    'locale_desc' => 'English, New Zealand',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_PH',
    'locale_desc' => 'English, Philippines',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_RH',
    'locale_desc' => 'English, Zimbabwe',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_SG',
    'locale_desc' => 'English, Singapore',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_TT',
    'locale_desc' => 'English, Trinidad and Tobago',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_US',
    'locale_desc' => 'English, United States',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en_ZA',
    'locale_desc' => 'English, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es',
    'locale_desc' => 'Spanish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_AR',
    'locale_desc' => 'Spanish, Argentina',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_BO',
    'locale_desc' => 'Spanish, Bolivia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_CL',
    'locale_desc' => 'Spanish, Chile',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_CO',
    'locale_desc' => 'Spanish, Colombia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_CR',
    'locale_desc' => 'Spanish, Costa Rica',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_DO',
    'locale_desc' => 'Spanish, Dominican Republic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_EC',
    'locale_desc' => 'Spanish, Ecuador',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_ES',
    'locale_desc' => 'Spanish, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_GT',
    'locale_desc' => 'Spanish, Guatemala',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_HN',
    'locale_desc' => 'Spanish, Honduras',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_LA',
    'locale_desc' => 'Spanish, Latin America',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_MX',
    'locale_desc' => 'Spanish, Mexico',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_NI',
    'locale_desc' => 'Spanish, Nicaragua',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_PA',
    'locale_desc' => 'Spanish, Panama',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_PE',
    'locale_desc' => 'Spanish, Peru',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_PR',
    'locale_desc' => 'Spanish, Puerto Rico',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_PY',
    'locale_desc' => 'Spanish, Paraguay',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_SV',
    'locale_desc' => 'Spanish, El Salvador',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_US',
    'locale_desc' => 'Spanish, United States',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_UY',
    'locale_desc' => 'Spanish, Uruguay',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es_VE',
    'locale_desc' => 'Spanish, Venezuela',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'et',
    'locale_desc' => 'Estonian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'et_EE',
    'locale_desc' => 'Estonian, Estonia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'eu',
    'locale_desc' => 'Basque',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'eu_ES',
    'locale_desc' => 'Basque, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fa',
    'locale_desc' => 'Persian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fa_AF',
    'locale_desc' => 'Persian-Dari, Afghanistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fa_IR',
    'locale_desc' => 'Farsi, Iran',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fi',
    'locale_desc' => 'Finnish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fi_FI',
    'locale_desc' => 'Finnish, Finland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fj',
    'locale_desc' => 'Fijian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fj_FJ',
    'locale_desc' => 'Fijian, Fiji',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fj_PH',
    'locale_desc' => 'Fijian, Philippines',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fo',
    'locale_desc' => 'Faroese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fo_FO',
    'locale_desc' => 'Faroese, Faroe Islands',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr',
    'locale_desc' => 'French',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_BE',
    'locale_desc' => 'French, Belgium',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_CA',
    'locale_desc' => 'French, Canada',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_CH',
    'locale_desc' => 'French, Switzerland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_FR',
    'locale_desc' => 'French, France',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_LU',
    'locale_desc' => 'French, Luxembourg',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_MC',
    'locale_desc' => 'French, Monaco',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_NC',
    'locale_desc' => 'French, New Caledonia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr_PF',
    'locale_desc' => 'French, French Polynesia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fy',
    'locale_desc' => 'Frisian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fy_NL',
    'locale_desc' => 'Frisian, Netherlands',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ga',
    'locale_desc' => 'Irish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ga_IE',
    'locale_desc' => 'Irish, Ireland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gd',
    'locale_desc' => 'Scottish Gaelic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gd_GB',
    'locale_desc' => 'Scottish Gaelic, United Kingdom',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gl',
    'locale_desc' => 'Galician',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gl_ES',
    'locale_desc' => 'Galician, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gn',
    'locale_desc' => 'Guaraní',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gs_ES',
    'locale_desc' => 'Gascon, Spain',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gu',
    'locale_desc' => 'Gujarati',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gu_IN',
    'locale_desc' => 'Gujarati, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ha',
    'locale_desc' => 'Hausa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'he',
    'locale_desc' => 'Hebrew',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'he_IL',
    'locale_desc' => 'Hebrew, Israel',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hi',
    'locale_desc' => 'Hindi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hi_IN',
    'locale_desc' => 'Hindi, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hm',
    'locale_desc' => 'Hmong',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hr',
    'locale_desc' => 'Croatian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hr_HR',
    'locale_desc' => 'Croatian, Croatia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ht',
    'locale_desc' => 'Haitian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hu',
    'locale_desc' => 'Hungarian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hu_HU',
    'locale_desc' => 'Hungarian, Hungary',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hy',
    'locale_desc' => 'Armenian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hy_AM',
    'locale_desc' => 'Armenian, Armenia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ia',
    'locale_desc' => 'Interlingua',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'id',
    'locale_desc' => 'Indonesian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'id_ID',
    'locale_desc' => 'Indonesian, Indonesia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ie',
    'locale_desc' => 'Interlingue',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ik',
    'locale_desc' => 'Inupiaq',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'il',
    'locale_desc' => 'Ilonggo',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'is',
    'locale_desc' => 'Icelandic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'is_IS',
    'locale_desc' => 'Icelandic, Iceland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'it',
    'locale_desc' => 'Italian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'it_CH',
    'locale_desc' => 'Italian, Switzerland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'it_IT',
    'locale_desc' => 'Italian, Italy',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'iu',
    'locale_desc' => 'Inuktitut',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ja',
    'locale_desc' => 'Japanese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ja_JP',
    'locale_desc' => 'Japanese, Japan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'jv',
    'locale_desc' => 'Javanese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ka_GE',
    'locale_desc' => 'Georgian, Georgia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'kk_KZ',
    'locale_desc' => 'Kazakh, Kazakhstan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'kl',
    'locale_desc' => 'Kalaallisut',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'km_KH',
    'locale_desc' => 'Khmer, Cambodia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'kn_IN',
    'locale_desc' => 'Kannada, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ko',
    'locale_desc' => 'Korean',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ko_KR',
    'locale_desc' => 'Korean, South Korea',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ko_KP',
    'locale_desc' => 'Korean, North Korea',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ks',
    'locale_desc' => 'Kashmiri',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ku',
    'locale_desc' => 'Kurdish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ku_TR',
    'locale_desc' => 'Kurdish, Turkey',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ky_KG',
    'locale_desc' => 'Kirghiz, Kyrgyzstan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'la',
    'locale_desc' => 'Latin',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lb_LU',
    'locale_desc' => 'Luxembourgish, Luxembourg',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ln',
    'locale_desc' => 'Lingala',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ln_CD',
    'locale_desc' => 'Lingala, The Democratic Republic Of Congo',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lo_LA',
    'locale_desc' => 'Lao, Laos',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lt',
    'locale_desc' => 'Lithuanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lt_LT',
    'locale_desc' => 'Lithuanian, Lithuania',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lv',
    'locale_desc' => 'Latvian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lv_LV',
    'locale_desc' => 'Latvian, Latvia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mg',
    'locale_desc' => 'Malagasy',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mg_MG',
    'locale_desc' => 'Malagasy, Madagascar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mi',
    'locale_desc' => 'Maori',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mk',
    'locale_desc' => 'Macedonian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mk_MK',
    'locale_desc' => 'Macedonian, Macedonia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ml',
    'locale_desc' => 'Malayalam',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ml_IN',
    'locale_desc' => 'Malayalam, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mn',
    'locale_desc' => 'Mongolian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mn_MN',
    'locale_desc' => 'Mongolian, Mongolia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mo',
    'locale_desc' => 'Moldavian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mo_MD',
    'locale_desc' => 'Moldovan, Moldova',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mr',
    'locale_desc' => 'Marathi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mr_IN',
    'locale_desc' => 'Marathi, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ms',
    'locale_desc' => 'Malay',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ms_SG',
    'locale_desc' => 'Malay, Singapore',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ms_BX',
    'locale_desc' => 'Malay, Brunei Darussalam',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ms_MY',
    'locale_desc' => 'Malay, Malaysia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mt',
    'locale_desc' => 'Maltese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mt_MT',
    'locale_desc' => 'Maltese, Malta',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'my_MM',
    'locale_desc' => 'Burmese, MyanMar (Burma)',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'na',
    'locale_desc' => 'Nauru',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nb_NO',
    'locale_desc' => 'Norwegian Bokmal, Norway',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nd_ZA',
    'locale_desc' => 'North Ndebele, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ne',
    'locale_desc' => 'Nepali',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ne_NP',
    'locale_desc' => 'Nepali, Nepal',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nl',
    'locale_desc' => 'Dutch',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nl_BE',
    'locale_desc' => 'Dutch, Belgium',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nl_NL',
    'locale_desc' => 'Dutch, Netherlands',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'no',
    'locale_desc' => 'Norwegian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'no_NO',
    'locale_desc' => 'Norwegian (Nynorsk), Norway',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nr_ZA',
    'locale_desc' => 'South Ndebele, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ns_ZA',
    'locale_desc' => 'Nothern Sotho, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ny_MW',
    'locale_desc' => 'Nyanja, Malawi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'oc',
    'locale_desc' => 'Occitan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'oc_FR',
    'locale_desc' => 'Occitan, France',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'om',
    'locale_desc' => 'Oromo',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'om_ET',
    'locale_desc' => 'Oromo, Ethiopia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'or',
    'locale_desc' => 'Oriya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'or_IN',
    'locale_desc' => 'Oriya, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pa',
    'locale_desc' => 'Punjabi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pa_IN',
    'locale_desc' => 'Punjabi (Gurmukha), India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pa_PK',
    'locale_desc' => 'Punjabi (Shahmukhi), Pakistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pl',
    'locale_desc' => 'Polish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pl_PL',
    'locale_desc' => 'Polish, Poland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ps_AF',
    'locale_desc' => 'Pashto, Afghanistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pt',
    'locale_desc' => 'Portuguese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pt_BR',
    'locale_desc' => 'Portuguese, Brazil',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pt_PT',
    'locale_desc' => 'Portuguese, Portugal',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'qu',
    'locale_desc' => 'Quechua',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'qu_BO',
    'locale_desc' => 'Quechua, Bolivia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'qu_EU',
    'locale_desc' => 'Quechua, Ecuador',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rm',
    'locale_desc' => 'Romansh',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rn',
    'locale_desc' => 'Kirundi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ro',
    'locale_desc' => 'Romanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ro_RO',
    'locale_desc' => 'Romanian, Romania',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru',
    'locale_desc' => 'Russian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru_KZ',
    'locale_desc' => 'Russian, Kazakhstan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru_KG',
    'locale_desc' => 'Russian, Kyrgyzstan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru_UA',
    'locale_desc' => 'Russian, Ukraine',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru_BY',
    'locale_desc' => 'Russian, Belarus',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru_RU',
    'locale_desc' => 'Russian, Russia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rw',
    'locale_desc' => 'Kinyarwanda',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rw_RW',
    'locale_desc' => 'Kinyarwanda, Rwanda',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sa',
    'locale_desc' => 'Sanskrit',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sd',
    'locale_desc' => 'Sindhi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sg',
    'locale_desc' => 'Sango',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sh_YU',
    'locale_desc' => 'Serbo_Croatian, Yugoslavia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'si_LK',
    'locale_desc' => 'Sinhalese, Sri Lanka',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sk',
    'locale_desc' => 'Slovak',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sk_SK',
    'locale_desc' => 'Slovak, Slovakia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sl',
    'locale_desc' => 'Slovenian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sl_SL',
    'locale_desc' => 'Slovenian, Slovenia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sm',
    'locale_desc' => 'Samoan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sn',
    'locale_desc' => 'Shona',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'so_SO',
    'locale_desc' => 'Somali, Somalia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sq',
    'locale_desc' => 'Albanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sq_AL',
    'locale_desc' => 'Albanian, Albania',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr',
    'locale_desc' => 'Serbian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr_BA',
    'locale_desc' => 'Serbian, Bosnia and Herzegovina',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr_CS',
    'locale_desc' => 'Serbian, Serbia and Montenegro',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr-ME',
    'locale_desc' => 'Serbian, Montenegro',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr_YU',
    'locale_desc' => 'Serbian (Cyrillic), Yugoslavia',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ss',
    'locale_desc' => 'Swati',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ss_ZA',
    'locale_desc' => 'Swati, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'st',
    'locale_desc' => 'Southern Sotho',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'st_ZA',
    'locale_desc' => 'Southern Sotho, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'su_SU',
    'locale_desc' => 'Sudanese, Sudan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sv',
    'locale_desc' => 'Swedish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sv_FI',
    'locale_desc' => 'Swedish, Finland',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sv_SE',
    'locale_desc' => 'Swedish, Sweden',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sw',
    'locale_desc' => 'Swahili',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sw_KE',
    'locale_desc' => 'Swahili, Kenya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sz',
    'locale_desc' => 'Sami',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tg_TJ',
    'locale_desc' => 'Tajik, Tajikistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'th_TH',
    'locale_desc' => 'Thai, Thailand',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ta',
    'locale_desc' => 'Tamil',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ta_IN',
    'locale_desc' => 'Tamil, India',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'te',
    'locale_desc' => 'Telugu',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ti',
    'locale_desc' => 'Tigrinya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tk',
    'locale_desc' => 'Turkmen',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tl',
    'locale_desc' => 'Tagalog',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tl_PH',
    'locale_desc' => 'Tagalog, Philippines',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tn',
    'locale_desc' => 'Tswana',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tn_ZA',
    'locale_desc' => 'Tswana, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'to',
    'locale_desc' => 'Tonga',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tr',
    'locale_desc' => 'Turkish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tr_TR',
    'locale_desc' => 'Turkish, Turkey',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ts',
    'locale_desc' => 'Tsonga',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ts_ZA',
    'locale_desc' => 'Tsonga, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tt',
    'locale_desc' => 'Tatar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tw',
    'locale_desc' => 'Twi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ug',
    'locale_desc' => 'Uighur',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'uk',
    'locale_desc' => 'Ukrainian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'uk_UA',
    'locale_desc' => 'Ukrainian, Ukraine',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ur',
    'locale_desc' => 'Urdu',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ur_PK',
    'locale_desc' => 'Urdu (Pakistan), Pakistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 've_ZA',
    'locale_desc' => 'Venda, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vi',
    'locale_desc' => 'Vietnamese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vi-US',
    'locale_desc' => 'Vietnamese, United States',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vi_VN',
    'locale_desc' => 'Vietnamese, Vietnam',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vo',
    'locale_desc' => 'Volapük',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'uz_UZ',
    'locale_desc' => 'Uzbek, Uzbekistan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'xh',
    'locale_desc' => 'Xhosa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'xh_ZA',
    'locale_desc' => 'Xhosa, South Africa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'yi',
    'locale_desc' => 'Yiddish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'yo',
    'locale_desc' => 'Yoruba',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'za',
    'locale_desc' => 'Zhuang',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh',
    'locale_desc' => 'Chinese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh_CN',
    'locale_desc' => 'Chinese (Simplified), China',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh_HK',
    'locale_desc' => 'Chinese, Hong Kong',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh_SG',
    'locale_desc' => 'Chinese (Simplified), Singapore',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh_TW',
    'locale_desc' => 'Chinese (Traditional), Taiwan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh_XM',
    'locale_desc' => 'Chinese, Macau',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zu',
    'locale_desc' => 'Zulu',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zu_ZA',
    'locale_desc' => 'Zulu, South Africa',
  ))
    ->execute();
  variable_set('globallink_publish_node', 0);
  variable_set('globallink_cron_type', 0);
  variable_set('globallink_pager_limit', 10);
  variable_set('globallink_implementation_type', 0);
  variable_set('globallink_enable_preview', 1);
  variable_set('globallink_pd_max_target', 99999);
  $node_types = node_type_get_types();
  foreach ($node_types as $node_type) {
    if (!translation_supported_type($node_type->type)) {
      continue;
    }
    $field_arr = field_info_instances(GLOBALLINK_ENTITY_TYPE_NODE, $node_type->type);
    $keys = array_keys($field_arr);
    db_insert('globallink_field_config')
      ->fields(array(
      'content_type' => $node_type->type,
      'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
      'bundle' => $node_type->type,
      'field_name' => 'title',
      'field_type' => 'text',
      'field_label' => 'Title',
      'translatable' => 1,
    ))
      ->execute();
    if (module_exists('metatag')) {
      db_insert('globallink_field_config')
        ->fields(array(
        'content_type' => $node_type->type,
        'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
        'bundle' => $node_type->type,
        'field_name' => 'metatags',
        'field_type' => 'text',
        'field_label' => 'Meta tags',
        'translatable' => 1,
      ))
        ->execute();
    }
    foreach ($keys as $field_name) {
      $field = field_info_field($field_name);
      switch ($field['type']) {
        case 'list_boolean':
        case 'image':
        case 'file':
        case 'taxonomy_term_reference':
        case 'field_collection':
          break;
        default:
          $translatable = 0;
          db_insert('globallink_field_config')
            ->fields(array(
            'content_type' => $node_type->type,
            'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
            'bundle' => $node_type->type,
            'field_name' => $field_name,
            'field_type' => $field['type'],
            'field_label' => $field_arr[$field_name]['label'],
            'translatable' => $translatable,
          ))
            ->execute();
      }
    }
    if (module_exists('field_collection')) {
      globallink_insert_field_collections($node_type->type);
    }
  }
}

/**
 * Implements hook_uninstall().
 */
function globallink_uninstall() {
  variable_del('globallink_publish_node');
  variable_del('globallink_cron_type');
  variable_del('globallink_pager_limit');
  variable_del('globallink_pd_url');
  variable_del('globallink_pd_username');
  variable_del('globallink_pd_password');
  variable_del('globallink_pd_projectid');
  variable_del('globallink_pd_submissionprefix');
  variable_del('globallink_pd_classifier');
  variable_del('globallink_pd_max_target');
  variable_del('globallink_implementation_type');
  $keys = array_keys($_SESSION);
  foreach ($keys as $key) {
    if (stristr($key, 'globallink') !== FALSE) {
      unset($_SESSION[$key]);
    }
  }
}

/**
 * Implements hook_update_N().
 *
 * Version 2.0 updates.
 */
function globallink_update_7200() {
  variable_set('globallink_pd_max_target', 99999);
  $keys = array_keys($_SESSION);
  foreach ($keys as $key) {
    if (stristr($key, 'globallink') !== FALSE) {
      unset($_SESSION[$key]);
    }
  }
  $last_modified = array(
    'description' => 'Last Modified Date for Source Node',
    'type' => 'int',
    'length' => 14,
    'unsigned' => TRUE,
    'not null' => FALSE,
  );
  db_add_field('globallink_core', 'last_modified', $last_modified);
  $changed = array(
    'description' => 'Boolean Flag indicating whether source node has changed',
    'type' => 'int',
    'length' => 1,
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('globallink_core', 'changed', $changed);
  $schema = array();
  $schema['globallink_field_config'] = array(
    'description' => 'GlobalLink Field Config Table',
    'fields' => array(
      'fid' => array(
        'description' => 'The row ID',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'content_type' => array(
        'description' => 'The content type for the field',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The entity type for the field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'bundle' => array(
        'description' => 'The node type for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_name' => array(
        'description' => 'The field_name for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_type' => array(
        'description' => 'The field_type for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'field_label' => array(
        'description' => 'The field_label for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'field_format' => array(
        'description' => 'The field_format for this field',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'translatable' => array(
        'description' => 'Is this field translatable?',
        'type' => 'int',
        'length' => 1,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'fid',
    ),
    'indexes' => array(
      'field_name' => array(
        'field_name',
      ),
    ),
  );
  db_create_table('globallink_field_config', $schema['globallink_field_config']);
  $node_types = node_type_get_types();
  foreach ($node_types as $node_type) {
    if (!translation_supported_type($node_type->type)) {
      continue;
    }
    $field_arr = field_info_instances(GLOBALLINK_ENTITY_TYPE_NODE, $node_type->type);
    $keys = array_keys($field_arr);
    db_insert('globallink_field_config')
      ->fields(array(
      'content_type' => $node_type->type,
      'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
      'bundle' => $node_type->type,
      'field_name' => 'title',
      'field_type' => 'text',
      'field_label' => 'Title',
      'translatable' => 1,
    ))
      ->execute();
    if (module_exists('metatag')) {
      db_insert('globallink_field_config')
        ->fields(array(
        'content_type' => $node_type->type,
        'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
        'bundle' => $node_type->type,
        'field_name' => 'metatags',
        'field_type' => 'text',
        'field_label' => 'Meta tags',
        'translatable' => 1,
      ))
        ->execute();
    }
    foreach ($keys as $field_name) {
      $field = field_info_field($field_name);
      switch ($field['type']) {
        case 'list_boolean':
        case 'image':
        case 'file':
        case 'taxonomy_term_reference':
          break;
        case 'field_collection':
          if (!module_exists('field_collection')) {
            break;
          }
          db_insert('globallink_field_config')
            ->fields(array(
            'content_type' => $node_type->type,
            'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
            'bundle' => $node_type->type,
            'field_name' => $field_name,
            'field_type' => $field['type'],
            'field_label' => $field_arr[$field_name]['label'],
            'translatable' => 1,
          ))
            ->execute();
          $field_info = field_info_instances('field_collection_item');
          if (!isset($field_info) || !isset($field_info[$field_name])) {
            break;
          }
          $fc_item = $field_info[$field_name];
          foreach ($fc_item as $fc_name => $fc) {
            $fc_info = field_info_field($fc_name);
            switch ($fc_info['type']) {
              case 'list_boolean':
              case 'image':
              case 'file':
              case 'taxonomy_term_reference':
              case 'field_collection':
                break;
              default:
                db_insert('globallink_field_config')
                  ->fields(array(
                  'content_type' => $node_type->type,
                  'entity_type' => 'field_collection_item',
                  'bundle' => $fc['bundle'],
                  'field_name' => $fc_name,
                  'field_type' => $fc_info['type'],
                  'field_label' => $fc['label'],
                  'translatable' => 1,
                ))
                  ->execute();
            }
          }
          break;
        default:
          db_insert('globallink_field_config')
            ->fields(array(
            'content_type' => $node_type->type,
            'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
            'bundle' => $node_type->type,
            'field_name' => $field_name,
            'field_type' => $field['type'],
            'field_label' => $field_arr[$field_name]['label'],
            'translatable' => 1,
          ))
            ->execute();
          break;
      }
    }
  }
  return t('GlobalLink module has been successfully upgraded to version 2.0');
}

/**
 * Implements hook_update_N().
 *
 * Version 2.0.1 updates.
 */
function globallink_update_7201() {
  $keys = array_keys($_SESSION);
  foreach ($keys as $key) {
    if (stristr($key, 'globallink') !== FALSE) {
      unset($_SESSION[$key]);
    }
  }
  if (!module_exists('field_collection')) {
    return;
  }
  db_truncate('globallink_field_config')
    ->execute();
  $node_types = node_type_get_types();
  foreach ($node_types as $node_type) {
    if (!translation_supported_type($node_type->type)) {
      continue;
    }
    $field_arr = field_info_instances(GLOBALLINK_ENTITY_TYPE_NODE, $node_type->type);
    $keys = array_keys($field_arr);
    db_insert('globallink_field_config')
      ->fields(array(
      'content_type' => $node_type->type,
      'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
      'bundle' => $node_type->type,
      'field_name' => 'title',
      'field_type' => 'text',
      'field_label' => 'Title',
      'translatable' => 1,
    ))
      ->execute();
    if (module_exists('metatag')) {
      db_insert('globallink_field_config')
        ->fields(array(
        'content_type' => $node_type->type,
        'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
        'bundle' => $node_type->type,
        'field_name' => 'metatags',
        'field_type' => 'text',
        'field_label' => 'Meta tags',
        'translatable' => 1,
      ))
        ->execute();
    }
    foreach ($keys as $field_name) {
      $field = field_info_field($field_name);
      switch ($field['type']) {
        case 'list_boolean':
        case 'image':
        case 'file':
        case 'taxonomy_term_reference':
        case 'field_collection':
          break;
        default:
          $translatable = 1;
          db_insert('globallink_field_config')
            ->fields(array(
            'content_type' => $node_type->type,
            'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
            'bundle' => $node_type->type,
            'field_name' => $field_name,
            'field_type' => $field['type'],
            'field_label' => $field_arr[$field_name]['label'],
            'translatable' => $translatable,
          ))
            ->execute();
      }
    }
    if (module_exists('field_collection')) {
      globallink_insert_field_collections($node_type->type);
    }
  }
  return t('GlobalLink module has been successfully upgraded to version 2.0.1');
}

/**
 * Inserts field collections.
 *
 * @param string $node_type
 *   The content type.
 */
function globallink_insert_field_collections($node_type) {
  $field_arr = field_info_instances(GLOBALLINK_ENTITY_TYPE_NODE, $node_type);
  $keys = array_keys($field_arr);
  foreach ($keys as $field_name) {
    $field_info = field_info_field($field_name);
    if ($field_info['type'] != 'field_collection') {
      continue;
    }
    db_insert('globallink_field_config')
      ->fields(array(
      'content_type' => $node_type,
      'entity_type' => GLOBALLINK_ENTITY_TYPE_NODE,
      'bundle' => $node_type,
      'field_name' => $field_name,
      'field_type' => $field_info['type'],
      'field_label' => $field_arr[$field_name]['label'],
      'translatable' => 0,
    ))
      ->execute();
    $fc_field_infos = field_info_instances('field_collection_item');
    if (isset($fc_field_infos) && isset($fc_field_infos[$field_name]) && is_array($fc_field_infos[$field_name])) {
      $fc_items = array_keys($fc_field_infos[$field_name]);
      foreach ($fc_items as $fc_item) {
        globallink_insert_field_collection_items($node_type, $field_name, $fc_item);
      }
    }
  }
}

/**
 * Inserts field collection items.
 *
 * @param string $content_type
 *   The content type.
 * @param string $parent_field_name
 *   The parent's field name.
 * @param string $field_name
 *   The field name.
 */
function globallink_insert_field_collection_items($content_type, $parent_field_name, $field_name) {
  $fc_field_info = field_info_field($field_name);
  $fc_field_instance = field_info_instance('field_collection_item', $field_name, $parent_field_name);
  switch ($fc_field_info['type']) {
    case 'list_boolean':
    case 'image':
    case 'file':
    case 'taxonomy_term_reference':
      break;
    case 'field_collection':
      db_insert('globallink_field_config')
        ->fields(array(
        'content_type' => $content_type,
        'entity_type' => 'field_collection_item',
        'bundle' => $parent_field_name,
        'field_name' => $field_name,
        'field_type' => $fc_field_info['type'],
        'field_label' => $fc_field_instance['label'],
        'translatable' => 0,
      ))
        ->execute();
      $fc_field_infos = field_info_instances('field_collection_item');
      if (isset($fc_field_infos) && isset($fc_field_infos[$field_name]) && is_array($fc_field_infos[$field_name])) {
        $fc_items = array_keys($fc_field_infos[$field_name]);
        foreach ($fc_items as $fc_item) {
          globallink_insert_field_collection_items($content_type, $field_name, $fc_item);
        }
      }
      break;
    default:
      $translatable = 1;
      db_insert('globallink_field_config')
        ->fields(array(
        'content_type' => $content_type,
        'entity_type' => 'field_collection_item',
        'bundle' => $parent_field_name,
        'field_name' => $field_name,
        'field_type' => $fc_field_info['type'],
        'field_label' => $fc_field_instance['label'],
        'translatable' => $translatable,
      ))
        ->execute();
  }
}

/**
 * Implements hook_update_N().
 *
 * Version 2.1.0 updates.
 */
function globallink_update_7210() {
  $keys = array_keys($_SESSION);
  foreach ($keys as $key) {
    if (stristr($key, 'globallink') !== FALSE) {
      unset($_SESSION[$key]);
    }
  }
  db_update('globallink_core')
    ->fields(array(
    'status' => GLOBALLINK_STATUS_TRANSLATION_SOURCE_DELETED,
  ))
    ->condition('status', 'Node Deleted', '=')
    ->execute();
}

/**
 * Implements hook_update_N().
 *
 * Version 2.3.0 updates.
 */
function globallink_update_7230() {
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'aa',
    'locale_desc' => 'Afar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'af',
    'locale_desc' => 'Afrikaans',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'am',
    'locale_desc' => 'Amharic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'an',
    'locale_desc' => 'Aragonese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ar',
    'locale_desc' => 'Arabic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'as',
    'locale_desc' => 'Assamese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ay',
    'locale_desc' => 'Aymara',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az',
    'locale_desc' => 'Azerbaijani',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az-XC',
    'locale_desc' => 'Azerbaijani-Cyrillic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'az-XE',
    'locale_desc' => 'Azerbaijani-Latin',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ba',
    'locale_desc' => 'Bashkir',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'be',
    'locale_desc' => 'Belarusian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bg',
    'locale_desc' => 'Bulgarian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bh',
    'locale_desc' => 'Bihari',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bi',
    'locale_desc' => 'Bislama',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bn',
    'locale_desc' => 'Bengali',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'br',
    'locale_desc' => 'Breton',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bs',
    'locale_desc' => 'Bosnian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'bs-BA',
    'locale_desc' => 'Bosnian, Bosnien und Herzegowina',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ca',
    'locale_desc' => 'Catalan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cb',
    'locale_desc' => 'Cebuano',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ce',
    'locale_desc' => 'Chechen',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ch',
    'locale_desc' => 'Chamorro',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'co',
    'locale_desc' => 'Corsican',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cs',
    'locale_desc' => 'Czech',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'cy',
    'locale_desc' => 'Welsh',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'da',
    'locale_desc' => 'Danish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'de',
    'locale_desc' => 'German',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'dz',
    'locale_desc' => 'Dzongkha',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'el',
    'locale_desc' => 'Greek',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'en',
    'locale_desc' => 'English',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'es',
    'locale_desc' => 'Spanish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'et',
    'locale_desc' => 'Estonian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'eu',
    'locale_desc' => 'Basque',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fa',
    'locale_desc' => 'Persian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fi',
    'locale_desc' => 'Finnish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fj',
    'locale_desc' => 'Fijian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fo',
    'locale_desc' => 'Faroese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fr',
    'locale_desc' => 'French',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'fy',
    'locale_desc' => 'Frisian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ga',
    'locale_desc' => 'Irish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gd',
    'locale_desc' => 'Scottish Gaelic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gl',
    'locale_desc' => 'Galician',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gn',
    'locale_desc' => 'Guaraní',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'gu',
    'locale_desc' => 'Gujarati',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ha',
    'locale_desc' => 'Hausa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'he',
    'locale_desc' => 'Hebrew',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hi',
    'locale_desc' => 'Hindi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hm',
    'locale_desc' => 'Hmong',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hr',
    'locale_desc' => 'Croatian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ht',
    'locale_desc' => 'Haitian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hu',
    'locale_desc' => 'Hungarian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'hy',
    'locale_desc' => 'Armenian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ia',
    'locale_desc' => 'Interlingua',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'id',
    'locale_desc' => 'Indonesian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ie',
    'locale_desc' => 'Interlingue',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ik',
    'locale_desc' => 'Inupiaq',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'il',
    'locale_desc' => 'Ilonggo',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'is',
    'locale_desc' => 'Icelandic',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'it',
    'locale_desc' => 'Italian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'iu',
    'locale_desc' => 'Inuktitut',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ja',
    'locale_desc' => 'Japanese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'jv',
    'locale_desc' => 'Javanese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'kl',
    'locale_desc' => 'Kalaallisut',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ko',
    'locale_desc' => 'Korean',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ks',
    'locale_desc' => 'Kashmiri',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ku',
    'locale_desc' => 'Kurdish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'la',
    'locale_desc' => 'Latin',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ln',
    'locale_desc' => 'Lingala',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lt',
    'locale_desc' => 'Lithuanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'lv',
    'locale_desc' => 'Latvian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mg',
    'locale_desc' => 'Malagasy',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mi',
    'locale_desc' => 'Maori',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mk',
    'locale_desc' => 'Macedonian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ml',
    'locale_desc' => 'Malayalam',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mn',
    'locale_desc' => 'Mongolian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mo',
    'locale_desc' => 'Moldavian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mr',
    'locale_desc' => 'Marathi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ms',
    'locale_desc' => 'Malay',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'mt',
    'locale_desc' => 'Maltese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'na',
    'locale_desc' => 'Nauru',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ne',
    'locale_desc' => 'Nepali',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'nl',
    'locale_desc' => 'Dutch',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'no',
    'locale_desc' => 'Norwegian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'oc',
    'locale_desc' => 'Occitan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'om',
    'locale_desc' => 'Oromo',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'or',
    'locale_desc' => 'Oriya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pa',
    'locale_desc' => 'Punjabi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pl',
    'locale_desc' => 'Polish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'pt',
    'locale_desc' => 'Portuguese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'qu',
    'locale_desc' => 'Quechua',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rm',
    'locale_desc' => 'Romansh',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rn',
    'locale_desc' => 'Kirundi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ro',
    'locale_desc' => 'Romanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ru',
    'locale_desc' => 'Russian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'rw',
    'locale_desc' => 'Kinyarwanda',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sa',
    'locale_desc' => 'Sanskrit',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sd',
    'locale_desc' => 'Sindhi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sg',
    'locale_desc' => 'Sango',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sk',
    'locale_desc' => 'Slovak',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sl',
    'locale_desc' => 'Slovenian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sm',
    'locale_desc' => 'Samoan',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sn',
    'locale_desc' => 'Shona',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sq',
    'locale_desc' => 'Albanian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sr',
    'locale_desc' => 'Serbian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ss',
    'locale_desc' => 'Swati',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'st',
    'locale_desc' => 'Southern Sotho',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sv',
    'locale_desc' => 'Swedish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sw',
    'locale_desc' => 'Swahili',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'sz',
    'locale_desc' => 'Sami',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ta',
    'locale_desc' => 'Tamil',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'te',
    'locale_desc' => 'Telugu',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ti',
    'locale_desc' => 'Tigrinya',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tk',
    'locale_desc' => 'Turkmen',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tl',
    'locale_desc' => 'Tagalog',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tn',
    'locale_desc' => 'Tswana',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'to',
    'locale_desc' => 'Tonga',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tr',
    'locale_desc' => 'Turkish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ts',
    'locale_desc' => 'Tsonga',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tt',
    'locale_desc' => 'Tatar',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'tw',
    'locale_desc' => 'Twi',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ug',
    'locale_desc' => 'Uighur',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'uk',
    'locale_desc' => 'Ukrainian',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'ur',
    'locale_desc' => 'Urdu',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vi',
    'locale_desc' => 'Vietnamese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vi-US',
    'locale_desc' => 'Vietnamese, United States',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'vo',
    'locale_desc' => 'Volapük',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'xh',
    'locale_desc' => 'Xhosa',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'yi',
    'locale_desc' => 'Yiddish',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'yo',
    'locale_desc' => 'Yoruba',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'za',
    'locale_desc' => 'Zhuang',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zh',
    'locale_desc' => 'Chinese',
  ))
    ->execute();
  db_insert('globallink_locale')
    ->fields(array(
    'locale_code' => 'zu',
    'locale_desc' => 'Zulu',
  ))
    ->execute();
}

/**
 * Implements hook_update_N().
 *
 * Version 2.6.0 updates.
 */
function globallink_update_7260() {
  db_add_field('globallink_core', 'project_code', array(
    'description' => 'PD Project Code.',
    'type' => 'varchar',
    'not null' => TRUE,
    'default' => '',
    'length' => 255,
  ));
}

/**
 *
 */
function globallink_update_7310() {
  $schema['globallink_log'] = array(
    'description' => 'GlobalLink Logs Table',
    'fields' => array(
      'lid' => array(
        'description' => 'Unique Log ID',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'severity' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'Info',
        'description' => 'The severity level of the event.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Type of Content - Content, Blocks, Menus etc.',
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Text of log message.',
      ),
      'timestamp' => array(
        'description' => 'The timestamp',
        'type' => 'int',
        'length' => 14,
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'lid',
    ),
    'indexes' => array(
      'severity' => array(
        'severity',
      ),
    ),
  );
  db_create_table('globallink_log', $schema['globallink_log']);
}

/**
 * Upgrade from 7.x to 7.7
 */
function globallink_update_7710() {
  $schema['globallink_submission'] = array(
    'description' => 'GlobalLink Submission Table',
    'fields' => array(
      'rid' => array(
        'description' => 'The row id',
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => FALSE,
      ),
      'submission' => array(
        'description' => 'The submission name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'pd_submission_id' => array(
        'description' => 'The PD submission ID',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'submission_ticket' => array(
        'description' => 'The submission ticket',
        'type' => 'varchar',
        'length' => 45,
        'not null' => TRUE,
      ),
      'source_lang_code' => array(
        'description' => 'The source language code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => TRUE,
      ),
      'source_lang_name' => array(
        'description' => 'The source language name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'sub_target_lang_code' => array(
        'description' => 'The submission target language code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => TRUE,
      ),
      'sub_target_lang_name' => array(
        'description' => 'The submission target language name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'project_code' => array(
        'description' => 'The project code',
        'type' => 'varchar',
        'length' => 45,
        'not null' => TRUE,
      ),
      'project_name' => array(
        'description' => 'The project name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'status' => array(
        'description' => 'The status of submission',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'created' => array(
        'description' => 'The created date',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'updated' => array(
        'description' => 'The updated date',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'due_date' => array(
        'description' => 'The due date for the submission',
        'type' => 'varchar',
        'length' => 50,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
    ),
  );
  $schema['globallink_document'] = array(
    'description' => 'Globallink Document Table',
    'fields' => array(
      'rid' => array(
        'description' => 'The row id',
        'type' => 'serial',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'submission_rid' => array(
        'description' => 'The submission id as foreign key',
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
      ),
      'document_ticket' => array(
        'description' => 'The document ticket',
        'type' => 'varchar',
        'length' => 50,
        'not null' => FALSE,
        'default' => '',
      ),
      'entity_type' => array(
        'description' => 'The entity type',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'entity_type_name' => array(
        'description' => 'The entity type display name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_type' => array(
        'description' => 'the object type',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_type_name' => array(
        'description' => 'the object type display name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_id' => array(
        'description' => 'The object ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'object_parent_id' => array(
        'description' => 'The object parent ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_version_id' => array(
        'description' => 'The object version ID',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'object_title' => array(
        'description' => 'The object title',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_lang_code' => array(
        'description' => 'The target langauge code',
        'type' => 'varchar',
        'length' => 5,
        'not null' => FALSE,
      ),
      'target_status' => array(
        'description' => 'The target status',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_ticket' => array(
        'description' => 'The target ticket',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'target_last_sent' => array(
        'description' => 'Target was sent last',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
      'target_last_updated' => array(
        'description' => 'Target last updated',
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'indexes' => array(
      'submission_rid' => array(
        'submission_rid',
      ),
      'entity_type' => array(
        'entity_type',
      ),
      'target_status' => array(
        'target_status',
      ),
    ),
  );
  db_create_table('globallink_submission', $schema['globallink_submission']);
  db_create_table('globallink_document', $schema['globallink_document']);
  $delete_field_types = [
    'paragraphs',
    'entityreference',
    'list_integer',
    'list_text',
    'taxonomy_term_reference',
    'list_boolean',
    'boolean',
    'list_float',
  ];
  db_delete('globallink_field_config')
    ->condition('field_type', $delete_field_types, 'IN')
    ->execute();

  //Copy core data into submission and document
  _globallink_update_7710_update_database();

  //Updating the target language names to DB.
  $db_results = db_select('globallink_submission', 'gs')
    ->fields('gs', array(
    'sub_target_lang_code',
  ))
    ->distinct()
    ->execute()
    ->fetchAll();
  foreach ($db_results as $db_result) {
    $locale_codes = db_select('globallink_locale', 'gl')
      ->fields('gl', array(
      'drupal_locale_desc',
    ))
      ->condition('locale_code', $db_result->sub_target_lang_code, '=')
      ->execute();
    foreach ($locale_codes as $locale_code) {
      db_update('globallink_submission')
        ->fields(array(
        'sub_target_lang_name' => $locale_code->drupal_locale_desc,
      ))
        ->condition('sub_target_lang_code', $db_result->sub_target_lang_code, '=')
        ->execute();
    }
  }

  //Updating the source langauage name to DB.
  $source_lang_codes = db_select('globallink_submission', 'gs')
    ->fields('gs', array(
    'source_lang_code',
  ))
    ->distinct()
    ->execute()
    ->fetchAll();
  foreach ($source_lang_codes as $souce_lang_code) {
    $src_locales = db_select('globallink_locale', 'gl')
      ->fields('gl', array(
      'drupal_locale_desc',
    ))
      ->condition('locale_code', $souce_lang_code->source_lang_code, '=')
      ->execute();
    foreach ($src_locales as $src_locale) {
      db_update('globallink_submission')
        ->fields(array(
        'source_lang_name' => $src_locale->drupal_locale_desc,
      ))
        ->condition('source_lang_code', $souce_lang_code->source_lang_code, '=')
        ->execute();
    }
  }

  // Updating project names.
  module_load_include('inc', 'globallink', 'globallink_settings');
  module_load_include('inc', 'globallink', 'gl_ws/gl_ws_common');
  $pd4 = globallink_get_project_director_details();
  $projects = globallink_get_user_pdProjects($pd4);
  $project_codes = db_select('globallink_submission', 'gs')
    ->fields('gs', array(
    'project_code',
  ))
    ->distinct()
    ->execute();
  foreach ($project_codes as $project_code) {
    if (isset($projects[$project_code->project_code])) {
      $project_name = $projects[$project_code->project_code]->name;
      db_update('globallink_submission')
        ->fields(array(
        'project_name' => $project_name,
      ))
        ->condition('project_code', $project_code->project_code, '=')
        ->execute();
    }
  }
}

/**
 * Utility function for update 7710. Updates the new database tables.
 */
function _globallink_update_7710_update_database() {
  if (db_table_exists('globallink_core')) {
    _globallink_update_7710_update_core();
  }
  if (db_table_exists('globallink_core_entity')) {
    _globallink_update_7710_update_core_entity();
  }
  if (db_table_exists('globallink_core_beans')) {
    _globallink_update_7710_update_core_common('beans', 'Bean');
  }
  if (db_table_exists('globallink_core_fieldable_panels')) {
    _globallink_update_7710_update_core_fpp();
  }
  if (db_table_exists('globallink_core_interface')) {
    _globallink_update_7710_update_core_common('interface', 'Interface');
  }
  if (db_table_exists('globallink_core_menu')) {
    _globallink_update_7710_update_core_common('menu', 'Menu');
  }
  if (db_table_exists('globallink_core_webform')) {
    _globallink_update_7710_update_core_webform();
  }
  if (db_table_exists('globallink_core_block')) {
    _globallink_update_7710_update_core_common('block', 'Block');
  }
  if (db_table_exists('globallink_core_taxonomy')) {
    _globallink_update_7710_update_core_common('taxonomy', 'Taxonomy');
  }
  return;
}

/**
 * Utility functions for update 7710. 
 * Updates the submission and document tables - Active submissions.
 */
function _globallink_update_7710_update_core() {
  $core_subs = db_select('globallink_core', 'gc')
    ->fields('gc', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Sent for Translations', '=')
    ->execute();
  $num = $core_subs
    ->rowCount();
  if ($num != 0) {
    foreach ($core_subs as $core_sub) {
      db_insert('globallink_submission')
        ->fields(array(
        'submission' => $core_sub->submission,
        'submission_ticket' => $core_sub->submission_ticket,
        'sub_target_lang_code' => $core_sub->target,
        'source_lang_code' => $core_sub->source,
        'project_code' => $core_sub->project_code,
        'status' => 'Sent for Translations',
        'created' => REQUEST_TIME,
        'updated' => REQUEST_TIME,
      ))
        ->execute();
      $sub_rids = db_select('globallink_submission', 'gs')
        ->fields('gs', array(
        'rid',
      ))
        ->condition('submission', $core_sub->submission, '=')
        ->condition('submission_ticket', $core_sub->submission_ticket, '=')
        ->condition('sub_target_lang_code', $core_sub->target, '=')
        ->condition('source_lang_code', $core_sub->source, '=')
        ->condition('project_code', $core_sub->project_code, '=')
        ->execute();
      foreach ($sub_rids as $sub_rid) {
        $rid = $sub_rid->rid;
      }
      $core_docs = db_select('globallink_core', 'gc')
        ->fields('gc', array(
        'nid',
        'vid',
        'type',
        'title',
        'target',
        'document_ticket',
        'status',
      ))
        ->condition('target', $core_sub->target, '=')
        ->condition('source', $core_sub->source, '=')
        ->condition('submission', $core_sub->submission, '=')
        ->condition('submission_ticket', $core_sub->submission_ticket, '=')
        ->execute();
      foreach ($core_docs as $core_doc) {
        $status = $core_doc->status;
        if ($status == 'Pending Translations') {
          $status = 'Translation Imported';
        }
        db_insert('globallink_document')
          ->fields(array(
          'submission_rid' => $rid,
          'document_ticket' => $core_doc->document_ticket,
          'entity_type' => 'node',
          'entity_type_name' => 'Node',
          'object_type' => $core_doc->type,
          'object_id' => $core_doc->nid,
          'object_parent_id' => $core_doc->nid,
          'object_version_id' => $core_doc->vid,
          'object_title' => $core_doc->title,
          'target_lang_code' => $core_doc->target,
          'target_status' => $status,
          'target_last_sent' => REQUEST_TIME,
          'target_last_updated' => REQUEST_TIME,
        ))
          ->execute();
      }
    }
  }
  $other_subs = db_select('globallink_core', 'gc')
    ->fields('gc', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Error', '=')
    ->execute();
  $num = $other_subs
    ->rowCount();
  if ($num != 0) {
    foreach ($other_subs as $other_sub) {
      $results = db_select('globallink_submission', 'gs')
        ->fields('gs')
        ->condition('submission_ticket', $other_sub->submission_ticket, '=')
        ->condition('source_lang_code', $other_sub->source, '=')
        ->condition('sub_target_lang_code', $other_sub->target, '=')
        ->condition('submission', $other_sub->submission, '=')
        ->condition('project_code', $other_sub->project_code, '=')
        ->execute();
      $number_of_rows = $results
        ->rowCount();
      if ($number_of_rows > 0) {
        continue;
      }
      else {
        db_insert('globallink_submission')
          ->fields(array(
          'submission' => $other_sub->submission,
          'submission_ticket' => $other_sub->submission_ticket,
          'sub_target_lang_code' => $other_sub->target,
          'source_lang_code' => $other_sub->source,
          'project_code' => $other_sub->project_code,
          'status' => 'Error',
          'created' => REQUEST_TIME,
          'updated' => REQUEST_TIME,
        ))
          ->execute();
        $other_rids = db_select('globallink_submission', 'gs')
          ->fields('gs', array(
          'rid',
        ))
          ->condition('submission', $other_sub->submission, '=')
          ->condition('submission_ticket', $other_sub->submission_ticket, '=')
          ->condition('sub_target_lang_code', $other_sub->target, '=')
          ->condition('source_lang_code', $other_sub->source, '=')
          ->condition('project_code', $other_sub->project_code, '=')
          ->execute();
        foreach ($other_rids as $other_rid) {
          $o_rid = $other_rid->rid;
        }
        $other_core_docs = db_select('globallink_core', 'gc')
          ->fields('gc', array(
          'nid',
          'vid',
          'type',
          'title',
          'target',
          'document_ticket',
          'status',
        ))
          ->condition('target', $other_sub->target, '=')
          ->condition('source', $other_sub->source, '=')
          ->condition('submission', $other_sub->submission, '=')
          ->condition('submission_ticket', $other_sub->submission_ticket, '=')
          ->execute();
        foreach ($other_core_docs as $other_core_doc) {
          $status = $other_core_doc->status;
          if ($status == 'Pending Translations') {
            $status = 'Translation Imported';
          }
          db_insert('globallink_document')
            ->fields(array(
            'submission_rid' => $o_rid,
            'document_ticket' => $other_core_doc->document_ticket,
            'entity_type' => 'node',
            'entity_type_name' => 'Node',
            'object_type' => $other_core_doc->type,
            'object_id' => $other_core_doc->nid,
            'object_parent_id' => $other_core_doc->nid,
            'object_version_id' => $other_core_doc->vid,
            'object_title' => $other_core_doc->title,
            'target_lang_code' => $other_core_doc->target,
            'target_status' => $status,
            'target_last_sent' => REQUEST_TIME,
            'target_last_updated' => REQUEST_TIME,
          ))
            ->execute();
        }
      }
    }
  }
}
function _globallink_update_7710_update_core_entity() {
  $ent_subs = db_select('globallink_core_entity', 'ge')
    ->fields('ge', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Sent for Translations', '=')
    ->execute();
  $num = $ent_subs
    ->rowCount();
  if ($num != 0) {
    foreach ($ent_subs as $ent_sub) {
      db_insert('globallink_submission')
        ->fields(array(
        'submission' => $ent_sub->submission,
        'submission_ticket' => $ent_sub->submission_ticket,
        'sub_target_lang_code' => $ent_sub->target,
        'source_lang_code' => $ent_sub->source,
        'project_code' => $ent_sub->project_code,
        'status' => 'Sent for Translations',
        'created' => REQUEST_TIME,
        'updated' => REQUEST_TIME,
      ))
        ->execute();
      $sub_rids = db_select('globallink_submission', 'gs')
        ->fields('gs', array(
        'rid',
      ))
        ->condition('submission', $ent_sub->submission, '=')
        ->condition('submission_ticket', $ent_sub->submission_ticket, '=')
        ->condition('sub_target_lang_code', $ent_sub->target, '=')
        ->condition('source_lang_code', $ent_sub->source, '=')
        ->condition('project_code', $ent_sub->project_code, '=')
        ->execute();
      foreach ($sub_rids as $sub_rid) {
        $rid = $sub_rid->rid;
      }
      $ent_docs = db_select('globallink_core_entity', 'ge')
        ->fields('ge', array(
        'nid',
        'vid',
        'type',
        'title',
        'target',
        'document_ticket',
        'status',
      ))
        ->condition('target', $ent_sub->target, '=')
        ->condition('source', $ent_sub->source, '=')
        ->condition('submission', $ent_sub->submission, '=')
        ->condition('submission_ticket', $ent_sub->submission_ticket, '=')
        ->execute();
      foreach ($ent_docs as $ent_doc) {
        $status = $ent_doc->status;
        if ($status == 'Pending Translations') {
          $status = 'Translation Imported';
        }
        db_insert('globallink_document')
          ->fields(array(
          'submission_rid' => $rid,
          'document_ticket' => $ent_doc->document_ticket,
          'entity_type' => 'entity',
          'entity_type_name' => 'Entity',
          'object_type' => $ent_doc->type,
          'object_id' => $ent_doc->nid,
          'object_parent_id' => $ent_doc->nid,
          'object_version_id' => $ent_doc->vid,
          'object_title' => $ent_doc->title,
          'target_lang_code' => $ent_doc->target,
          'target_status' => $status,
          'target_last_sent' => REQUEST_TIME,
          'target_last_updated' => REQUEST_TIME,
        ))
          ->execute();
      }
    }
  }

  //Error submissions
  $other_ents = db_select('globallink_core_entity', 'ge')
    ->fields('ge', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Error', '=')
    ->execute();
  $num_rows = $other_ents
    ->rowCount();
  if ($num_rows != 0) {
    foreach ($other_ents as $other_ent) {
      $result_ents = db_select('globallink_submission', 'gs')
        ->fields('gs')
        ->condition('submission_ticket', $other_ent->submission_ticket, '=')
        ->condition('source_lang_code', $other_ent->source, '=')
        ->condition('sub_target_lang_code', $other_ent->target, '=')
        ->condition('submission', $other_ent->submission, '=')
        ->condition('project_code', $other_ent->project_code, '=')
        ->execute();
      $number_of_rows = $result_ents
        ->rowCount();
      if ($number_of_rows > 0) {
        continue;
      }
      else {
        db_insert('globallink_submission')
          ->fields(array(
          'submission' => $other_ent->submission,
          'submission_ticket' => $other_ent->submission_ticket,
          'sub_target_lang_code' => $other_ent->target,
          'source_lang_code' => $other_ent->source,
          'project_code' => $other_ent->project_code,
          'status' => 'Error',
          'created' => REQUEST_TIME,
          'updated' => REQUEST_TIME,
        ))
          ->execute();
        $entity_rids = db_select('globallink_submission', 'gs')
          ->fields('gs', array(
          'rid',
        ))
          ->condition('submission', $other_ent->submission, '=')
          ->condition('submission_ticket', $other_ent->submission_ticket, '=')
          ->condition('sub_target_lang_code', $other_ent->target, '=')
          ->condition('source_lang_code', $other_ent->source, '=')
          ->condition('project_code', $other_ent->project_code, '=')
          ->execute();
        foreach ($entity_rids as $entity_rid) {
          $e_rid = $entity_rid->rid;
        }
        $other_entity_docs = db_select('globallink_core_entity', 'ge')
          ->fields('ge', array(
          'nid',
          'vid',
          'type',
          'title',
          'target',
          'document_ticket',
          'status',
        ))
          ->condition('target', $other_ent->target, '=')
          ->condition('source', $other_ent->source, '=')
          ->condition('submission', $other_ent->submission, '=')
          ->condition('submission_ticket', $other_ent->submission_ticket, '=')
          ->execute();
        foreach ($other_entity_docs as $other_entity_doc) {
          $status = $other_entity_doc->status;
          if ($status == 'Pending Translations') {
            $status = 'Translation Imported';
          }
          db_insert('globallink_document')
            ->fields(array(
            'submission_rid' => $e_rid,
            'document_ticket' => $other_entity_doc->document_ticket,
            'entity_type' => 'entity',
            'entity_type_name' => 'Entity',
            'object_type' => $other_entity_doc->type,
            'object_id' => $other_entity_doc->nid,
            'object_parent_id' => $other_entity_doc->nid,
            'object_version_id' => $other_entity_doc->vid,
            'object_title' => $other_entity_doc->title,
            'target_lang_code' => $other_entity_doc->target,
            'target_status' => $status,
            'target_last_sent' => REQUEST_TIME,
            'target_last_updated' => REQUEST_TIME,
          ))
            ->execute();
        }
      }
    }
  }
}
function _globallink_update_7710_update_core_fpp() {
  $fpp_subs = db_select('globallink_core_fieldable_panels', 'gf')
    ->fields('gf', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Sent for Translations', '=')
    ->execute();
  $num = $fpp_subs
    ->rowCount();
  if ($num > 0) {
    foreach ($fpp_subs as $fpp_sub) {
      db_insert('globallink_submission')
        ->fields(array(
        'submission' => $fpp_sub->submission,
        'submission_ticket' => $fpp_sub->submission_ticket,
        'sub_target_lang_code' => $fpp_sub->target,
        'source_lang_code' => $fpp_sub->source,
        'project_code' => $fpp_sub->project_code,
        'status' => 'Sent for Translations',
        'created' => REQUEST_TIME,
        'updated' => REQUEST_TIME,
      ))
        ->execute();
      $sub_rids = db_select('globallink_submission', 'gs')
        ->fields('gs', array(
        'rid',
      ))
        ->condition('submission', $fpp_sub->submission, '=')
        ->condition('submission_ticket', $fpp_sub->submission_ticket, '=')
        ->condition('sub_target_lang_code', $fpp_sub->target, '=')
        ->condition('source_lang_code', $fpp_sub->source, '=')
        ->condition('project_code', $fpp_sub->project_code, '=')
        ->execute();
      foreach ($sub_rids as $sub_rid) {
        $rid = $sub_rid->rid;
      }
      $fpp_docs = db_select('globallink_core_fieldable_panels', 'gf')
        ->fields('gf', array(
        'fpid',
        'title',
        'target',
        'document_ticket',
        'status',
      ))
        ->condition('target', $fpp_sub->target, '=')
        ->condition('source', $fpp_sub->source, '=')
        ->condition('submission', $fpp_sub->submission, '=')
        ->condition('submission_ticket', $fpp_sub->submission_ticket, '=')
        ->execute();
      foreach ($fpp_docs as $fpp_doc) {
        $status = $fpp_doc->status;
        if ($status == 'Pending Translations') {
          $status = 'Translation Imported';
        }
        db_insert('globallink_document')
          ->fields(array(
          'submission_rid' => $rid,
          'document_ticket' => $fpp_doc->document_ticket,
          'entity_type' => 'fieldable_panels_panes',
          'entity_type_name' => 'Fieldable Panels Panes',
          'object_type' => 'fieldable_panels_panes',
          'object_id' => $fpp_doc->fpid,
          'object_parent_id' => $fpp_doc->fpid,
          'object_title' => $fpp_doc->title,
          'target_lang_code' => $fpp_doc->target,
          'target_status' => $status,
          'target_last_sent' => REQUEST_TIME,
          'target_last_updated' => REQUEST_TIME,
        ))
          ->execute();
      }
    }
  }

  //Error submissions
  $other_fpps = db_select('globallink_core_fieldable_panels', 'gf')
    ->fields('gf', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Error', '=')
    ->execute();
  $num_rows = $other_fpps
    ->rowCount();
  if ($num_rows != 0) {
    foreach ($other_fpps as $other_fpp) {
      $result_fpps = db_select('globallink_submission', 'gs')
        ->fields('gs')
        ->condition('submission_ticket', $other_fpp->submission_ticket, '=')
        ->condition('source_lang_code', $other_fpp->source, '=')
        ->condition('sub_target_lang_code', $other_fpp->target, '=')
        ->condition('submission', $other_fpp->submission, '=')
        ->condition('project_code', $other_fpp->project_code, '=')
        ->execute();
      $number_of_rows = $result_fpps
        ->rowCount();
      if ($number_of_rows > 0) {
        continue;
      }
      else {
        db_insert('globallink_submission')
          ->fields(array(
          'submission' => $other_fpp->submission,
          'submission_ticket' => $other_fpp->submission_ticket,
          'sub_target_lang_code' => $other_fpp->target,
          'source_lang_code' => $other_fpp->source,
          'project_code' => $other_fpp->project_code,
          'status' => 'Error',
          'created' => REQUEST_TIME,
          'updated' => REQUEST_TIME,
        ))
          ->execute();
        $fpp_rids = db_select('globallink_submission', 'gs')
          ->fields('gs', array(
          'rid',
        ))
          ->condition('submission', $other_fpp->submission, '=')
          ->condition('submission_ticket', $other_fpp->submission_ticket, '=')
          ->condition('sub_target_lang_code', $other_fpp->target, '=')
          ->condition('source_lang_code', $other_fpp->source, '=')
          ->condition('project_code', $other_fpp->project_code, '=')
          ->execute();
        foreach ($fpp_rids as $fpp_rid) {
          $fp_rid = $fpp_rid->rid;
        }
        $other_fpp_docs = db_select('globallink_core_fieldable_panels', 'gf')
          ->fields('gf', array(
          'fpid',
          'title',
          'target',
          'document_ticket',
          'status',
        ))
          ->condition('target', $other_fpp->target, '=')
          ->condition('source', $other_fpp->source, '=')
          ->condition('submission', $other_fpp->submission, '=')
          ->condition('submission_ticket', $other_fpp->submission_ticket, '=')
          ->execute();
        foreach ($other_fpp_docs as $other_fpp_doc) {
          $status = $other_fpp_doc->status;
          if ($status == 'Pending Translations') {
            $status = 'Translation Imported';
          }
          db_insert('globallink_document')
            ->fields(array(
            'submission_rid' => $fp_rid,
            'document_ticket' => $other_fpp_doc->document_ticket,
            'entity_type' => 'fieldable_panels_panes',
            'entity_type_name' => 'Fieldable Panels Panes',
            'object_type' => 'fieldable_panels_panes',
            'object_id' => $other_fpp_doc->fpid,
            'object_parent_id' => $other_fpp_doc->fpid,
            'object_title' => $other_fpp_doc->title,
            'target_lang_code' => $other_fpp_doc->target,
            'target_status' => $status,
            'target_last_sent' => REQUEST_TIME,
            'target_last_updated' => REQUEST_TIME,
          ))
            ->execute();
        }
      }
    }
  }
}
function _globallink_update_7710_update_core_common($entity, $entity_type) {
  $table = 'globallink_core_' . $entity;
  if ($entity == 'beans' && $entity_type == 'Bean') {
    $entity = 'bean';
  }
  $int_subs = db_select($table, 'gi')
    ->fields('gi', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Sent for Translations', '=')
    ->execute();
  $num = $int_subs
    ->rowCount();
  if ($num > 0) {
    foreach ($int_subs as $int_sub) {
      db_insert('globallink_submission')
        ->fields(array(
        'submission' => $int_sub->submission,
        'submission_ticket' => $int_sub->submission_ticket,
        'sub_target_lang_code' => $int_sub->target,
        'source_lang_code' => $int_sub->source,
        'project_code' => $int_sub->project_code,
        'status' => 'Sent for Translations',
        'created' => REQUEST_TIME,
        'updated' => REQUEST_TIME,
      ))
        ->execute();
      $sub_rids = db_select('globallink_submission', 'gs')
        ->fields('gs', array(
        'rid',
      ))
        ->condition('submission', $int_sub->submission, '=')
        ->condition('submission_ticket', $int_sub->submission_ticket, '=')
        ->condition('sub_target_lang_code', $int_sub->target, '=')
        ->condition('source_lang_code', $int_sub->source, '=')
        ->condition('project_code', $int_sub->project_code, '=')
        ->execute();
      foreach ($sub_rids as $sub_rid) {
        $rid = $sub_rid->rid;
      }
      $int_docs = db_select($table, 'gi')
        ->fields('gi', array(
        'object_id',
        'title',
        'target',
        'document_ticket',
        'status',
      ))
        ->condition('target', $int_sub->target, '=')
        ->condition('source', $int_sub->source, '=')
        ->condition('submission', $int_sub->submission, '=')
        ->condition('submission_ticket', $int_sub->submission_ticket, '=')
        ->execute();
      foreach ($int_docs as $int_doc) {
        $status = $int_doc->status;
        if ($status == 'Pending Translations') {
          $status = 'Translation Imported';
        }
        db_insert('globallink_document')
          ->fields(array(
          'submission_rid' => $rid,
          'document_ticket' => $int_doc->document_ticket,
          'entity_type' => $entity,
          'entity_type_name' => $entity_type,
          'object_type' => $entity,
          'object_id' => $int_doc->object_id,
          'object_parent_id' => $int_doc->object_id,
          'object_title' => $int_doc->title,
          'target_lang_code' => $int_doc->target,
          'target_status' => $status,
          'target_last_sent' => REQUEST_TIME,
          'target_last_updated' => REQUEST_TIME,
        ))
          ->execute();
      }
    }
  }

  //Error
  $other_ints = db_select($table, 'gi')
    ->fields('gi', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Error', '=')
    ->execute();
  $num_rows = $other_ints
    ->rowCount();
  if ($num_rows != 0) {
    foreach ($other_ints as $other_int) {
      $result_ints = db_select('globallink_submission', 'gs')
        ->fields('gs')
        ->condition('submission_ticket', $other_int->submission_ticket, '=')
        ->condition('source_lang_code', $other_int->source, '=')
        ->condition('sub_target_lang_code', $other_int->target, '=')
        ->condition('submission', $other_int->submission, '=')
        ->condition('project_code', $other_int->project_code, '=')
        ->execute();
      $number_of_rows = $result_ints
        ->rowCount();
      if ($number_of_rows > 0) {
        continue;
      }
      else {
        db_insert('globallink_submission')
          ->fields(array(
          'submission' => $other_int->submission,
          'submission_ticket' => $other_int->submission_ticket,
          'sub_target_lang_code' => $other_int->target,
          'source_lang_code' => $other_int->source,
          'project_code' => $other_int->project_code,
          'status' => 'Error',
          'created' => REQUEST_TIME,
          'updated' => REQUEST_TIME,
        ))
          ->execute();
        $int_rids = db_select('globallink_submission', 'gs')
          ->fields('gs', array(
          'rid',
        ))
          ->condition('submission', $other_int->submission, '=')
          ->condition('submission_ticket', $other_int->submission_ticket, '=')
          ->condition('sub_target_lang_code', $other_int->target, '=')
          ->condition('source_lang_code', $other_int->source, '=')
          ->condition('project_code', $other_int->project_code, '=')
          ->execute();
        foreach ($int_rids as $int_rid) {
          $int_rid = $int_rid->rid;
        }
        $other_int_docs = db_select($table, 'gi')
          ->fields('gi', array(
          'object_id',
          'title',
          'target',
          'document_ticket',
          'status',
        ))
          ->condition('target', $other_int->target, '=')
          ->condition('source', $other_int->source, '=')
          ->condition('submission', $other_int->submission, '=')
          ->condition('submission_ticket', $other_int->submission_ticket, '=')
          ->execute();
        foreach ($other_int_docs as $other_int_doc) {
          $status = $other_int_doc->status;
          if ($status == 'Pending Translations') {
            $status = 'Translation Imported';
          }
          db_insert('globallink_document')
            ->fields(array(
            'submission_rid' => $int_rid,
            'document_ticket' => $other_int_doc->document_ticket,
            'entity_type' => $entity,
            'entity_type_name' => $entity_type,
            'object_type' => $entity,
            'object_id' => $other_int_doc->object_id,
            'object_parent_id' => $other_int_doc->object_id,
            'object_title' => $other_int_doc->title,
            'target_lang_code' => $other_int_doc->target,
            'target_status' => $status,
            'target_last_sent' => REQUEST_TIME,
            'target_last_updated' => REQUEST_TIME,
          ))
            ->execute();
        }
      }
    }
  }
}
function _globallink_update_7710_update_core_webform() {
  $web_subs = db_select('globallink_core_webform', 'gw')
    ->fields('gw', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Sent for Translations', '=')
    ->execute();
  $num = $web_subs
    ->rowCount();
  if ($num > 0) {
    foreach ($web_subs as $web_sub) {
      db_insert('globallink_submission')
        ->fields(array(
        'submission' => $web_sub->submission,
        'submission_ticket' => $web_sub->submission_ticket,
        'sub_target_lang_code' => $web_sub->target,
        'source_lang_code' => $web_sub->source,
        'project_code' => $web_sub->project_code,
        'status' => 'Sent for Translations',
        'created' => REQUEST_TIME,
        'updated' => REQUEST_TIME,
      ))
        ->execute();
      $sub_rids = db_select('globallink_submission', 'gs')
        ->fields('gs', array(
        'rid',
      ))
        ->condition('submission', $web_sub->submission, '=')
        ->condition('submission_ticket', $web_sub->submission_ticket, '=')
        ->condition('sub_target_lang_code', $web_sub->target, '=')
        ->condition('source_lang_code', $web_sub->source, '=')
        ->condition('project_code', $web_sub->project_code, '=')
        ->execute();
      foreach ($sub_rids as $sub_rid) {
        $rid = $sub_rid->rid;
      }
      $web_docs = db_select('globallink_core_webform', 'gw')
        ->fields('gw', array(
        'parent_id',
        'object_id',
        'title',
        'target',
        'document_ticket',
        'status',
      ))
        ->condition('target', $web_sub->target, '=')
        ->condition('source', $web_sub->source, '=')
        ->condition('submission', $web_sub->submission, '=')
        ->condition('submission_ticket', $web_sub->submission_ticket, '=')
        ->execute();
      foreach ($web_docs as $web_doc) {
        $status = $web_doc->status;
        if ($status == 'Pending Translations') {
          $status = 'Translation Imported';
        }
        db_insert('globallink_document')
          ->fields(array(
          'submission_rid' => $rid,
          'document_ticket' => $web_doc->document_ticket,
          'entity_type' => 'webform',
          'entity_type_name' => 'Webform',
          'object_type' => 'webform',
          'object_id' => $web_doc->object_id,
          'object_parent_id' => $web_doc->parent_id,
          'object_title' => $web_doc->title,
          'target_lang_code' => $web_doc->target,
          'target_status' => $status,
          'target_last_sent' => REQUEST_TIME,
          'target_last_updated' => REQUEST_TIME,
        ))
          ->execute();
      }
    }
  }

  //Error
  $other_ints = db_select('globallink_core_webform', 'gw')
    ->fields('gw', array(
    'source',
    'target',
    'submission',
    'submission_ticket',
    'project_code',
  ))
    ->distinct()
    ->condition('status', 'Error', '=')
    ->execute();
  $num_rows = $other_ints
    ->rowCount();
  if ($num_rows != 0) {
    foreach ($other_ints as $other_int) {
      $result_ints = db_select('globallink_submission', 'gs')
        ->fields('gs')
        ->condition('submission_ticket', $other_int->submission_ticket, '=')
        ->condition('source_lang_code', $other_int->source, '=')
        ->condition('sub_target_lang_code', $other_int->target, '=')
        ->condition('submission', $other_int->submission, '=')
        ->condition('project_code', $other_int->project_code, '=')
        ->execute();
      $number_of_rows = $result_ints
        ->rowCount();
      if ($number_of_rows > 0) {
        continue;
      }
      else {
        db_insert('globallink_submission')
          ->fields(array(
          'submission' => $other_int->submission,
          'submission_ticket' => $other_int->submission_ticket,
          'sub_target_lang_code' => $other_int->target,
          'source_lang_code' => $other_int->source,
          'project_code' => $other_int->project_code,
          'status' => 'Error',
          'created' => REQUEST_TIME,
          'updated' => REQUEST_TIME,
        ))
          ->execute();
        $int_rids = db_select('globallink_submission', 'gs')
          ->fields('gs', array(
          'rid',
        ))
          ->condition('submission', $other_int->submission, '=')
          ->condition('submission_ticket', $other_int->submission_ticket, '=')
          ->condition('sub_target_lang_code', $other_int->target, '=')
          ->condition('source_lang_code', $other_int->source, '=')
          ->condition('project_code', $other_int->project_code, '=')
          ->execute();
        foreach ($int_rids as $int_rid) {
          $int_rid = $int_rid->rid;
        }
        $other_int_docs = db_select('globallink_core_webform', 'gw')
          ->fields('gw', array(
          'parent_id',
          'object_id',
          'title',
          'target',
          'document_ticket',
          'status',
        ))
          ->condition('target', $other_int->target, '=')
          ->condition('source', $other_int->source, '=')
          ->condition('submission', $other_int->submission, '=')
          ->condition('submission_ticket', $other_int->submission_ticket, '=')
          ->execute();
        foreach ($other_int_docs as $other_int_doc) {
          $status = $other_int_doc->status;
          if ($status == 'Pending Translations') {
            $status = 'Translation Imported';
          }
          db_insert('globallink_document')
            ->fields(array(
            'submission_rid' => $int_rid,
            'document_ticket' => $other_int_doc->document_ticket,
            'entity_type' => 'webform',
            'entity_type_name' => 'Webform',
            'object_type' => 'webform',
            'object_id' => $other_int_doc->object_id,
            'object_parent_id' => $other_int_doc->parent_id,
            'object_title' => $other_int_doc->title,
            'target_lang_code' => $other_int_doc->target,
            'target_status' => $status,
            'target_last_sent' => REQUEST_TIME,
            'target_last_updated' => REQUEST_TIME,
          ))
            ->execute();
        }
      }
    }
  }
}