password form in colorbox

vincent3569 Member, Translator
hi,

on the next version of my theme, I posted the login form in colorbox. You can see the result here: http://test.vincentbourganel.fr/

I would have the same function for displaying the password form (for protected album for example).
to be more precise: when I click on an image with the lock, the password form is displayed in colorbox, and if OK, the user is returned to the album.

is it possible to do that ?

Comments

  • acrylian Administrator, Developer
    Since the password protection is php and the colorbox not you need to relead the page the colorbox was called from to see the change. (=if you close the colorbox nothing is loaded new). You could probably do a direct redirection to a new page from the page called within the colorbox. That might be possible if you call a custom theme page with the form within the colorbox (/page/<custompage>).
  • The logon redirect will happen within the colorbox unless you find a way to close the colorbox when the logon button is pressed. You can do that with javascript, and probably attach the js to the button in the code that loads the form in colorbox. There are details here that would need to be worked out, though.
  • acrylian Administrator, Developer
    True, that is a problem. Perhaps not really worth the work to follow this idea.
  • vincent3569 Member, Translator
    go to my test site (http://test.vincentbourganel.fr/) and try to connect with invite/guess!
    when the logon button is pressed, colorbox is closed and you are logged.

    I wish to do the same thing with password form
  • acrylian Administrator, Developer
    Well, your test credentials do not work for me. Anyway if the colorbox is closed on a button there must be a js call attached to that button. There is a publich method for that:
    http://jacklmoore.com/colorbox/

    Anyway, if the colorbox is closed without the page behind reloaded that page will not reflect you are logged in until you do so manually or accessing another page.
  • vincent3569 Member, Translator
    longin : invite / password : guess! (with "!" at the end)
    it works without reload anything.

    in fact, the login form is in the footer : colorbox use inline content.

    for password form, maybe, there is another story (maybe use iframe content)
  • Because it is inline content that form goes away on the redirect. (it does actually reload the page, by the way.) But the form you get from visiting a password protected ablum came from the page load. The `password.php` script gets loaded instead of the `album.php` script. So I do not see where a colorbox would make any benefit.

    If instead you want to change the link to the album if it is password protected, you could then make a colorbox. Of course, the normal template functions do not do that, so you would have to code your own album link functions. Those functions could test to see if the viewer has access rights to the album, and if not present a colorbox login form like you do for the footer.

    The `printUserLogin_out()` function does not have a parameter for the redirect. However it does make use of a global variable `$__redirect` which is an array of query parameters. So you could setup that array before the function call to set the `album=xxx` query parameter. Kind of relying on undocumented behavior, so if you find this useful we really need to formalize the parameter.
  • vincent3569 Member, Translator
    Because it is inline content that form goes away on the redirect. (it does actually reload the page, by the way.)

    ok, I understand : when the page is reloaded, if the login is correct, printUserLogin_out is not displayed again, so colorbox is not displayed too (so the colorbox is not closed in the inital page, but closed by the reloading of the new page).

    so, for my personnal use, I don't need to have a new redirect parameter in the call of `printUserLogin_out()`.

    nevertheless it is an interesting idea, especially since printPasswordform use this parameter.
    If instead you want to change the link to the album if it is password protected, you could then make a colorbox. Of course, the normal template functions do not do that, so you would have to code your own album link functions. Those functions could test to see if the viewer has access rights to the album, and if not present a colorbox login form like you do for the footer
    It seems to be my need. but I am not competent enough to code this improvement, and it's a pity, because this would bring the same experience on the using of the theme (password and login in colorbox)
  • For the album bit it would most likely need to be a theme implementation given the way the href normally encompases the thumbnail. You can test `$album->checkAccess()` to see if the album is "allowed" for the user or not. But then the code becomes theme specific.
  • vincent3569 Member, Translator
    hi

    I need your help :
    when a user access on protected album (for example), `zp_loggedin()` is false.
    so is there a variable which indicates this particular state (the user is not logged in, but he has provided a correct login/password to access on protected object) ?
  • Your analysis above is faulty. `zp_loggedin()` returns true if there is a Zenphoto user logged in and false if there is no Zenphoto user logged in. A logged in user may still not have access to a protected album and requre a guest password to browse it.

    you can tell if a viewer may browse an album with `$album->checkAccess()` But it does not distinguish between Zenphoto users and guest password users. Just tells you that the viewer may access the album. It is true if the viewer has provided the correct guest password or is a zenphoto user with rights to browse the album.

    BTW, there is no simple way to tell if a user could access the album.
  • vincent3569 Member, Translator
    I feel that something does not work well with plugin userlogin_out.

    I did some tests with the theme zenpage:
    If you connect with the credentials of a user, you have the link "logout" between tags `
      ` and `
    • ` in the sidebar and it's OK.

      But, if you connect to a protected album using the login / password of the album, you have the link "Logout" not included in the tags `
        ` and `
      • ` in the sidebar.

        In fact, if you use the login/password of a protected object, you are considered as not connected ( if (zp_loggedin()) returns false ).

        But at the same time, in printUserLogin_out, it seems you are considered as connected and the logout link is displayed.
  • acrylian Administrator, Developer
    Looking at the sidebar.php of the Zenpage theme the login/register links are always within `` if you don't use the custom menu with the menu_manager but the standard menu functions. Which one did you test?
  • You should also be sure you are testing with the RC3 candidate since this area has been changed to close out your ticket. [note: the login menu is separate from the custom/standard menu selection, so is always with the `` pair.]
  • vincent3569 Member, Translator
    yes ! with RC3, it works very well and it is an improvement which greatly simplifies the operation of the plugin.

    however, there is a problem : the function js() (the call of colorbox) is not called by other themes : so it works only with zenpage, and not with zpardoise, so I can't benifit of this improvement :-(

    a note: I found a trick to force the display of colorbox if there is error message

    I will add the modified file to the ticket http://www.zenphoto.org/trac/ticket/2054
  • You can use it with your theme as well,just have to use the same undocumented code that Zenpage does use. That is, it sets the Login Form option to 2 in its functions.php script.

    Thanks for the modification, a good addition.
  • vincent3569 Member, Translator
    Hi,

    I have some tests with new printUserLogin_out and my personnal themes : I use the same undocumented code that Zenpage does use.

    I don't undderstand :

    the following script, applied in the header with zenpage theme, is not applied with other themes.

    `

    //

    `
    so, the colorbox is not displayed (even if colorbox is enabled on the page)
    can you explain where the problem is ?

    to be more simple, why don't you add this code in

    why don't write this script next to the generated HTML (and not in the header), as you did with the search parameters or colorbox slideshow parameters ?

    I have another request :
    for cross-browser compatibility, could you add in the colorbox parameters `innerWidth: "400px"`.
    with actual parameters, it doesn't work well with IE7...
  • Are you sure you copied all the code that zenpage has added? In particular, the code that sets the "form" option to 2? We can move the script, but you will still have to be sure that colorbox is enabled on the page--setting the option takes care of that as well.

    No problem with the innerwidth. I will add that.
  • vincent3569 Member, Translator
    zenpage code is

    `
    <?php if (function_exists("printUserLogin_out")) { ?>

    <?php printUserLogin_out("","", 2); ?>

    <?php } ?>
    `
    mine is

    `
    <?php if (function_exists('printUserLogin_out')) { ?>
    <?php printUserLogin_out(' | ', '', 2); ?>
    <?php } ?>
    `
    of course, colorbox is enabled on each page of the theme.
  • That is not the only code involved. Look at the zenpage functions.php!
Sign In or Register to comment.