You are here

function photos_access_request_album_password in Album Photos 8.5

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

Album password check.

3 calls to photos_access_request_album_password()
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_node_access in photos_access/photos_access.module
Implements hook_ENTITY_TYPE_access().

File

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

Code

function photos_access_request_album_password() {
  $node = \Drupal::routeMatch()
    ->getParameter('node');
  if (is_numeric($node)) {

    // Views only provides the numeric nid.
    // @todo find out if there is a better way to do this in views?
    $node = Drupal::entityTypeManager()
      ->getStorage('node')
      ->load($node);
  }
  if ($node && $node instanceof NodeInterface && $node
    ->getType() == 'photos') {

    // Use album node id.
    $t = _photos_access_pass_type($node
      ->id());
  }
  elseif ($entityId = \Drupal::routeMatch()
    ->getRawParameter('photos_image')) {

    // If viewing image check access to album node id.
    $db = \Drupal::database();
    $nid = $db
      ->query("SELECT album_id FROM {photos_image_field_data} WHERE id = :id", [
      ':id' => $entityId,
    ])
      ->fetchField();
    $t = _photos_access_pass_type($nid);
  }
  if (isset($t['view'])) {
    if ($t['view']->viewid == 3) {
      photos_access_pass_validate($t);
    }
  }
}