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".
I am a programmer, but not in php. I can probably come up with the right syntax, by reading examples.
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.
" title=" ">
" title=" ">
There should be no need to modify the core function next_album(). What you could do is add those checks within the existing loop (on whichever page on which you wish to block the protected albums) and, if true, use continue to continue to the next iteration of the loop.
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.
Good idea.
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=" ">
Thanks. I already looked in the user guide (that is how I found the template-functions.php name), but I haven't been able to find a simple function that returns a true or false if the album is permitted for the current user.
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:
"
title="">
"
title="">
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 '' and ''
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//images/err-passwordprotected.gif.
The functions you will want to use for the check are in either functions-basic.php or functions.php, not template-functions.php. The Functions Documentation in the User Guide is useful for looking up these functions.
You need to escape code with backticks otherwise it gets unusable.
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.
Well, what you really should do is mark the albums both with a password and as unpublished. Then give the user rights to those albums you want him to see.
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.