From dd843c78230c95fb44b95239e3d440f50be3506e Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 4 Apr 2010 22:50:12 +0000 Subject: bug 1579: admins should see all user comments on picture.php, validated or not. git-svn-id: http://piwigo.org/svn/trunk@5654 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/picture_comment.inc.php | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'include/picture_comment.inc.php') diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php index 2f0198b22..ac0cd9356 100644 --- a/include/picture_comment.inc.php +++ b/include/picture_comment.inc.php @@ -88,11 +88,23 @@ elseif ( isset($_POST['content']) ) if ($page['show_comments']) { + if ( !is_admin() ) + { + $validated_clause = ' AND validated = \'true\''; + } + else + { + $validated_clause = ''; + } + // number of comments for this picture $query = ' -SELECT COUNT(*) AS nb_comments +SELECT + COUNT(*) AS nb_comments FROM '.COMMENTS_TABLE.' - WHERE image_id='.$page['image_id']." AND validated = 'true'"; + WHERE image_id = '.$page['image_id'] + .$validated_clause.' +;'; $row = pwg_db_fetch_assoc( pwg_query( $query ) ); // navigation bar creation @@ -118,23 +130,21 @@ SELECT COUNT(*) AS nb_comments if ($row['nb_comments'] > 0) { - if ( !is_admin() ) - { - $validated_clause = ' AND validated = \'true\''; - } - else - { - $validated_clause = ''; - } - $query = ' -SELECT com.id,author,author_id,'.$conf['user_fields']['username'].' AS username, - date,image_id,content,validated +SELECT + com.id, + author, + author_id, + '.$conf['user_fields']['username'].' AS username, + date, + image_id, + content, + validated FROM '.COMMENTS_TABLE.' AS com LEFT JOIN '.USERS_TABLE.' AS u ON u.'.$conf['user_fields']['id'].' = author_id - WHERE image_id = '.$page['image_id']. -$validated_clause.' + WHERE image_id = '.$page['image_id'].' + '.$validated_clause.' ORDER BY date ASC LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start'].' ;'; -- cgit v1.2.3