Changeset 5654


Ignore:
Timestamp:
Apr 5, 2010, 12:50:12 AM (10 years ago)
Author:
plg
Message:

bug 1579: admins should see all user comments on picture.php, validated or not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/picture_comment.inc.php

    r5649 r5654  
    8989if ($page['show_comments'])
    9090{
     91  if ( !is_admin() )
     92  {
     93    $validated_clause = '  AND validated = \'true\'';
     94  }
     95  else
     96  {
     97    $validated_clause = '';
     98  }
     99
    91100  // number of comments for this picture
    92101  $query = '
    93 SELECT COUNT(*) AS nb_comments
     102SELECT
     103    COUNT(*) AS nb_comments
    94104  FROM '.COMMENTS_TABLE.'
    95   WHERE image_id='.$page['image_id']." AND validated = 'true'";
     105  WHERE image_id = '.$page['image_id']
     106  .$validated_clause.'
     107;';
    96108  $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    97109
     
    119131  if ($row['nb_comments'] > 0)
    120132  {
    121     if ( !is_admin() )
    122     {
    123       $validated_clause = '  AND validated = \'true\'';
    124     }
    125     else
    126     {
    127       $validated_clause = '';
    128     }
    129 
    130133    $query = '
    131 SELECT com.id,author,author_id,'.$conf['user_fields']['username'].' AS username,
    132   date,image_id,content,validated
     134SELECT
     135    com.id,
     136    author,
     137    author_id,
     138    '.$conf['user_fields']['username'].' AS username,
     139    date,
     140    image_id,
     141    content,
     142    validated
    133143  FROM '.COMMENTS_TABLE.' AS com
    134144  LEFT JOIN '.USERS_TABLE.' AS u
    135145    ON u.'.$conf['user_fields']['id'].' = author_id
    136   WHERE image_id = '.$page['image_id'].
    137 $validated_clause.'
     146  WHERE image_id = '.$page['image_id'].'
     147    '.$validated_clause.'
    138148  ORDER BY date ASC
    139149  LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start'].'
Note: See TracChangeset for help on using the changeset viewer.