function lingotek_update_7408 in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.4 lingotek.install \lingotek_update_7408()
- 7.5 lingotek.install \lingotek_update_7408()
- 7.6 lingotek.install \lingotek_update_7408()
Creates an upgrade path for existing translated content to be inserted into entity_translation module table if necessary
File
- ./
lingotek.install, line 661
Code
function lingotek_update_7408(&$sandbox) {
lingotek_extend_metadata_tables();
if (module_exists('entity_translation')) {
$nid_list = array();
$results = db_select('lingotek', 'l')
->fields('l', array(
'nid',
'lingokey',
))
->condition('lingokey', 'target_sync_status_%', 'LIKE')
->condition('lingovalue', LingotekSync::STATUS_CURRENT)
->execute();
foreach ($results as $r) {
$nid_list[$r->nid] = str_replace('target_sync_status_', '', $r->lingokey);
}
foreach ($nid_list as $nid => $locale) {
$node = lingotek_node_load_default($nid, NULL, TRUE);
if ($node) {
if (lingotek_managed_by_entity_translation($node->type)) {
lingotek_entity_translation_save_status('node', $node, array(
Lingotek::convertLingotek2Drupal($locale, FALSE),
));
}
}
}
}
}