You are here

function lingotek_entity_changed in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lingotek.util.inc \lingotek_entity_changed()
  2. 7.6 lingotek.util.inc \lingotek_entity_changed()
2 calls to lingotek_entity_changed()
lingotek_entity_save in ./lingotek.module
lingotek_rules_entity_upload in ./lingotek.rules.inc

File

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

Code

function lingotek_entity_changed($entity_type, $entity, $entity_id) {
  $updated_entity = $entity;
  if ($entity_type == 'node') {

    // Clear the cache to ensure we get the latest revision
    $nid = $updated_entity->nid;
    $cache =& drupal_static('lingotek_node_load_default', array());
    if (isset($cache[$nid])) {
      unset($cache[$nid]);
    }
    $updated_entity = lingotek_node_load_default($entity_id);
  }
  $xml = lingotek_entity_xml_body($entity_type, $updated_entity);
  $hash = md5($xml);
  $oldhash = lingotek_keystore($entity_type, $entity_id, 'hash');
  if (!$oldhash || strcmp($hash, $oldhash)) {
    lingotek_keystore($entity_type, $entity_id, 'hash', $hash);
    return TRUE;
  }
  return FALSE;
}