You are here

function lingotek_previously_managed_translations in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.util.inc \lingotek_previously_managed_translations()
  2. 7.5 lingotek.util.inc \lingotek_previously_managed_translations()
2 calls to lingotek_previously_managed_translations()
lingotek_admin_add_entity_specific_changes in ./lingotek.admin.inc
Modify general entity-translation form to include entity-specific changes.
lingotek_get_node_settings_form in ./lingotek.module
Display the Lingotek node-settings form

File

./lingotek.util.inc, line 1966
Utility functions.

Code

function lingotek_previously_managed_translations($entity_type, $entity_ids = NULL) {

  // retrieve all entities of the given type with document IDs
  $query = db_select('lingotek_entity_metadata', 'lem');
  $query
    ->fields('lem', array(
    'entity_id',
  ))
    ->condition('lem.entity_type', $entity_type)
    ->condition('lem.entity_key', 'document_id');
  if ($entity_ids && is_array($entity_ids)) {
    $query
      ->condition('lem.entity_id', $entity_ids, 'IN');
  }
  $result = $query
    ->execute();
  $entity_ids = $result
    ->fetchCol();
  if (!$entity_ids) {
    return FALSE;
  }

  // filter the entity IDs by ones that still exist
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $entity_type)
    ->entityCondition('entity_id', $entity_ids, 'IN');
  $entities = $query
    ->execute();
  $entity_ids = array_keys($entities[$entity_type]);
  $enabled_entities = lingotek_get_enabled_entities_by_type($entity_type);
  $entity_ids = array_diff($entity_ids, array_keys($enabled_entities));
  if (empty($entity_ids)) {

    // No disabled entities found.
    return FALSE;
  }
  return TRUE;
}