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:
`
<?php if($_zp_loggedin == true) { ?>
" title="<?php echo getBareImageTitle();?>">
<?php echo gettext('Full Size'); ?><?php } ?>
`
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
Comments
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.
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?
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?
`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'; ?>
<?php } ?>
`
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?
As to the function, yuou apparently did not read its documentation as suggested. Nor did you notice the example I gave.
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.
`
<?php
$pwd=$_zp_current_album->getPassword();
if (!empty($pwd) && !checkForPassword()) {
echo 'protected items go here'
} ?>
`