From: Michael J. Rubinsky Date: Sun, 23 Jan 2011 18:15:30 +0000 (-0500) Subject: Horde_Share::listShares() returns a hash keyed by name, not id. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8a8679dd557a358533e3cf64974cae54f9b61c33;p=horde.git Horde_Share::listShares() returns a hash keyed by name, not id. --- diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index e1f1dab9a..6f33e0ee2 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -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 { diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 79fdda2a3..b4ffdd2df 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -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; } diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 725d840c5..90c8129a1 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -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(); + } } } } diff --git a/ansel/scripts/ansel.php b/ansel/scripts/ansel.php index ee8c2b987..e207a52f4 100755 --- a/ansel/scripts/ansel.php +++ b/ansel/scripts/ansel.php @@ -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'); diff --git a/framework/Share/lib/Horde/Share/Sql.php b/framework/Share/lib/Horde/Share/Sql.php index 866cabfd3..4751a832f 100644 --- a/framework/Share/lib/Horde/Share/Sql.php +++ b/framework/Share/lib/Horde/Share/Sql.php @@ -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);