Latest Comments Not Showing for Non-Admin Users

I'm using zpskeleton (v1.4.3) on ZenPhoto (v1.4.3.3) which calls:
`
<?php printLatestComments(2,'125','all'); ?>
<?php printLatestZenpageComments(1,'125','','all'); ?>
`
This gallery is password protected so that only registered users can see it.

I am able to see the latest comments show up on the home page when my users have General -> Admin permission bit set, but I am unable to see the latest comments without the bit set.

The comments are published and not private. I am able to see the comment on the album or image page without the permissions bit set.

I'm hoping somebody can help me make sense of what might be happening.

Thanks for any help in advance.

-Derek

PS. Also, I realize the standard answer will be "use a standard theme", so I gave the "Default" theme a shot, making a slight modification to include the call to the two functions:
`


--- index.php.mod 2012-10-10 13:45:40.321655946 -0600

+++ index.php 2012-10-10 13:45:46.216887100 -0600



printCustomPageURL(gettext('Register for this site'), 'register', '', '', ' | ');

}

?>

-

-

Latest Comments

-<?php printLatestComments(2,'125','all'); ?>

-<?php printLatestZenpageComments(1,'125','','all'); ?>

-

<?php printZenphotoLink(); ?>



<?php @call_user_func('mobileTheme::controlLink'); ?>

`
The same issue exists on the Default theme as well.

