Horde_Share::listShares() returns a hash keyed by name, not id.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 23 Jan 2011 18:15:30 +0000 (13:15 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 23 Jan 2011 18:26:27 +0000 (13:26 -0500)
ansel/lib/Api.php
ansel/lib/Gallery.php
ansel/lib/GalleryMode/Date.php
ansel/scripts/ansel.php
framework/Share/lib/Horde/Share/Sql.php

index e1f1dab..6f33e0e 100644 (file)
@@ -98,8 +98,8 @@ class Ansel_Api extends Horde_Registry_Api
             }
 
             $results = array();
-            foreach ($galleries as $galleryId => $gallery) {
-                $retpath = 'ansel/' . implode('/', $parts) . '/' . $galleryId;
+            foreach ($galleries as $gallery) {
+                $retpath = 'ansel/' . implode('/', $parts) . '/' . $gallery->getId();
                 if (in_array('name', $properties)) {
                     $results[$retpath]['name'] = $gallery->data['attribute_name'];
                 }
@@ -686,7 +686,7 @@ class Ansel_Api extends Horde_Registry_Api
             ->listGalleries($params);
         $return = array();
         foreach ($galleries as $gallery) {
-            $return[$gallery->id] = array_merge($gallery->data,
+            $return[$gallery->getId()] = array_merge($gallery->data,
                                                 array('crumbs' => $gallery->getGalleryCrumbData()));
         }
 
@@ -788,9 +788,8 @@ class Ansel_Api extends Horde_Registry_Api
             if (!count($galleries)) {
                 return array();
             }
-            $keys = array_keys($galleries);
-            $gallery_names = array_keys($galleries[$keys[0]]['galleries']);
-            $gallery_id = $gallery_names[0];
+            $g = current($galleries);
+            $gallery_id = $g->getId();
         } elseif (!empty($slug)) {
             $gallery = $storage->getGalleryBySlug($slug);
         } else {
index 79fdda2..b4ffdd2 100644 (file)
@@ -676,7 +676,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql implements Serializable
                         ->getInstance('Ansel_Storage')
                         ->listGalleries(array('parent' => $this, 'all_levels' => false));
 
-                    foreach ($galleries as $galleryId => $gallery) {
+                    foreach ($galleries as $gallery) {
                         if ($default_img = $gallery->getKeyImage($style)) {
                             return $default_img;
                         }
index 725d840..90c8129 100644 (file)
@@ -612,7 +612,9 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base
             $subs = $GLOBALS['injector']
                 ->getInstance('Ansel_Storage')
                 ->listGalleries(array('parent' => $this->_gallery));
-            $this->_subGalleries = array_keys($subs);
+            foreach ($subs as $sub) {
+                $this->_subGalleries[] = $sub->getId();
+            }
         }
     }
 }
index ee8c2b9..e207a52 100755 (executable)
@@ -193,8 +193,9 @@ if (!empty($list)) {
         $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries();
         $cli->message(_("Listing Gallery/Name"), 'cli.success');
         $cli->writeln();
-        foreach ($galleries as $id => $gallery) {
+        foreach ($galleries as $gallery) {
             $name = $gallery->get('name');
+            $id = $gallery->getId();
             $msg = "$id/$name";
             $cli->writeln($msg);
             Horde::logMessage($msg, 'DEBUG');
index 866cabf..4751a83 100644 (file)
@@ -363,9 +363,9 @@ class Horde_Share_Sql extends Horde_Share_Base
                                     'all_levels' => true),
                               $params);
         $key = md5(serialize(array($userid, $params)));
-        if (!empty($this->_listcache[$key])) {
-            return $this->_listcache[$key];
-        }
+        //if (!empty($this->_listcache[$key])) {
+        //    return $this->_listcache[$key];
+        //}
         $shares = array();
         if (is_null($params['sort_by'])) {
             $sortfield = 's.share_id';
@@ -431,7 +431,7 @@ class Horde_Share_Sql extends Horde_Share_Base
         $sharelist = array();
         foreach ($shares as $id => $data) {
             $this->_getSharePerms($data);
-            $sharelist[$id] = $this->_createObject($data);
+            $sharelist[$data['share_name']] = $this->_createObject($data);
         }
         unset($shares);