One more place we need ids instead of names.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 23 Jan 2011 18:42:47 +0000 (13:42 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 23 Jan 2011 18:43:52 +0000 (13:43 -0500)
Add a utility function to act as callback to array_map, still need
to audit code for all places to use it.

ansel/lib/Ansel.php
ansel/lib/Storage.php

index 1fff82b..953f488 100644 (file)
@@ -52,6 +52,11 @@ class Ansel
         return $mdb;
     }
 
+    static public function keysFromNames($gallery)
+    {
+        return $gallery->getId();
+    }
+
     /**
      * Return a string containing an <option> listing of the given
      * gallery array.
index 574fde1..093da9a 100644 (file)
@@ -1012,8 +1012,8 @@ class Ansel_Storage
         if (empty($galleries)) {
             return array();
         }
-
-        $where = 'gallery_id IN(' . implode(',', array_keys($galleries)) . ') AND LENGTH(image_latitude) > 0 GROUP BY image_latitude, image_longitude';
+        $ids = array_map(array('Ansel', 'keysFromNames'), $galleries);
+        $where = 'gallery_id IN(' . implode(',', $ids) . ') 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');
     }