From 6611ca548eed54329a24eb3a352cc4aed198c705 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 29 Mar 2006 13:48:51 +0000 Subject: [PATCH] Fix problems with multiple image resuilts when using access lists --- docs/NEWS | 3 +++ include/functions_images.inc.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/NEWS b/docs/NEWS index a3e34cd..7a131cf 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.1-alpha1() ------------------------------------------------------------------------ + * Fix getting multiple images for directories that were put into + the Acccess List (garvinhicking) + * Allow to create new groups from existing ones, by editing them and clicking on "Create new group". (garvinhicking) diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php index 37e9479..e33affa 100644 --- a/include/functions_images.inc.php +++ b/include/functions_images.inc.php @@ -76,6 +76,14 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order ); serendipity_ACL_SQL($cond, false, 'directory'); + if ($serendipity['dbType'] == 'postgres') { + $cond['group'] = ''; + $cond['distinct'] = 'DISTINCT'; + } else { + $cond['group'] = 'GROUP BY i.id'; + $cond['distinct'] = ''; + } + $basequery = "FROM {$serendipity['dbPrefix']}images AS i LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a ON i.authorid = a.authorid @@ -83,12 +91,14 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order {$cond['and']}"; - $query = "SELECT i.*, + $query = "SELECT {$cond['distinct']} i.id, i.name, i.extension, i.mime, i.size, i.dimensions_width, i.dimensions_height, i.date, i.thumbnail_name, i.authorid, i.path, i.hotlink, a.realname AS authorname $basequery + {$cond['group']} ORDER BY $order $ordermode $limitsql"; $rs = serendipity_db_query($query, false, 'assoc'); + if (!is_array($rs)) { return array(); } -- 2.39.5