You are here

function _photos_access_pass_type in Album Photos 8.5

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

Check validation type.

3 calls to _photos_access_pass_type()
PhotosAccess::access in photos_access/src/Plugin/views/access/PhotosAccess.php
Determine if the current user has access or not.
PhotosAccessControlHandler::checkAccess in src/PhotosAccessControlHandler.php
Performs access checks.
photos_access_request_album_password in photos_access/photos_access.module
Album password check.

File

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

Code

function _photos_access_pass_type($id, $op = 0) {
  $db = \Drupal::database();
  if ($op) {

    // photos.module.
    $result = $db
      ->query('SELECT a.*, au.collaborate, n.uid, n.type, n.status FROM {photos_access_album} a
      INNER JOIN {node_field_data} n ON a.nid = n.nid
      INNER JOIN {photos_image_field_data} p ON p.album_id = a.nid
      LEFT JOIN {photos_access_user} au ON a.id = au.id
      WHERE p.id = :id', [
      ':id' => $id,
    ]);
  }
  else {
    $result = $db
      ->query('SELECT a.*, au.collaborate, n.uid, n.type, n.status FROM {photos_access_album} a
      INNER JOIN {node_field_data} n ON a.nid = n.nid
      LEFT JOIN {photos_access_user} au ON a.id = au.id
      WHERE a.nid = :id', [
      ':id' => $id,
    ]);
  }
  $t = [];
  foreach ($result as $ac) {
    if ($ac->viewid == 3) {

      // Password authentication.
      $t['view'] = $ac;
    }
    elseif ($ac->collaborate && $ac->pass) {

      // Collaborate privileges.
      $t['update'] = $ac;
    }
    else {

      // Continue to node_access verification.
      $t['node'] = $ac;
    }
  }
  return $t;
}