You are here

function _photos_access_usersdel in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos_access/photos_access.module \_photos_access_usersdel()
  2. 7.3 photos_access/photos_access.module \_photos_access_usersdel()
  3. 6.0.x photos_access/photos_access.module \_photos_access_usersdel()

Delete user from album access list.

1 call to _photos_access_usersdel()
photos_access_update_access in photos_access/photos_access.module
Update access to album.

File

photos_access/photos_access.module, line 620
Implementation of photos_access.module.

Code

function _photos_access_usersdel($value, $id, $type = 0) {
  $db = \Drupal::database();
  if ($type) {

    // Delete all designated users.
    $db
      ->delete('photos_access_user')
      ->condition('id', $id)
      ->condition('collaborate', 0)
      ->execute();
  }
  elseif (is_array($value)) {
    $count = count($value);
    $i = 0;
    foreach ($value as $key => $remove) {
      if ($remove) {
        ++$i;
        $db
          ->delete('photos_access_user')
          ->condition('id', $id)
          ->condition('uid', $key)
          ->execute();
      }
    }
    if ($count == $i) {
      return TRUE;
    }
  }
}