You are here

function lingotek_rules_entity_all_translations_of_status in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.rules.inc \lingotek_rules_entity_all_translations_of_status()
  2. 7.5 lingotek.rules.inc \lingotek_rules_entity_all_translations_of_status()
2 calls to lingotek_rules_entity_all_translations_of_status()
lingotek_rules_entity_all_downloaded in ./lingotek.rules.inc
lingotek_rules_entity_all_ready_for_download in ./lingotek.rules.inc

File

./lingotek.rules.inc, line 188
Lingotek Module + Rules Module Integration

Code

function lingotek_rules_entity_all_translations_of_status($wrapper, $status) {
  $entity = $wrapper
    ->value();
  $entity_id = $wrapper
    ->getIdentifier();
  $entity_type = $wrapper
    ->type();
  $source_lingotek_locale = Lingotek::convertDrupal2Lingotek($entity->language);
  $target_languages = Lingotek::getLanguagesWithoutSource($source_lingotek_locale);
  $target_status_keys = array();
  foreach ($target_languages as $target_lingotek_locale) {
    $target_status_keys[] = 'target_sync_status_' . $target_lingotek_locale;
  }
  if (empty($target_status_keys)) {
    return FALSE;
  }
  $query = db_select('lingotek_entity_metadata', 'lem')
    ->fields('lem', array(
    'entity_id',
  ))
    ->condition('lem.entity_id', $entity_id)
    ->condition('lem.entity_type', $entity_type)
    ->condition('lem.entity_key', $target_status_keys, 'IN')
    ->condition('lem.value', $status);
  $result = $query
    ->execute();
  return $result
    ->rowCount() === count($target_languages);
}