setting view restriction to un-registered users

Hi hope you guys are doing great. I am coming here after a long time and have even forgotten the zenphoto standard terminologies regarding albums/galleries etc (not your headache i know) so i'll explain what i need to know:

I want un-registered users to view up till here: http://www.outzeal.com/index.php?album=skiing/photos/usa-colorado

After this point I want them to log in so that they can view this: http://www.outzeal.com/index.php?album=skiing/photos/usa-colorado&image=001.jpg

If it is already mentioned somewhere pls share the link (sorry for wasting your time).

If its not mentioned before pls let me know how this can be done.

Thanks
«1

Comments

  • acrylian Administrator, Developer
    Please take a look here if this answers your questions already:
    http://www.zenphoto.org/news/an-overview-of-zenphoto-users
  • I already had a look before posting this query. In my understanding (if correct) the option I am looking for is not addressed there. The link you sent mentions:

    Protected image guest user: When these are set and image protection is set to protected, viewers will be required to login to view the full sized image.

    However what I want is something similar but at a different level (i.e. one step earlier). I want unrestricted access for viewers so that they can see the albums with image icons only. Once they click on the icon to see the image, I want viewers to login first.
  • acrylian Administrator, Developer
    We have no such protection on image level. You can guest password protect any album or you can limit top level albums and all sub albums via rights for registered users only. But you will not get to the thumbs.

    If you want to require being loggedin to view images at all you can modify your theme's image.php to check for the login status and refuse access of course. So don't protect the albums and modify the image.php file to refuse acccess if e.g. the vistior is not logged in and/or has a specific right.
  • ok thanks will try that, and definitely will come here again considering my scripting skills
  • file: image.php
    <head>
    if (zp_loggedin(user)) {load_CurrentPage;} else {load_LoginPage;}
    </head>

    do i need to do something like this. if yes then what will be the code to check log in status and displaying of current page or login page?

    Is there a guide about these functions, thanks.
  • acrylian Administrator, Developer
    No, much simpler. Place this check around the acual content of the image.php page:

    `
    if(zp_loggedin()) {
    // your actual single image content
    } else {
    printPasswordForm('', true, false);
    }
    `
    Just using `zp_loggedin()` requires being logged in but you can also request specific rights like `zp_loggedin(VIEW_GALLERY_RIGHTS)`. You find an overview here:
    http://www.zenphoto.org/news/an-overview-of-zenphoto-users
  • The issue I am getting with this is:

    When the else command runs it prints the Password Form at the location of this code and then carries on with the rest of the script and displays the image. e.g. please follow this link to see what I mean:
    http://www.outzeal.com/index.php?album=skiing/photos/usa-colorado

    I tried to get the login litebox to pop up but could'nt do it. Need help thanks.
  • acrylian Administrator, Developer
    Then you haven't enclosed the image.php page content within the check correctly.
  • acrylian Administrator, Developer
    An easier solution I should have thought of first (a bit like your own idea) for you without enclosing any content. On the image.php page right after
    `
    if (!defined('WEBPATH'))
    die();
    `
    place:

    `
    if(!zp_loggedin()) {
    include ('password.php');
    exitZP();
    }
    `
  • yeah this works however password.php brings up the page that requests for a password only i.e. there is no option for username. http://www.outzeal.com/index.php?album=skiing/photos/usa-colorado

    I tried this instead:

    if(!zp_loggedin()) {
    printPasswordForm('', true, false);
    exitZP();
    }

    this brings up the login page but not within the site.

    But if I place the code after the body tag then it pops up the login page within the site and masks everything else with black color. This works good, however in this case there is no registration link visible for visitors that are not yet registered.

    So the issue now is how to bring login page, if I use:

    if(!zp_loggedin()) {
    include ('password.php');
    exitZP();
    }

    Or how to show register link if I use:

    if(!zp_loggedin()) {
    printPasswordForm('', true, false);
    exitZP();
    }

    Thanks for your time, much appreciated
  • acrylian Administrator, Developer
    If you use the code I noted last like:
    http://www.zenphoto.org/test/passwordprotected_imagepage_code.jpg.html

    You get this:
    http://www.zenphoto.org/test/passwordprotected_imagepage.jpg.html

    So exactly what you wanted or not? Of course the function has several parameters. You can review them on the documentation as usual:
    http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionprintPasswordForm

    Registering is something different but the link should be show below the form if you have th register_user plugin enabled. Otherwise you can look at the theme's register.php page.
  • I am using the code like:
    http://www.outzeal.com/pswd_protect_code.jpg

    I get this:
    http://www.outzeal.com/pswd_protect_result.jpg

    Your result is exactly what I need but I cant figure out why I am not getting the username field.
  • acrylian Administrator, Developer
    My bad, that's a bug in 1.4.7. You would need to use the master / support build to get the name.
  • I am still on 1.4.5.7 official build. working fine for me. I've done so much customization that I would like to avoid an overall update.

    What does this mean 'master / support build to get the name"
  • oh ok the support build to get the same result... got it

    if i ugrade from 1.4.5.7 to 1.4.7 support build without updating the theme ... is it ok? (i know its not recommended)
  • acrylian Administrator, Developer
    You can of course choose to not upgrade on your own risk but you miss issue and security fixes and, well, as you know we can only support the current version.

    You will in any case have to update your theme in some place if you update from 1.4.5 to 1.4.6 as that was a bigger release but 1.4.7 is just a bugfix release (as the version numbering change was noted on its release).
  • the older version archive after 1.4.5.7 lists 1.4.5.8 and 1.4.5.9

    there is no 1.4.6? any special reason?

    the last digit is for the bug fix release, so is it ok to upgrade directly from 1.4.5.7 to 1.4.7 support build by skipping the intermediate releases?
  • fretzl Administrator, Developer
    Starting with 1.4.4 all consecutive releases are available on GitHub https://github.com/zenphoto/zenphoto/releases

    You should be able to safely upgrade to 1.4.7 directly.

    As @acrylian said, you will probably have to change some functions in your theme manually.
  • acrylian Administrator, Developer
    What fretzl said. But besides we just forgot to update the archive…
  • Thanks guys. I have upgraded to 1.4.7 Support build.

    The initial issue (to be logged in for viewing images) has been resolved and it works properly now.

    However if you click on the login link, the form is printed but doesn't go away after submission. I have to click on the index link to go back to the gallery/album.

    Though the login function is working properly and the user is logged in after submitting the form.

    Is this a bug or something at my end?

    Previously the login was done through litebox popup. Is it not available anymore? The user login-out plugin options show colorbox enabled.
  • acrylian Administrator, Developer
    The colorbox one is still there but check the colorbox plugin option so the scripts are loaded on the theme pages needed.

    Cannot answer the login link issue. Is this maybe the same as this?:
    https://github.com/zenphoto/zenphoto/issues/908
    Couldn't reproduce that so far.

    At least the printPasswordForm() function has a parameter for a page redirect. Maybe that is not set on your theme?
  • options/theme - use colorbox is checked

    options/plugin/colorbox_js on active (zenpage) theme has the required pages checked e.g. index,album,gallery,image etc

    but still it doesn't pop up.

    Regarding redirect issue are you talking about this parameter of printPasswordForm()in template-functions.php

    if (is_null($_password_redirect))
    $_password_redirect = getPageRedirect();

    how is one supposed to set this on a theme?
  • acrylian Administrator, Developer
    You don't do anything in template-funtions.php but set it where you use the printPasswordForm() function…
  • I checked the login issue with other themes, it is working normally i.e. the popup colorbox comes and then redirects after submission.

    I deleted the zenpage theme files and downloaded the files again from zenphoto site (1.4.7 support build) and uploaded them.

    Run the setup again. It gives a warning:

    "Zenphoto core files [Some files are missing or seem wrong]"

    and then it lists all zenpage theme files. Why is that?

    Though after setup it gives 5 green ticks for all themes setup.
  • acrylian Administrator, Developer
    It gives a warning because the file date is off compared to the other files. In your case you know it is since you added them later one. If this happens by itself suddenly it could indicate a file being hacked. http://www.zenphoto.org/news/installation-and-upgrading#re-running-and-re-uploading-setup-files
  • so what else can i try to resolve the login issue
  • acrylian Administrator, Developer
    You did use a custom theme, correct? If it works in the included correctly something will be different on yours.
  • I am using zenpage. i customized css a little bit but nothing related to its functions and in 1.4.5.7 login colorbox was working fine.

    After upgrading to 1.4.7 the login colorbox is not popping up neither redirecting after submission only in zenpage. In other themes it is working properly.

    After upgrading i havent customized anything yet. the files are exactly as they were downloaded from your site.
  • acrylian Administrator, Developer
    Ok, will take a look asap.
  • acrylian Administrator, Developer
    Reason you don't get a colorbox for the form is that it is not configured for the theme. In fact it requests a link to the password page instead by overriding the plugin options. Find `printUserLogin_out("", "", 0)` in the Zenpage theme's `sidebar.php` and change the 0 to 2 to always get a colorbox or remove the last parameter to let the plugin option set it.
Sign In or Register to comment.