You are here

function _photos_access_userlist in Album Photos 8.4

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

List of users who have access to album.

2 calls to _photos_access_userlist()
photos_access_form_node_form_alter in photos_access/photos_access.module
Implements hook_form_BASE_FORM_ID_alter() for form_node.
photos_access_node_load in photos_access/photos_access.module
Implements hook_node_load().

File

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

Code

function _photos_access_userlist($id, $collaborate = FALSE) {
  $db = \Drupal::database();
  $results = $db
    ->query('SELECT u.uid, u.name FROM {users_field_data} u
    INNER JOIN {photos_access_user} a ON u.uid = a.uid
    WHERE a.id = :id AND a.collaborate = :collaborate', [
    ':id' => $id,
    ':collaborate' => $collaborate ? 1 : 0,
  ]);
  $users = [];
  foreach ($results as $a) {
    $u = new stdClass();
    $u = $a;
    $u->username = [
      '#theme' => 'username',
      '#account' => $a,
    ];
    $users[] = $u;
  }
  return $users;
}