You are here

function nodeaccess_uuid_entity_dependencies in Nodeaccess 7

Implements hook_entity_dependencies().

File

nodeaccess_uuid/nodeaccess_uuid.module, line 109
Adds UUID functionality to the nodeaccess module.

Code

function nodeaccess_uuid_entity_dependencies($entity, $entity_type) {
  if ($entity_type !== 'node') {
    return;
  }
  $query = db_select('node_access', 'na')
    ->condition('na.nid', $entity->nid)
    ->condition('na.realm', 'nodeaccess_uid');
  $join_alias = $query
    ->join('users', 'u', '(na.gid = u.uid AND na.realm = :realm)', array(
    ':realm' => 'nodeaccess_uid',
  ));
  $query
    ->fields($join_alias);
  $results = $query
    ->execute()
    ->fetchAllAssoc('uid');
  $dependencies = array();
  if (!empty($results)) {
    foreach ($results as $result) {
      $dependencies[] = array(
        'type' => 'user',
        'id' => $result->uid,
      );
    }
  }
  return $dependencies;
}