You are here

function lingotek_managed_entity in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lingotek.util.inc \lingotek_managed_entity()
  2. 7.6 lingotek.util.inc \lingotek_managed_entity()
3 calls to lingotek_managed_entity()
lingotek_field_language_alter in ./lingotek.module
Implements hook_field_language_alter().
lingotek_form_node_form_alter in ./lingotek.module
Implements hook_form_BASE_FORM_ID_alter().
lingotek_node_view in ./lingotek.module
Implements hook_node_view().

File

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

Code

function lingotek_managed_entity($entity_type, $entity) {
  list($id, $vid, $bundle) = lingotek_entity_extract_ids($entity_type, $entity);

  // If there is no $bundle property, then nothing to manage for now.
  if (!$bundle) {
    return FALSE;
  }

  // If this is being newly created, see if the content type is enabled
  if (!$id) {
    return lingotek_enabled_bundle($entity_type, $bundle);
  }

  // Check the entity itself for overrides.
  $query = db_select('{lingotek_entity_metadata}', 'lem')
    ->fields('lem', array(
    'value',
  ))
    ->condition('lem.entity_type', $entity_type)
    ->condition('lem.entity_id', $id)
    ->condition('lem.entity_key', 'profile');
  $result = $query
    ->execute()
    ->fetchField();
  if ($result !== FALSE) {
    if ($result === LingotekSync::PROFILE_DISABLED) {
      return FALSE;
    }
    else {
      return TRUE;
    }
  }

  // No overrides, so check the entity's bundle.
  return lingotek_enabled_bundle($entity_type, $bundle);
}