From ff1dc9edad76b265992b34b67b171704ff42bbf4 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Sun, 5 Oct 2003 13:21:44 +0000 Subject: Always displays last comments, not only when choosing a number of days (-> use the default) git-svn-id: http://piwigo.org/svn/trunk@179 68402e56-0260-453c-a942-63ccdbb3a9ee --- comments.php | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/comments.php b/comments.php index b4802ace0..f6c51e034 100644 --- a/comments.php +++ b/comments.php @@ -141,33 +141,30 @@ foreach ( $conf['last_days'] as $option ) { $vtp->closeSession( $handle, 'last_day_option' ); } $vtp->setVar( $handle, 'back_url', add_session_id( './category.php' ) ); -if ( isset( $_GET['last_days'] ) ) +// 1. retrieving picture ids which have comments recently added +$date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) ); +list($year,$month,$day) = explode( '-', $date); +$maxtime = mktime( 0,0,0,$month,$day,$year ); +$query = 'SELECT DISTINCT(ic.image_id) as image_id'; +$query.= ' FROM '.PREFIX_TABLE.'comments AS c'; +$query.= ', '.PREFIX_TABLE.'image_category AS ic'; +$query.= ' WHERE c.image_id = ic.image_id'; +$query.= ' AND date > '.$maxtime; +// we must not show pictures of a forbidden category +$restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); +if ( count( $restricted_cats ) > 0 ) { - // 1. retrieving picture ids which have comments recently added - $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) ); - list($year,$month,$day) = explode( '-', $date); - $maxtime = mktime( 0,0,0,$month,$day,$year ); - $query = 'SELECT DISTINCT(ic.image_id) as image_id'; - $query.= ' FROM '.PREFIX_TABLE.'comments AS c'; - $query.= ', '.PREFIX_TABLE.'image_category AS ic'; - $query.= ' WHERE c.image_id = ic.image_id'; - $query.= ' AND date > '.$maxtime; - // we must not show pictures of a forbidden category - $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); - if ( count( $restricted_cats ) > 0 ) - { - $query.= ' AND category_id NOT IN ('; - foreach ( $restricted_cats as $i => $restricted_cat ) { - if ( $i > 0 ) $query.= ','; - $query.= $restricted_cat; - } - $query.= ')'; + $query.= ' AND category_id NOT IN ('; + foreach ( $restricted_cats as $i => $restricted_cat ) { + if ( $i > 0 ) $query.= ','; + $query.= $restricted_cat; } - $query.= ' ORDER BY ic.image_id DESC'; - $query.= ';'; - $result = mysql_query( $query ); - display_pictures( $result, $maxtime, $restricted_cats ); + $query.= ')'; } +$query.= ' ORDER BY ic.image_id DESC'; +$query.= ';'; +$result = mysql_query( $query ); +display_pictures( $result, $maxtime, $restricted_cats ); //----------------------------------------------------------- html code display $code = $vtp->Display( $handle, 0 ); echo $code; -- cgit v1.2.3