You are here

function photos_photos_access in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos.module \photos_photos_access()
  2. 6.2 photos.module \photos_photos_access()
  3. 7.3 photos.module \photos_photos_access()
  4. 6.0.x photos.module \photos_photos_access()

Implements hook_photos_access().

File

./photos.module, line 145
Implementation of photos.module.

Code

function photos_photos_access() {
  if (\Drupal::config('photos.settings')
    ->get('photos_access_photos')) {
    $current_path = \Drupal::service('path.current')
      ->getPath();
    $path_args = explode('/', $current_path);
    if (isset($path_args[3]) && $path_args[1] == 'photos' && $path_args[2] != 'get' && is_numeric($path_args[3])) {
      switch ($path_args[2]) {
        case 'album':
          return [
            $path_args[3],
          ];
        case 'image':
          $db = \Drupal::database();
          $nid = $db
            ->query("SELECT pid FROM {photos_image} WHERE fid = :fid", [
            ':fid' => $path_args[3],
          ])
            ->fetchField();
          return [
            $nid,
          ];
      }
    }
    if (isset($path_args[4]) && $path_args[1] == 'photos' && $path_args[2] == 'data' && is_numeric($path_args[4])) {
      return [
        $path_args[4],
      ];
    }
  }
}