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
Otherwise I cannpt reproduce this.
`
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.
http://zenphoto.maltem.de/
That you have set your gallery to "private" is quite an important extra info!
Lengthy, I know. To reproduce: 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. 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.
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!).
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.
Best you create a ticket meanwhile so this doesn't get lost. Point to this topic from there.
http://www.zenphoto.org/trac/ticket/2256
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
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
Many thanks for the speedy response and fix.
Michael
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