How can I get Zenphoto to only show albums that the current user has access to, when displaying the gallery of albums? Right now, the albums that are blocked show up with a locked icon (err_passwordprotected.gif) and the title of the album. These clutter the gallery view for the restricted user and they also create questions about "why can't I see such and such".
Comments
Seems like I should modify the 'next_album' logic to just skip the ones I don't want, right? Where is the next_album function defined?
I see the following in the index.php page.
<?php while (next_album()): ?>
<div class="album">
<div class="thumb">
" title="<?php echo gettext('View album:'); ?> <?php echo getAnnotatedAlbumTitle();?>"><?php printAlbumThumbImage(getAnnotatedAlbumTitle()); ?>
</div>
<div class="albumdesc">
<h3>" title="<?php echo gettext('View album:'); ?> <?php echo getAnnotatedAlbumTitle();?>"><?php printAlbumTitle(); ?></h3>
<small><?php printAlbumDate(""); ?></small>
<p><?php printAlbumDesc(); ?></p>
</div>
<p style="clear: both; "></p>
</div>
<?php endwhile; ?>
Another alternative could be to simply unpublish the protected albums. Given that your users have the correct rights to view those albums, they will see the albums even if they are unpublished. Users without sufficient rights, however, would not.
It appears that getAnnotatedAlbumTitle() returns the title with some embedded flag to tell if it is protected. So THAT is my clue, but how can I derive the value of this flag? If I could see the code in printAlbumThumbImage I would get further long. Where do I go to find this function's code?
Sorry to be so PHP and ZenPhoto dense....
" title="<?php echo gettext('View album:'); ?> <?php echo getAnnotatedAlbumTitle();?>"><?php printAlbumThumbImage(getAnnotatedAlbumTitle()); ?>
The section from the user guide on themes that is relevant doesn't address how to filter the albums. (See below). Actually, the problem would be solved easier if the list of returned albums was pre-filtered based on the user's ability to see the albums. Don't return what they can't see and problem solved. But I am sure I'd be too far down the rabbit hole to make that happen.
Am I basically asking for a feature in ZenPhoto that would be a checkbox by user or group that would say 'hide albums that are not protected'??
----------------------------------------------------------------------------------
The following code is the main chunk of code for this file. It’s the so called “album loop†that lists all the albums in the gallery:
<?php while (next_album()): ?> <div class="album">
<div class="albumthumb">"
title="<?php echo getAlbumTitle();?>">
<?php printAlbumThumbImage(getAlbumTitle()); ?></div>
<div class="albumtitle">
"
title="<?php echo getAlbumTitle();?>">
<?php printAlbumTitle(true); ?></div> </div> <?php endwhile; ?>
Let’s take this line by line. First you’re starting a while loop in PHP and tell ZenPhoto that ‘as long as there’s a another album that’s next in the list of albums, do the following code’. The ‘code’ that you want Zenphoto to process for every album is placed in between the the lines '<?php while (next_album()): ?>' and '<?php endwhile; ?>'
That is why when you look at the xHTML source from your browser you see a div with an album class more than once, because it will put every album into a div tag with the album class.
Now inside that while loop you will see more PHP code. The functions getAlbumLinkURL(), getAlbumTitle(), printAlbumThumbImage(), and printAlbumTitle() are all theme functions of which we won’t explain because there are just too many to create a list here and you can also look them up in the theme function reference. However it’s pretty obvious what they do just by looking at the function names. Keep in mind that all these functions provide information about the album and this information will be repeated for each album in the list of albums while going through the while loop.
Note: If you password protect an album via the admin backend and have the image display use lock image option set, Zenphoto uses a default image err-passwordprotected.gif as a replacement for the actual album thumb. This image is located within /zenphoto/zp-core/image/ folder. But a theme can have its own image, all that needs to be done is to place a custom image of the same name like this: /zenphoto/<themefolder>/images/err-passwordprotected.gif.
By default Zenphoto does simply not what you want. See the forum rules post on how to submit feature suggestions. As said you need to look at the two functions I already mentioned. However excluding an album from the loop results in wrong album pagination.
You can of course code your own loop using the object model framework but then you have to do all yourself.
Thanks for everyone's help.
Zenphoto does in fact return only the albums a user is allowed to see. Your problem seems that you are allowing him to see ones you do not want him to see. Thjs is the same suggestion made by kagutsuchi earlier.
The states are pretty simple:
To protect access to an album use password protection
To hide an album mark it as unpublished.
all combinations of these states are allowed and provide useful actions.
Users may be "limited" to certain albums via the managed albums list plus the rights you assign them. Users with rights to an album can see it even when it is unpublished. (Of course, they can also access it.) No rights, no see nor access.