Hi! I'm new to zenphoto and need some help with a little tweak on the default stopdesign theme. On the image page there is a link for the full-sized image. I would like to have a test to see if a user is logged in to that album before displaying the link, otherwise it would not appear at all.
I have been able to make this happen for admin users, which is great because admin should be able to see the link, using:
`
">
`
But again I would like have it check against the album password as well and if the same then display the link for that album only. Can anyone point me in the right direction?
Thank you
Several things.
first, you should be using the function zp_loggedin() rather than the global variable.
second, this result will never be exactly true, but testing it with if (zp_loggenin()) { will tell you if there is an admin user logged in.
third, there are album rights, etc. for admin users, so if you want to know if an admin is logged in with rights to view the album, that is yet another story.
fourth, visitors can also log in and view the gallery. If you are interested in that, then you have yet another story. for this look at the checkForPassword() function.
Thanks for the quick reply!
I am interested in the fourth option you mention, visitors that can log in with the album password to view an album.
I tested the checkForPassword() function, but it will display those hidden functions only on the album page that prompts you to enter the password, and not on the album or image page after entering the correct password.
Is there any way to check if the visitor is logged in or check the password before displaying these features?
Yes, use if !checkForPassword(true) { display the protected items }. Please see the function guide for documentation on this function. (NOTE: will also cover logged in admins.)
But, I am curious. If your gallery is password protected, then the viewer must login to view anything, so why is this test not redundant?
Well the album.php and image.php files are used for every album whether or not password protected. So there needs to be a way to test before showing the full size link, otherwise it will show up on every image in every album.
So in trying the !checkForPassword(true) function, it seems to just display the link anytime there isn't a prompt for the password in all albums, regardless of whether the album is password protected or if you're logged in. But looking around the function guide as you suggested, I ran across another promising function:
checkAlbumPassword($album, $hint)
Unfortunately this neat little function was ignored whether or not I was logged in as a guest to a password-protected album. It displayed the link either way:
`
if (checkAlbumPassword($album, $hint)) {
echo 'whatever is hidden'; ?>
`
But I think I may be on to something. Is there anything to be said for using this function? How could I make it work in this case?
My point was not about which album/image was being viewed. It was that SINCE IT IS BEING VIEWED the user must be logged in or he would not be seing the image and therefore could not be clicking on the full image link.
As to the function, yuou apparently did not read its documentation as suggested. Nor did you notice the example I gave.
woah dude, as stated above I tested the example you gave, and read the documentation, which I confess is not elaborate. I appreciate and am trying to absorb all the help that is given, and you have my sincere thanks. Apologies for not fully understanding.
However, your assumption that anytime the image is being viewed the user must be logged in is false.
A user must not necessarily be logged in to view an image in every album, only some albums require a login.
Thus the function as stated does not work in all cases.
solution:
`
`