Patch provides an inner join for album access table so you can filter albums view by access type:

Example Usage:
- show only albums that are "open"
- show only albums that are pass protected
- etc

Patch provides SQL query like so:

SELECT photos_album.pid AS pid, photos_album.fid AS photos_album_fid
FROM 
{photos_album} photos_album
INNER JOIN {photos_access_album} photos_access_album ON photos_album.pid = photos_access_album.nid
WHERE (( (photos_access_album.viewid = '0') ))
LIMIT 5 OFFSET 0
CommentFileSizeAuthor
#3 2701989-extended-patch.patch668 bytesdakku
#2 2701989-patch.patch1.95 KBdakku

Comments

dakku created an issue. See original summary.

dakku’s picture

StatusFileSize
new1.95 KB
dakku’s picture

StatusFileSize
new668 bytes

extending patch to make access type available to images too:

Example usage:
- show all images where album access is "open"

SELECT photos_image.fid AS fid, photos_image.fid AS photos_image_fid
FROM 
{photos_image} photos_image
LEFT JOIN {photos_access_album} photos_access_album ON photos_image.pid = photos_access_album.nid
WHERE (( (photos_access_album.viewid = '0') ))
ORDER BY photos_image_fid DESC
LIMIT 5 OFFSET 0
nathaniel’s picture

This is a great idea. I think it would be best in the photos_access sub-module since that module creates the {photos_access_album} table. Added it there in the D8 version.

/**
 * Helper function to return options for views album privacy filter.
 */
function _photos_access_album_views_options() {
  return array(
    0 => t('Open'),
    1 => t('Locked'),
    2 => t('Designated users'),
    3 => t('Password required')
  );
}

/**
 * Implements hook_views_data().
 */
function photos_access_views_data() {
  $data = array();
  $data['photos_access_album'] = array();
  $data['photos_access_album']['table'] = array();
  $data['photos_access_album']['table']['group'] = t('Photos');
  $data['photos_access_album']['table']['provider'] = 'photos_access';

  // Join node_field_data.
  $data['photos_access_album']['table']['join'] = array(
    'node_field_data' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );

  // Numeric field, exposed as a field, sort, filter, and argument.
  $data['photos_access_album']['viewid'] = array(
    'title' => t('Privacy'),
    'help' => t('Album privacy setting.'),
    'field' => array(
      'id' => 'numeric',
    ),
    'sort' => array(
      'id' => 'standard',
    ),
    'filter' => array(
      'id' => 'in_operator',
      'options callback' => '_photos_access_album_views_options'
    ),
    'argument' => array(
      'id' => 'numeric',
    ),
  );

  return $data;
}
nathaniel’s picture

Assigned: Unassigned » nathaniel
Status: Needs review » Needs work

  • Nathaniel committed 8e0d29e on 7.x-3.x authored by dakku
    Issue #2701989 by dakku, Nathaniel: Filter Albums view by Album Access...
nathaniel’s picture

Assigned: nathaniel » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.