Skip to content

Commit

Permalink
Merge pull request #5 from herbdool/1.x-1.x
Browse files Browse the repository at this point in the history
Update entity_access to entityreference_entity_access
  • Loading branch information
herbdool authored Apr 4, 2017
2 parents 87c67f7 + 83046e8 commit 36c7f9a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions entityreference.module
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,8 @@ function entityreference_autocomplete_callback_get_matches($type, $field, $insta
$entity = NULL;
if ($entity_id !== 'NULL') {
$entity = entity_load($entity_type, $entity_id);
$has_view_access = (entity_access('view', $entity_type, $entity) !== FALSE);
$has_update_access = (entity_access('update', $entity_type, $entity) !== FALSE);
$has_view_access = (entityreference_entity_access('view', $entity_type, $entity) !== FALSE);
$has_update_access = (entityreference_entity_access('update', $entity_type, $entity) !== FALSE);
if (!$entity || !($has_view_access || $has_update_access)) {
return MENU_ACCESS_DENIED;
}
Expand Down Expand Up @@ -1161,8 +1161,8 @@ function entityreference_field_formatter_prepare_view($entity_type, $entities, $
// Replace the instance value with the term data.
$items[$id][$delta]['entity'] = $target_entities[$item['target_id']];
// Check whether the user has access to the referenced entity.
$has_view_access = (entity_access('view', $field['settings']['target_type'], $target_entities[$item['target_id']]) !== FALSE);
$has_update_access = (entity_access('update', $field['settings']['target_type'], $target_entities[$item['target_id']]) !== FALSE);
$has_view_access = (entityreference_entity_access('view', $field['settings']['target_type'], $target_entities[$item['target_id']]) !== FALSE);
$has_update_access = (entityreference_entity_access('update', $field['settings']['target_type'], $target_entities[$item['target_id']]) !== FALSE);
$items[$id][$delta]['access'] = ($has_view_access || $has_update_access);
}
// Otherwise, unset the instance value, since the entity does not exist.
Expand Down Expand Up @@ -1340,11 +1340,16 @@ function entityreference_autoload_info() {
);
}

function entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
/**
* Check user access to the entity.
*
* Until entity_access is supported in core.
*/
function entityreference_entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);
}
return TRUE;
// if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
// return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);
// }
}

/**
Expand Down

0 comments on commit 36c7f9a

Please sign in to comment.