You are here

function _pm_permission_get_entity_id_referenced_to_user in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 includes/pm.permission.inc \_pm_permission_get_entity_id_referenced_to_user()

Get entity ids having a reference field pointing towards the user id.

1 call to _pm_permission_get_entity_id_referenced_to_user()
pm_permission_grants_list in includes/pm.permission.inc
Helper function for pm_permission_node_grants.

File

includes/pm.permission.inc, line 658
Main module file for the pm_permission module.

Code

function _pm_permission_get_entity_id_referenced_to_user($entity_type, $bundle, $field_name, $uid) {
  $ids = FALSE;
  if ($entity_type and $bundle and $field_name and $uid) {
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', $entity_type)
      ->entityCondition('bundle', $bundle)
      ->propertyCondition('status', 1)
      ->fieldCondition($field_name, 'target_id', $uid)
      ->addMetaData('account', user_load(1));
    $result = $query
      ->execute();
    if (isset($result['node'])) {
      $ids = array_keys($result['node']);
    }
  }
  return $ids;
}