Created
November 20, 2012 20:11
-
-
Save drsnyder/4120715 to your computer and use it in GitHub Desktop.
publicly visible images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT gallery_images.* | |
| FROM gallery_images | |
| JOIN gallery_album_images ON ( | |
| gallery_album_images.image_id = gallery_images.id AND gallery_album_images.is_default | |
| ) | |
| JOIN gallery_albums album ON ( | |
| album.id = gallery_album_images.gallery_album_id | |
| ) | |
| LEFT JOIN gallery_albums community ON ( | |
| album.object_type = get_huddler_constant('CONTENT_TYPE_GALLERY_ALBUM')::int AND | |
| community.id = album.object_id | |
| ) | |
| LEFT JOIN forum_threads ON ( | |
| community.object_type = get_huddler_constant('CONTENT_TYPE_THREAD')::int AND | |
| forum_threads.id = community.object_id | |
| ) | |
| WHERE | |
| -- make sure the album category is visible | |
| ( album.category_id IN (SELECT id FROM user_gallery_album_category_visibility(0)) ) AND | |
| -- make sure the community album category is visible (in case it is an image in a photoset | |
| -- IF community.id IS NOT NULL THEN communit.id IN ((SELECT id FROM user_gallery_album_category_visibility(0)) | |
| ( ( community.id IS NULL ) | |
| OR ( community.category_id IN (SELECT id FROM user_gallery_album_category_visibility(0)) ) ) AND | |
| -- IF community album AND forum_threads.id IS NOT NULL THEN forum_threads.forum_id must be in the visible forums | |
| ( ( community.id IS NULL ) | |
| OR ( ( forum_threads.id IS NULL ) | |
| OR ( forum_threads.forum_id IN (SELECT id | |
| FROM user_forum_visibility(0) | |
| WHERE is_content_viewable)))) AND | |
| -- IF community album status must be visible | |
| ( ( community.id IS NULL ) | |
| OR (community.status & get_huddler_constant('STATUS_BIT_VIEWABLE')::int)::bool ) AND | |
| (gallery_images.status & album.status & get_huddler_constant('STATUS_BIT_VIEWABLE')::int)::bool; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment