Login redirect to user gallery

Hello there,

please bear with me if this has been discussed widely (I hope not), I was not able to find anything too close related to my case.

I am currently setting up a website for a photographer who wants to have a login area where customers of her can view an album of photographs they had ordered, so they can re-order them. No need for getting any web shop or data transmission to a contact form, it's just that those customers should be able to see a specific album after they logged on, and nobody else.

Setting up the basics is simple - we have some open albums visible to anyone, and one that is connected to a user, i.e. it has not been published, but is tied to a specific user with limited rights (viewing etc.) so that he is able to see them when he is on while nobody else sees the albums.

My question is: is it possible to have this very album/the pictures for the customer on a separate page and not in the main gallery, and make the login form redirect to that page? The photographer will have more than one customer, so sending them to a straight URI of a specific album will not work well :). Can anybody help me out with some hints on this?

Thanks in advance ;).

Comments

  • acrylian Administrator, Developer
    That is possible. Since you can only assign passwords to top level albums I suggest this:

    Create a toplevel album where you put all open viewable albums in and link directly to that via a main navigation for example. That will look like the index page.

    Then you create a page that displays all future password albums except that one. We have some functions for that like isMyAlbum.
  • Guess you looked in the wrong place:) Maybe this is what you are lookin for http://www.zenphoto.org/2009/11/zenphoto-single-login/
  • acrylian Administrator, Developer
    And my suggestion was more for a separate client area, just to add.
  • Hey you two,

    thank you for helping me out a second time today. Not sure whether you nailed it or not, but it sounds helpful in the first place. What I want to achieve is a) an area where each and every visitor of the site can see some public albums and b) an area where a registered user can see his or her own album(s).

    Suggestion 1 - acrylian - wouldn't that mean I have maybe a big album for all client sub-albums, and everyone, each client, can at least see that other clients also have albums up there, only that they cannot access it without the password?

    Suggestion 2 - sbillard - I may be a complete stupid person, but I had already tried that out, resulting in a redirect to an upgrade for zenphoto - each time I try it out. No upgrade preinstalled for zenPhoto, so I wonder what that means...

    Thank you again for your help!
  • #2: The hack is a bit old. The zp-config.php file has moved. Change the line which reads:
    `if (!file_exists(dirname(__FILE__) . '/' . ZENFOLDER . "/zp-config.php")) {`
    to be:
    `if (!file_exists(dirname(__FILE__) . '/zp-data/zp-config.php")) {`
    alo change:
    `require_once(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER . 'user_logout.php');`
    to be:
    `require_once(SERVERPATH . "/" . ZENFOLDER . "/" . PLUGIN_FOLDER . '/user_login-out.php');`
  • acrylian Administrator, Developer
    As to my suggestion 1: Yes, you would have one top level album with subalbums for the public ones that you link to directly.
    Since the client albums would also be top level albums (as only those can be password protected) no one visiting would see them. If you use the helper function isMyAlbum() to test the clients will only see their own albums if they are loggedin and nothing if not.

    Rough code for a client page (a custom theme page like clientlogin.php):
    `
    <?php if(!zp_loggedin()) printPasswordForm(); (( to display the password form if not loggedin
    while (next_album()):
    if(isMyAlbum($_zp_current_album->name,ALBUM_RIGHTS)) { // you might add here additional checks to prevent display of other albums.

    endwhile; ?>
    `
    I did this for a client's site myself (sadly not online yet so I can't show)
  • Hey there,

    I will try out both later to see what helps me most. So far acrylian's approach seems closer to what I need, but my tests will tell :).

    Thanks again for so much help!
  • Hey there,

    I checked with the single_login approach and am having trouble to get any further. Once the login is processed, it leads to an 'object not found' page created by zenphoto. In my lay interpretation of the PHP code I'd think that

    if (!is_null($_zp_current_admin)) {
    if ($_zp_loggedin & ADMIN_RIGHTS) {
    header("Location: " . WEBPATH . "/");
    } else {
    $albums = getManagedAlbumList();
    $album = array_shift($albums);
    header("Location: " . WEBPATH . "/".$album.'/');
    }

    is not leading to the page it should. I tried with a super admin and a normal user who is able to see an album exclusively. No avail so far....

    Can somebody point me in the right direction?

    Thanks as usual :).
  • I might add that nearly all paths seem to be wrong in the hack version.

    EDIT: No, just my wrong interpretation of PHP code :).
  • What do the links look like? One thing you should try is to hard code a link to a known album and see if that works. Anyway, compare the links to those that you get when you visit the album through the gallery. Let us know.
  • Well, the page I land on after logging on is index.php?userlog=1&p= where I get the "The object cannot be found" (I see it in German, only assume it's named that way in English) error. It just doesn't seem to find the right path.

    If I put up a

    if (!defined('WEBPATH')) { define('WEBPATH', ''); }

    for the

    if (!is_null($_zp_current_admin)) {
    if ($_zp_loggedin & ADMIN_RIGHTS) {
    header("Location: " . WEBPATH . "/");
    } else {
    $albums = getManagedAlbumList();
    $album = array_shift($albums);
    header("Location: " . WEBPATH . "/".$album.'/');
    }

    stuff I get a successful redirect, but each time to the home page of my site, not the portfolio url (home: www.address.com, portfolio at www.address.com/portfolio) or the specific albums or or the user manages....
  • Assuming that you have `ADMIN_RIGHTS`, then that behavior is exactly as prescribed in the code you posted. If the user logged in and has those rights, he will be redirected to the home page. Otherwise, the user will be redirected to a managed album.
  • Just to get it straight: when I set up a user to be able to visit a certain album that hasn't been published, nothing else - is that user an admin then? I mean I choose 'Show all' and 'Overview' as his rights and select an unpublished album under 'Manage'?

    If I leave out my !define WEBPATH, I get the 'Object not found' error, if I include it, I get redirected to the frontpage of my website (not the portfolio), be it an admin or the user form I described above... sorry if I start sounding lame :).
  • It sounds like WEBPATH has not been defined. Does your script include the zenphoto scripts? You should probably check your CGI error log as well to see if it shows some errors.
  • Yes, it has not been in the original script (http://www.zenphoto.org/2009/11/zenphoto-single-login/).
    If I define webpath this way:

    if (!defined('WEBPATH')) { define('WEBPATH', ''); }

    the script leads me to the homepage of the site (not the portfolio), no matter what kind of user I am. If I leave it out like in the original script, I get these 'object not found' errors.
  • acrylian Administrator, Developer
    Do you use the recently updated file from the extensions section?
  • I use exactly the one pointed to above: http://www.zenphoto.org/2009/11/zenphoto-single-login/
  • acrylian Administrator, Developer
    I think sbillard had updated that file either quite while you ask or shortly after. That's why I asked if it is the recent one. The one shortly before was not compatible.
  • Hey

    I have tried also using the single user login extension and have followed the instructions to the T but when I navigate to where the index.php page included to use this I receive the error:

    Fatal error: Call to undefined function printuserlogout() in /home/mysite/public_html/sitetest/single_login.php on line 41

    any clues?

    Jake
  • The function `printUserLogout` is deprecated; either change it to `printUserLogin_out` at line 41 of the script or enable the `deprecated_functions` plugin.
  • Hey

    that worked, thank you - but it doesn't show the albums... no matter - I will bash on a little more...
Sign In or Register to comment.