You are here

function acl_get_ids_by_user in ACL 8

Same name and namespace in other branches
  1. 7 acl.module \acl_get_ids_by_user()

Get an array of acl_ids held by a user.

File

./acl.module, line 274
An API module providing by-user access control lists.

Code

function acl_get_ids_by_user($module, $uid, $name = NULL, $figure = NULL) {
  $query = \Drupal::database()
    ->select('acl', 'a');
  $query
    ->join('acl_user', 'au', 'a.acl_id = au.acl_id');
  $query
    ->fields('a', [
    'acl_id',
  ])
    ->condition('a.module', $module)
    ->condition('au.uid', $uid);
  if (isset($name)) {
    $query
      ->condition('a.name', $name);
  }
  if (isset($figure)) {
    $query
      ->condition('a.figure', $figure);
  }
  $acl_ids = $query
    ->execute()
    ->fetchCol();
  return $acl_ids;
}