Comments

  • Also, it appears the latest comments aren't showing up in the "Overview" tab either for users with the Admin permissions bit set. Perhaps this calls the same printLatestComments() function.
  • acrylian Administrator
    Are you sure the items you want the comments from are not protected and also published? Note inheritance from parent items. Be also sure that the static html cache is cleared otherwise normal users will see the older cached version without the comments.

    Otherwise I cannpt reproduce this.
  • I appreciate the response. My cache_html folder is empty.

    `

    user@domain:/var/www/gallery/cache_html$ ls -l *

    albums:

    total 0

    images:

    total 0

    pages:

    total 0

    rss:

    total 0

    `

    I setup the permissions for "Options -> Gallery -> Gallery Type" set to "Private".

    I'd like to take a look at an album comment with you if you don't mind (image comments are broke in the same way). Album permissions appear to be alright, and the best way I can show you is by taking a look at the DB itself.

    `

    mysql> select * from zp_albums where id in (663, 251, 18) \G

    *************************** 1. row ***************************

    id: 18

    parentid: NULL

    folder: Grandpa

    title: Grandpa

    desc:

    date: 2012-08-03 20:28:38

    updateddate: 2012-08-22 22:08:48

    location:

    show: 1

    closecomments: 0

    commentson: 1

    thumb: 1

    mtime: 1348140067

    sort_type:

    subalbum_sort_type:

    sort_order: NULL

    image_sortdirection: 0

    album_sortdirection: 0

    hitcounter: 38

    password:

    password_hint: NULL

    publishdate: 2012-08-03 20:28:38

    expiredate: NULL

    total_value: 0

    total_votes: 0

    used_ips: NULL

    custom_data:

    dynamic: 0

    search_params: NULL

    album_theme: NULL

    user: NULL

    rating: NULL

    rating_status: 3

    watermark:

    watermark_thumb:

    owner: Grandpa

    codeblock: a:0:{}

    *************************** 2. row ***************************

    id: 251

    parentid: 18

    folder: Grandpa/2012

    title: 2012

    desc: Photo's and videos taken in 2012.

    date: 2012-09-01 11:12:35

    updateddate: 2012-09-30 22:06:07

    location:

    show: 1

    closecomments: 0

    commentson: 1

    thumb: 1

    mtime: 1349377477

    sort_type:

    subalbum_sort_type:

    sort_order: NULL

    image_sortdirection: 0

    album_sortdirection: 0

    hitcounter: 0

    password:

    password_hint: NULL

    publishdate: 2012-09-01 11:12:35

    expiredate: NULL

    total_value: 0

    total_votes: 0

    used_ips: NULL

    custom_data:

    dynamic: 0

    search_params: NULL

    album_theme: NULL

    user: NULL

    rating: NULL

    rating_status: 3

    watermark:

    watermark_thumb:

    owner: NULL

    codeblock: a:0:{}

    *************************** 3. row ***************************

    id: 663

    parentid: 251

    folder: Grandpa/2012/Blessing

    title: Blessing

    desc:

    date: 2012-09-02 11:13:17

    updateddate: 2012-09-02 11:18:40

    location:

    show: 1

    closecomments: 0

    commentson: 1

    thumb: 1

    mtime: 1347824674

    sort_type:

    subalbum_sort_type:

    sort_order: NULL

    image_sortdirection: 0

    album_sortdirection: 0

    hitcounter: 1

    password:

    password_hint: NULL

    publishdate: 2012-09-02 11:13:17

    expiredate: NULL

    total_value: 0

    total_votes: 0

    used_ips: NULL

    custom_data:

    dynamic: 0

    search_params: NULL

    album_theme: NULL

    user: NULL

    rating: NULL

    rating_status: 3

    watermark:

    watermark_thumb:

    owner: NULL

    codeblock: a:0:{}

    3 rows in set (0.00 sec)

    mysql> select * from zp_comments where comment like 'Thanks so much for these pictures%'\G

    *************************** 1. row ***************************

    id: 16

    ownerid: 663

    name: Derek XXXXXXX

    email: derek@XXXXXXX.com

    website:

    date: 2012-09-16 19:17:01

    comment: Thanks so much for these pictures.

    inmoderation: 0

    type: albums

    IP: XXX.XXX.XXX.XXX

    private: 0

    anon: 0

    custom_data: NULL

    1 row in set (0.00 sec)

    `

    To my eye, everything appears to be setup correctly. Maybe there's something simple I'm missing.

    Maybe there's something going awry with getLatestComments function in template-functions.php (line 3060)? I see that there is a check to see if the logged in user does not have ADMIN_RIGHTS and within that check, it see if the album isMyItem(LIST_RIGHTS). Well, the album doesn't belong to me, so I wonder if that's where things are getting hung up. Anyways, continuing on...

    `

    function getLatestComments($number,$type="all",$itemID=0) {

    global $_zp_gallery;

    $passwordcheck1 = "";

    $passwordcheck2 = "";

    if (!zp_loggedin(ADMIN_RIGHTS)) {

    $rslt = query("SELECT * FROM " . prefix('albums'). " ORDER BY title");

    if ($rslt) {

    while ($albumcheck = db_fetch_assoc($rslt)) {

    $album = new Album(NULL, $albumcheck['folder']);

    if($album->isMyItem(LIST_RIGHTS) || !checkAlbumPassword($albumcheck['folder'])) {

    $albumpasswordcheck1= " AND i.albumid != ".$albumcheck['id'];

    $albumpasswordcheck2= " AND a.id != ".$albumcheck['id'];

    $passwordcheck1 = $passwordcheck1.$albumpasswordcheck1;

    $passwordcheck2 = $passwordcheck2.$albumpasswordcheck2;

    }

    }

    }

    }

    `

    I'm also noticing how we build the query conditionals ($whereAlbums):
    `

    case "all":

    $whereImages = " WHERE i.show = 1 AND c.ownerid = i.id AND i.albumid = a.id AND c.private = 0 AND c.inmoderation = 0 AND (c.type IN (".zp_image_types("'") ."))".$passwordcheck1;

    $whereAlbums = " WHERE a.show = 1 AND c.ownerid = a.id AND c.private = 0 AND c.inmoderation = 0 AND c.type = 'albums'".$passwordcheck2;

    break;

    `

    Looks like in order to view the comment for the example album above the following is required:
    zp_albums.show = 1
    zp_comments.ownerid = zp_albums.id
    zp_comments.private = 0
    zp_comments.inmoderation = 0
    zp_comments.type = albums

    I'm not actually sure what the $passwordcheck2 is doing to the query, but when I get rid of it, bad things happen (mysqld becomes unresponsive and my server crashes). :-)

    So, looking at my example, here's what I see:
    zp_albums.show = 1 (All albums in hierarchy are = 1, true)
    zp_comments.ownerid = zp_albums.id (663 = 663, true)
    zp_comments.private = 0 (true)
    zp_comments.inmoderation = 0 (true)
    zp_comments.type = albums (true)

    Seems like the query ought to be working. I'm gathering the query would look something like this after all variables have been evaluated:
    "SELECT c.id, i.title, i.filename, a.folder, a.title AS albumtitle, c.name, c.type, c.website,
    c.date, c.anon, c.comment FROM zp_comments AS c, zp_images AS i, zp_albums AS a
    WHERE a.show = 1 AND c.ownerid = a.id AND c.private = 0 AND c.inmoderation = 0 AND c.type = 'albums' AND a.id != 663
    ORDER BY c.id DESC LIMIT 10"

    Lengthy, I know. To reproduce:
    1.) Set gallery type to "Private"
    2.) Create 2 users (besides the admin account)
    3.) For each user, create a gallery in which they are the only owner. The permissions of each user should be reflect the following:
    `

    mysql> select id, user, rights, valid, 'group', prime_album, other_credentials from zp_administrators where user = 'Derek';

    +----+-------+-----------+-------+-------+-------------+-------------------+

    | id | user | rights | valid | group | prime_album | other_credentials |

    +----+-------+-----------+-------+-------+-------------+-------------------+

    | 8 | Derek | 271230957 | 1 | group | NULL | NULL |

    +----+-------+-----------+-------+-------+-------------+-------------------+

    `

    4.) Login as user1 and comment on a user2 album and image.
    5.) As user1, visit the admin Overview page.
    6.) Notice the comments are not showing up in the "Latest 10 Comments" section.

    I'm trying to think of anything else that might be causing an issue, but I can't. The actual folders on the filesystem have 777 permissions.

    Sorry so lengthy. Just trying to figure things out.

  • acrylian Administrator
    Generally on a normal site it is working without admin rights as you can see on my test site:
    http://zenphoto.maltem.de/

    That you have set your gallery to "private" is quite an important extra info!

    Lengthy, I know. To reproduce:
    1.) Set gallery type to "Private"
    2.) Create 2 users (besides the admin account)
    3.) For each user, create a gallery in which they are the only owner. The permissions of each user should be reflect the following:

    Nitpicking I know but in Zenphoto terms "gallery" refers to the whole site. We are talking about an "albums" here. Just to avoid confusion.
    So do the two users have manage and view rights only to their albums? In that case they of course cannot see the comments from others. They will need "view all" rights.
    zp_albums.show = 1
    zp_comments.ownerid = zp_albums.id
    zp_comments.private = 0
    zp_comments.inmoderation = 0
    zp_comments.type = albums

    This just means the album to get the comments from must be published and the comment not moderated and not marked as private.

    $password1 checks if the images are in any password protected album since an password protected album will also protect its subalbums and images. Since it is not noted for the subalbum in the database itself any parent dependency must be checked. Same with $password2 for the albums.
  • I appreciate the help. Continuing my adventure...

    That you have set your gallery to "private" is quite an important extra info!

    My apologies, I thought I made it clear in my first post that the gallery is password protected. Glad I mentioned it again.

    So do the two users have manage and view rights only to their albums? In that case they of course cannot see the comments from others. They will need "view all" rights.

    For my user "Derek", here is how my permissions are setup:

    Albums
    * View fullimage - ON
    * Access all - ON
    * View unpublished - OFF
    * Upload - ON
    * Manage all - OFF

    Gallery
    * View gallery - ON
    * View search - ON
    * Post comments - ON
    * Comments - OFF
    * Files - ON
    * Themes - OFF
    * Tags - ON

    General
    * Overview - ON
    * User - ON
    * Options - OFF
    * Admin - OFF (this is the one which will allow me to see comments)

    News
    * Access all - ON
    * Manage all - ON

    Pages
    * Access all - ON
    * Manage all - OFF

    Managed albums (1):
    Derek - Edit (ON) Upload (ON) View Unpublished (ON)

    (There are a dozen or so other albums here in which I do not have any checked, since this user is only supposed to 'view' them, but not 'manage' them).

    I assume these settings equate to '271230957' in zp_administrators.rights.

    I don't see any permission bit for "view all" rights, but the closest thing that I see is "Access all", which is enabled.

    Does this sound like it's "working as designed"? If so, I guess I'll need to find another way to create a 'members only' gallery through hacking .htaccess or something (not fun!).
  • For the fun of it, I set the gallery to be "Public". When I log out and visit the main homepage, I do see the latest comments okay. When I login under the user "Derek", the comments stop showing up (I can still see the comments on the album/image pages themselves). Maybe I'm misunderstanding what the permissions bits are actually controlling and/or I have something configured wrong?

    Edit: More playing... I set my gallery to be "Private" again. I logged out so that I get the login page. I can even see the comments on the login page without being logged in as anybody! Clear, plain view for anyone with the URL to see. That's actually another problem I'll need to deal with in the template I believe... anyways, I login again and comments are gone just like before.
  • acrylian Administrator
    "Access all" is the one named formerly "view all" I think. I have no time to try all this at the moment and my colleague who is the expert on the user guide stuff is currently only occasionally available. But maybe he will respond later.

    Best you create a ticket meanwhile so this doesn't get lost. Point to this topic from there.
  • Sounds good. I sure appreciate the help. I created a ticket here:
    http://www.zenphoto.org/trac/ticket/2256
  • I've just updated my installation to 1.4.4.1b and have now lost the "printlatestComments" function in both the gallery itself and in the main site (where I use Zenphoto as a "plug in").

    Further examination reveals a problem similar to the one described in this topic.

    The Gallery is an open gallery, the only user defined being myself as administrator. The gallery can be found at http://royal-signals.org.uk/zenphoto/

    If I set the Gallery to be "Private" or "Restricted" and log in using the administrator username and password then I can see the latest comments when viewing the Gallery (but not the main site).

    If I reset the gallery to be public then the latest comments once again disappear from the gallery itself.

    I searched Github and note that the original bug was reported fixed.

    Any help would be gratefully received.

    Michael

    Current config:

    Zenphoto version 1.4.4.1 [596740f651] (Official build)
    Current locale setting: en_US.UTF8
    Server path: /home/xxxxxx/public_html/zenphoto
    WEB path: /zenphoto
    Current gallery theme: rsigs
    PHP version: 5.3.18
    Graphics support: PHP GD library bundled (2.0.34 compatible)
    supporting: gif, jpg, jpeg, png, bmp
    PHP memory limit: 96M (Note: Your server might allocate less!)
    MySQL version: 5.1.68
    Database name: xxxxxxxxxx
    Table prefix: zp_
    Spam filter: simpleSpam
    CAPTCHA generator: zpCaptcha
    Site status: The site is opened
  • acrylian Administrator
    If you use a custom theme try with an official one (you might need to add the function to it yourself). Also look at the error logs of Zenphoto and the server. Make sure that the images/items that have been commented are published.
  • I have reverted to Zenphoto version 1.4.3.5 [11059] (Official build) on my live site and the printLatestImages function is working again on both the Gallery and the main site where Zenphoto is being used as a "plug in".

    I uploaded the 1.4.4.1 [596740f651] (Official build)onto a development site and the problem reappeared (the development site had been running 1.4.3.5 and printLatestImages was working fine).

    I did as you suggested and selected the official "Zenpage" theme (upon which my modified theme is based) and added the function to it as follows:

    `</p>
    <p> <h3><?php // print latest comments
    echo gettext("Latest Comments"); ?></h3></p>

    <?php
    printLatestComments(25,'50', 'all', '');
    ?>

    <p>`
    The latest comments are still not being shown either on the Gallery pages or the main website. They are, however, shown on both if I am logged in as "administrator".

    The error logs don't show any failures.

    Thank you for your response.

    Michael
  • You should file an issue report on this so it may be tracked.
  • This has been resolved by fix #239

    Many thanks for the speedy response and fix.

    Michael
  • Thanks for the confirmation. Sorry about the original problem.
  • Hello,
    I'm using Zenphoto 1.4.4.1b and zpFocus 1.4.4.
    I had this same issue, so I applied the fix #239. Now the comments are there, but the function I use is '<?php printLatestComments( 3,'100'); ?>' and all the comments (oldest to newest) are listed now, instead of the 3 latest. Do I need to update something in my theme because of the fix #239?
    Thank-you! Renee
  • You probably grabbed the update too soon. You need bf2e07e8cfd9b0d81bb0a7481153838529a2b696
  • Thank-you. That was the fix! Renee
Sign In or Register to comment.