function nodeaccess_uuid_entity_uuid_load in Nodeaccess 7
Implements hook_entity_uuid_load().
File
- nodeaccess_uuid/
nodeaccess_uuid.module, line 10 - Adds UUID functionality to the nodeaccess module.
Code
function nodeaccess_uuid_entity_uuid_load(&$entities, $entity_type) {
if ($entity_type !== 'node') {
return;
}
foreach ($entities as &$entity) {
// Load the information.
$query = db_select('node_access', 'na');
$query
->fields('na');
$query
->addField('r', 'name', 'role_name');
$query
->addField('u', 'uuid', 'user_uuid');
$query
->addExpression("CONCAT(na.nid, '-', na.gid, '-', na.realm)", 'unique_key');
$query
->leftJoin('role', 'r', "na.realm='nodeaccess_rid' AND r.rid=na.gid");
$query
->leftJoin('users', 'u', "na.realm='nodeaccess_uid' AND u.uid=na.gid");
$query
->condition('na.nid', $entity->nid);
$results = $query
->execute()
->fetchAllAssoc('unique_key');
$entity->nodeaccess = $results;
}
}