diff options
author | mistic100 <mistic@piwigo.org> | 2012-01-15 17:05:30 +0000 |
---|---|---|
committer | mistic100 <mistic@piwigo.org> | 2012-01-15 17:05:30 +0000 |
commit | e673454e05e910de3553103d6f41695c5388ffbc (patch) | |
tree | bfb6422e059cc0f26da227951d0ef74fafccb06d /include | |
parent | 24eafada3e6f0b8ee27a4088ed50c35e0cad15ed (diff) |
feaure:2379 option to display user comments sorted new>old instead of old>new
git-svn-id: http://piwigo.org/svn/trunk@12894 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/picture_comment.inc.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php index 70e2c7e95..b35bf2285 100644 --- a/include/picture_comment.inc.php +++ b/include/picture_comment.inc.php @@ -125,6 +125,32 @@ SELECT if ($row['nb_comments'] > 0) { + // comments order (get, session, conf) + if (!empty($_GET['comments_order'])) + { + if (in_array(strtoupper($_GET['comments_order']), array('ASC', 'DESC'))) + { + $comments_order = $_GET['comments_order']; + pwg_set_session_var('comments_order', $comments_order); + } + else + { + $comments_order = $conf['comments_order']; + } + } + else if (pwg_get_session_var('comments_order') !== null) + { + $comments_order = pwg_get_session_var('comments_order'); + } + else + { + $comments_order = $conf['comments_order']; + } + $template->assign(array( + 'COMMENTS_ORDER_URL' => duplicate_picture_url().'&comments_order='.($comments_order == 'ASC' ? 'DESC' : 'ASC'), + 'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('ascending') : l10n('descending'), + )); + $query = ' SELECT com.id, @@ -140,7 +166,7 @@ SELECT ON u.'.$conf['user_fields']['id'].' = author_id WHERE image_id = '.$page['image_id'].' '.$validated_clause.' - ORDER BY date ASC + ORDER BY date '.$comments_order.' LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start'].' ;'; $result = pwg_query( $query ); |