123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 |
- <?php
- /**
- * @file
- * Installation hooks for the Translation Management module.
- */
- /**
- * Implements hook_uninstall().
- */
- function tmgmt_uninstall() {
- // Remove all variables that we added.
- variable_del('tmgmt_quick_checkout');
- variable_del('tmgmt_purge_finished');
- }
- /**
- * Implements hook_schema().
- */
- function tmgmt_schema() {
- $schema['tmgmt_job'] = array(
- 'description' => 'A translation job represents a translation order that can be assigned to a translator.',
- 'fields' => array(
- 'tjid' => array(
- 'description' => 'The identifier of the translation job.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'source_language' => array(
- 'description' => 'The source language of the data.',
- 'type' => 'varchar',
- 'length' => 12,
- 'not null' => TRUE,
- ),
- 'target_language' => array(
- 'description' => 'The language the data should be translated to.',
- 'type' => 'varchar',
- 'length' => 12,
- 'not null' => TRUE,
- ),
- 'state' => array(
- 'description' => 'The state of the translation job.',
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'created' => array(
- 'description' => 'Created timestamp.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'changed' => array(
- 'description' => 'Changed timestamp.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'translator' => array(
- 'description' => 'Machine name of the translator.',
- 'type' => 'varchar',
- 'length' => 128,
- ),
- 'settings' => array(
- 'description' => 'Translator specific configuration and context for this job.',
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- 'reference' => array(
- 'description' => 'Remote identifier of this translation job.',
- 'type' => 'varchar',
- 'length' => 255,
- ),
- 'uid' => array(
- 'description' => 'uid of the job creator',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'label' => array(
- 'description' => 'Optional user provided label of the job.',
- 'type' => 'varchar',
- 'length' => 255,
- ),
- ),
- 'primary key' => array('tjid'),
- 'indexes' => array(
- 'state' => array('state'),
- 'reference' => array('reference'),
- ),
- );
- $schema['tmgmt_remote'] = array(
- 'description' => 'TMGMT job remote mapping.',
- 'fields' => array(
- 'trid' => array(
- 'description' => 'The primary key.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'tjid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => '{tmgmt_job}.tjid foreign key',
- ),
- 'tjiid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => '{tmgmt_job_item}.tjjid foreign key',
- ),
- 'data_item_key' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Translation job data item key.',
- ),
- 'remote_identifier_1' => array(
- 'type' => 'varchar',
- 'length' => 127,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_identifier_2' => array(
- 'type' => 'varchar',
- 'length' => 127,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_identifier_3' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_url' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Remote job url.',
- ),
- 'word_count' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Word count info provided by the remote service.',
- ),
- 'amount' => array(
- 'type' => 'int',
- 'size' => 'big',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Amount charged for the remote translation job.',
- ),
- 'currency' => array(
- 'type' => 'char',
- 'length' => 3,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Amount charged currency.',
- ),
- 'remote_data' => array(
- 'description' => 'Custom remote data.',
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- ),
- 'primary key' => array('trid'),
- 'indexes' => array(
- 'tjid' => array('tjid'),
- 'tjiid' => array('tjiid'),
- 'remote_identifiers' => array('remote_identifier_1', 'remote_identifier_2'),
- ),
- );
- $schema['tmgmt_job_item'] = array(
- 'description' => 'A job item connects a source to a translation job.',
- 'fields' => array(
- 'tjiid' => array(
- 'description' => 'The identifier of the translation job item.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'tjid' => array(
- 'description' => 'The identifier of the translation job.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'unsigned' => TRUE,
- ),
- 'plugin' => array(
- 'description' => 'Indicates the plugin which provides this item.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- ),
- 'item_type' => array(
- 'description' => 'The type of the item, e.g. the entity type.',
- 'type' => 'varchar',
- 'length' => 128,
- ),
- 'item_id' => array(
- 'description' => 'The unique id (within the given item type) of the item.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- ),
- 'state' => array(
- 'description' => 'The state of the translation job item.',
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'data' => array(
- 'description' => 'Can be used by the source plugin to store the data if it can not be retrieved anymore later on.',
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- 'changed' => array(
- 'description' => 'Changed timestamp.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'count_pending' => array(
- 'description' => 'Counter for all pending data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'count_translated' => array(
- 'description' => 'Counter for all translated data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'count_accepted' => array(
- 'description' => 'Counter for all accepted data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'count_reviewed' => array(
- 'description' => 'Counter for all reviewed data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'word_count' => array(
- 'description' => 'Word count of all texts contained in this job item.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- ),
- 'primary key' => array('tjiid'),
- 'indexes' => array(
- 'job_id' => array('tjid'),
- ),
- 'foreign keys' => array(
- 'job' => array(
- 'table' => 'tmgmt_job',
- 'columns' => array('tjid'),
- ),
- ),
- );
- $schema['tmgmt_translator'] = array(
- 'description' => 'A translator is a combination of a translator type and type specific configuration.',
- 'fields' => array(
- 'tid' => array(
- 'description' => 'The identifier of the translator.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'name' => array(
- 'description' => 'Machine name identifier of the translator.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- ),
- 'label' => array(
- 'description' => 'Label of the translator.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- ),
- 'description' => array(
- 'description' => 'Description of the translator.',
- 'type' => 'text',
- 'size' => 'medium',
- ),
- 'plugin' => array(
- 'description' => 'Name of the translator service plugin.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- ),
- 'settings' => array(
- 'description' => 'Translator specific settings.',
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- 'weight' => array(
- 'description' => 'The weight of the translator.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'status' => array(
- 'description' => 'The exportable status of the entity.',
- 'type' => 'int',
- 'not null' => TRUE,
- // Set the default to ENTITY_CUSTOM without using the constant as it is
- // not safe to use it at this point.
- 'default' => 0x01,
- 'size' => 'tiny',
- ),
- 'module' => array(
- 'description' => 'The name of the providing module if the entity has been defined in code.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- ),
- ),
- 'primary key' => array('tid'),
- 'unique keys' => array(
- 'name' => array('name'),
- ),
- );
- $schema['tmgmt_message'] = array(
- 'description' => 'A log message can be used to store events that affect a job.',
- 'fields' => array(
- 'mid' => array(
- 'description' => 'The identifier of the message.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'tjid' => array(
- 'description' => 'The identifier of the translation job that the message belongs to.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'tjiid' => array(
- 'description' => 'The identifier of the translation job item that the message belongs to.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- ),
- 'uid' => array(
- 'description' => 'The identifier of the user who performed the action.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'default' => 0,
- ),
- 'message' => array(
- 'description' => 'The language into the data should be translated.',
- 'type' => 'text',
- 'size' => 'big',
- ),
- 'variables' => array(
- 'description' => 'The variables of the message as expected by t().',
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- 'created' => array(
- 'description' => 'Created timestamp.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'type' => array(
- 'description' => 'Type of the message (debug, notice, warning or error)',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('mid'),
- 'indexes' => array(
- 'tjid' => array('tjid'),
- 'tjiid' => array('tjiid'),
- ),
- );
- // Clone the schema for our cache table from Drupal core.
- $schema['cache_tmgmt'] = drupal_get_schema_unprocessed('system', 'cache');
- // Clone the schema for the entity cache module if it is enabled.
- if (module_exists('entitycache')) {
- $schema['cache_entity_tmgmt_translator'] = drupal_get_schema_unprocessed('system', 'cache');
- }
- return $schema;
- }
- /**
- * Merge the content of the 'translation' field into the 'data' field.
- */
- function tmgmt_update_7000(&$sandbox) {
- if (!isset($sandbox['progress'])) {
- $sandbox['progress'] = 0;
- $sandbox['max'] = db_query('SELECT COUNT(*) FROM {tmgmt_job_item}')->fetchField();
- }
- $results = db_select('tmgmt_job_item', 'tji')
- ->fields('tji', array('tjiid', 'data', 'translation'))
- ->range($sandbox['progress'], 50)
- ->orderBy('tjiid', 'ASC')
- ->execute();
- foreach ($results as $item) {
- $data = unserialize($item->data);
- if (!empty($item->translation)) {
- foreach (tmgmt_flatten_data(unserialize($item->translation)) as $key => $translation) {
- if (!empty($item->data)) {
- $key = explode('][', $key);
- drupal_array_set_nested_value($data, array_merge($key, array('#translation')), $translation);
- }
- }
- db_update('tmgmt_job_item')
- ->condition('tjiid', $item->tjiid)
- ->fields(array('data' => serialize($data)))
- ->execute();
- }
- $sandbox['progress']++;
- }
- $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
- }
- /**
- * Remove the 'translation' field from the job item entity.
- */
- function tmgmt_update_7001() {
- db_drop_field('tmgmt_job_item', 'translation');
- }
- /**
- * Add counter columns to {tmgmt_job_item}.
- */
- function tmgmt_update_7002() {
- // Defining schema of additional fields.
- $schema = array(
- 'count_pending' => array(
- 'description' => 'Counter for all pending data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'count_translated' => array(
- 'description' => 'Counter for all translated data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'count_approved' => array(
- 'description' => 'Counter for all approved data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- );
- // Add aditional fields to db.
- foreach ($schema as $field => $spec) {
- db_add_field('tmgmt_job_item', $field, $spec);
- }
- }
- /**
- * Data parsing helper function for tmgmt_update_7003().
- *
- * Copied from TMGMTJobItemController::count().
- *
- * @param $item
- * The current data item.
- * @param $entity
- * The job item the count should be calculated.
- */
- function _tmgmt_data_count_7003(&$item, $entity) {
- if (!empty($item['#text'])) {
- if (_tmgmt_filter_data($item)) {
- // Set default states if no state is set.
- if (!isset($item['#status'])) {
- // Translation is present.
- if (!empty($item['#translation'])) {
- $item['#status'] = TMGMT_DATA_ITEM_STATE_TRANSLATED;
- }
- // No translation present.
- else {
- $item['#status'] = TMGMT_DATA_ITEM_STATE_PENDING;
- }
- }
- switch ($item['#status']) {
- case 1:
- $entity->count_approved++;
- break;
- case 2:
- $entity->count_translated++;
- break;
- default:
- $entity->count_pending++;
- break;
- }
- }
- }
- else {
- foreach (element_children($item) as $key) {
- _tmgmt_data_count_7003($item[$key], $entity);
- }
- }
- }
- /**
- * Set counters for existing job items.
- */
- function tmgmt_update_7003(&$sandbox) {
- if (!isset($sandbox['progress'])) {
- $sandbox['progress'] = 0;
- $sandbox['last_tjiid'] = 0;
- $sandbox['max'] = db_query('SELECT COUNT(tjiid) FROM {tmgmt_job_item}')->fetchField();
- }
- $result = db_query('SELECT tjiid, data FROM {tmgmt_job_item} WHERE tjiid > :last_tjiid ORDER BY tjiid LIMIT 10', array( ':last_tjiid' => $sandbox['last_tjiid']));
- foreach ($result as $row) {
- // Unseralize data, count it and then save the counters.
- if (!empty($row->data)) {
- $fake_job_item = (object)array(
- 'count_approved' => 0,
- 'count_translated' => 0,
- 'count_pending' => 0,
- );
- $data = unserialize($row->data);
- _tmgmt_data_count_7003($data, $fake_job_item);
- $fields = (array)$fake_job_item + array(
- 'data' => serialize($data),
- );
- db_update('tmgmt_job_item')
- ->condition('tjiid', $row->tjiid)
- ->fields($fields)
- ->execute();
- }
- $sandbox['progress']++;
- }
- $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
- if ($row) {
- $sandbox['last_tjiid'] = $row->tjiid;
- }
- }
- /**
- * Replace the [#translation][#finished] attribute with [#status].
- */
- function tmgmt_update_7004(&$sandbox) {
- if (!isset($sandbox['progress'])) {
- $sandbox['progress'] = 0;
- $sandbox['last_tjiid'] = 0;
- $sandbox['max'] = db_query('SELECT COUNT(tjiid) FROM {tmgmt_job_item}')->fetchField();
- }
- $result = db_query('SELECT tjiid, data FROM {tmgmt_job_item} WHERE tjiid > :last_tjiid ORDER BY tjiid LIMIT 10', array(':last_tjiid' => $sandbox['last_tjiid']));
- foreach ($result as $row) {
- if (!empty($row->data)) {
- $data = unserialize($row->data);
- $flattened_data = array_filter(tmgmt_flatten_data($data), '_tmgmt_filter_data');
- // Loop over data, find finished translations, remove the flag and set
- // the status instead.
- foreach ($flattened_data as $key => $values) {
- if (!empty($values['#translation']['#finished'])) {
- $finished = $values['#translation']['#finished'];
- unset($values['#translation']['#finished']);
- drupal_array_set_nested_value($data, array_merge($key, array('#translation')), $values['#translation']);
- if ($finished && (empty($values['#status']) || $values['#status'] == TMGMT_DATA_ITEM_STATE_PENDING)) {
- drupal_array_set_nested_value($data, array_merge($key, array('#status')), TMGMT_DATA_ITEM_STATE_TRANSLATED);
- }
- // Save the updated data structure.
- db_update('tmgmt_job_item')
- ->condition('tjiid', $row->tjiid)
- ->fields(array('data' => serialize($data)))
- ->execute();
- }
- }
- }
- $sandbox['progress']++;
- }
- $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
- if ($row) {
- $sandbox['last_tjiid'] = $row->tjiid;
- }
- }
- /**
- * Add word count column to {tmgmt_job_item}.
- */
- function tmgmt_update_7005() {
- if (!db_field_exists('tmgmt_job_item', 'word_count')) {
- $spec = array(
- 'description' => 'Word count of all texts contained in this job item.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- );
- db_add_field('tmgmt_job_item', 'word_count', $spec);
- }
- }
- /**
- * Data parsing helper function for tmgmt_update_7006().
- *
- * Copied from TMGMTJobItemController::count().
- *
- * @param $item
- * The current data item.
- * @param $entity
- * The job item the count should be calculated.
- */
- function _tmgmt_data_count_7006($item, $entity) {
- if (!empty($item['#text'])) {
- if (_tmgmt_filter_data($item)) {
- module_load_include('module', 'tmgmt');
- // Count words of the data item.
- $entity->word_count += tmgmt_word_count($item['#text']);
- }
- }
- else {
- foreach (element_children($item) as $key) {
- _tmgmt_data_count_7006($item[$key], $entity);
- }
- }
- }
- /**
- * Set word count for existing job items.
- */
- function tmgmt_update_7006(&$sandbox) {
- if (!isset($sandbox['progress'])) {
- $sandbox['progress'] = 0;
- $sandbox['last_tjiid'] = 0;
- $sandbox['max'] = db_query('SELECT COUNT(tjiid) FROM {tmgmt_job_item}')->fetchField();
- }
- $result = db_query('SELECT tjiid, data FROM {tmgmt_job_item} WHERE tjiid > :last_tjiid ORDER BY tjiid LIMIT 10', array(':last_tjiid' => $sandbox['last_tjiid']));
- foreach ($result as $row) {
- // Unseralize data, count it and then save the counters.
- if (!empty($row->data)) {
- $fake_job_item = (object)array(
- 'word_count' => 0,
- );
- _tmgmt_data_count_7006(unserialize($row->data), $fake_job_item);
- db_update('tmgmt_job_item')
- ->condition('tjiid', $row->tjiid)
- ->fields((array)$fake_job_item)
- ->execute();
- }
- $sandbox['progress']++;
- }
- $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
- if ($row) {
- $sandbox['last_tjiid'] = $row->tjiid;
- }
- }
- /**
- * Removing the tmgmt_auto_accept variable.
- */
- function tmgmt_update_7007() {
- variable_del('tmgmt_auto_accept');
- }
- /**
- * Introduce the reviewed counter and rename approved.
- */
- function tmgmt_update_7008() {
- // Rename approved to reviewed to simplify the upgrade path.
- db_change_field('tmgmt_job_item', 'count_approved', 'count_reviewed', array(
- 'description' => 'Counter for all reviewed data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ));
- // Add the accepted counter.
- db_add_field('tmgmt_job_item', 'count_accepted', array(
- 'description' => 'Counter for all accepted data items.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ));
- }
- /**
- * Update data item status of accepted job items to accepted.
- */
- function tmgmt_update_7009() {
- // First set count_accepted to the value of count_reviewed.
- db_update('tmgmt_job_item')
- ->expression('count_accepted', 'count_reviewed + count_pending + count_translated')
- ->condition('state', TMGMT_JOB_ITEM_STATE_ACCEPTED)
- ->execute();
- // Then set count_reviewed to 0.
- db_update('tmgmt_job_item')
- ->fields(array(
- 'count_reviewed' => 0,
- 'count_translated' => 0,
- 'count_pending' => 0,
- ))
- ->condition('state', TMGMT_JOB_ITEM_STATE_ACCEPTED)
- ->execute();
- }
- /**
- * Create tmgmt_remote table to provide generic functionality for remote job
- * mappings.
- */
- function tmgmt_update_7010() {
- db_create_table('tmgmt_remote', array(
- 'description' => 'TMGMT job remote mapping.',
- 'fields' => array(
- 'trid' => array(
- 'description' => 'The primary key.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'tjid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => '{tmgmt_job}.tjid foreign key',
- ),
- 'tjiid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => '{tmgmt_job_item}.tjjid foreign key',
- ),
- 'data_item_key' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Translation job data item key.',
- ),
- 'remote_identifier_1' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_identifier_2' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_identifier_3' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ),
- 'remote_url' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Remote job url.',
- ),
- 'word_count' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Word count info provided by the remote service.',
- ),
- 'remote_data' => array(
- 'description' => 'Custom remote data.',
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- ),
- ),
- 'primary key' => array('trid'),
- 'indexes' => array(
- 'tjid' => array('tjid'),
- 'tjiid' => array('tjiid'),
- 'remote_identifiers' => array('remote_identifier_1', 'remote_identifier_2', 'remote_identifier_3'),
- ),
- ));
- }
- /**
- * Add uid field for {tmgmt_message} table.
- */
- function tmgmt_update_7011() {
- db_add_field('tmgmt_message', 'uid', array(
- 'description' => 'The identifier of the user who performed the action.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ));
- }
- /**
- * Shortens remote_identifier_1/2 fields and recreates index for remote
- * identifier fields to include only the first two.
- */
- function tmgmt_update_7012() {
- db_drop_index('tmgmt_remote', 'remote_identifiers');
- db_change_field('tmgmt_remote', 'remote_identifier_1', 'remote_identifier_1', array(
- 'type' => 'varchar',
- 'length' => 127,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ));
- db_change_field('tmgmt_remote', 'remote_identifier_2', 'remote_identifier_2', array(
- 'type' => 'varchar',
- 'length' => 127,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Custom remote identifier data.',
- ));
- db_add_index('tmgmt_remote', 'remote_identifiers', array('remote_identifier_1', 'remote_identifier_2'));
- }
- /**
- * Shortens reference and label fields in {tmgmt_job} to length 255.
- *
- * Avoids issues with InnoDB and UTF-8 key limits.
- */
- function tmgmt_update_7013() {
- db_drop_index('tmgmt_job', 'reference');
- db_change_field('tmgmt_job', 'reference', 'reference', array(
- 'description' => 'Remote identifier of this translation job.',
- 'type' => 'varchar',
- 'length' => 255,
- ));
- db_change_field('tmgmt_job', 'label', 'label', array(
- 'description' => 'Optional user provided label of the job.',
- 'type' => 'varchar',
- 'length' => 255,
- ));
- db_add_index('tmgmt_job', 'reference', array('reference'));
- }
- /**
- * Add amount and currency fields for {tmgmt_remote} table.
- */
- function tmgmt_update_7014() {
- db_add_field('tmgmt_remote', 'amount', array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Amount charged for the remote translation job.',
- ));
- db_add_field('tmgmt_remote', 'currency', array(
- 'type' => 'char',
- 'length' => 3,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Amount charged currency.',
- ));
- }
|