From d1a7bad37782b0becd67b4dbd83b3aa1b4a58dad Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 29 Nov 2009 00:20:09 -0500 Subject: [PATCH] Bug: #8732 Author: duck@obala.net - Horde_Perms::EDIT is a constant not a string - stop if there is no galleries otherwise listImages returns an sql error ( notihing in IN() ) - in listImages use the $sql variable --- ansel/lib/Storage.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 0ea75d932..274331305 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -962,8 +962,7 @@ class Ansel_Storage $this->_db->setLimit($count, $from); $sql = 'SELECT ' . $fields . ' FROM ansel_images ' . $query_where . ' ORDER BY ' . $sort; Horde::logMessage('Query by Ansel_Storage::listImages: ' . $sql, __FILE__, __LINE__, PEAR_LOG_DEBUG); - $results = $this->_db->query('SELECT ' . $fields . ' FROM ansel_images ' - . $query_where . ' ORDER BY ' . $sort); + $results = $this->_db->query($sql); if ($results instanceof PEAR_Error) { throw new Horde_Exception($results->getMessage()); } @@ -1026,7 +1025,11 @@ class Ansel_Storage */ public function getRecentImagesGeodata($user = null, $start = 0, $count = 8) { - $galleries = $this->listGalleries('Horde_Perms::EDIT', $user); + $galleries = $this->listGalleries(Horde_Perms::EDIT, $user); + if (empty($galleries)) { + return array(); + } + $where = 'gallery_id IN(' . implode(',', array_keys($galleries)) . ') AND LENGTH(image_latitude) > 0 GROUP BY image_latitude, image_longitude'; return $this->listImages(0, $start, $count, array('image_id as id', 'image_id', 'gallery_id', 'image_latitude', 'image_longitude', 'image_location'), $where, 'image_geotag_date DESC'); } -- 2.11.0