You are here

function acl_add_user in ACL 8

Same name and namespace in other branches
  1. 5 acl.module \acl_add_user()
  2. 6 acl.module \acl_add_user()
  3. 7 acl.module \acl_add_user()

Add the specified UID to an ACL.

1 call to acl_add_user()
AclTest::testNodeAclSingleUserAddRemove in src/Tests/AclTest.php
Includes acl_add_user, acl_remove_user, acl_has_users, acl_get_id_by_name, acl_has_user, acl_get_uids

File

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

Code

function acl_add_user($acl_id, $uid) {
  $database = \Drupal::database();
  $test_uid = $database
    ->query("SELECT uid FROM {acl_user} WHERE acl_id = :acl_id AND uid = :uid", [
    'acl_id' => $acl_id,
    'uid' => $uid,
  ])
    ->fetchField();
  if (!$test_uid) {
    $database
      ->insert('acl_user')
      ->fields([
      'acl_id' => $acl_id,
      'uid' => $uid,
    ])
      ->execute();
  }
}