[pLog-svn] r3051 - plog/trunk/class/gallery/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Mar 12 17:40:04 GMT 2006
Author: oscar
Date: 2006-03-12 17:40:04 +0000 (Sun, 12 Mar 2006)
New Revision: 3051
Modified:
plog/trunk/class/gallery/dao/galleryalbums.class.php
Log:
fixed another important notice message
Modified: plog/trunk/class/gallery/dao/galleryalbums.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryalbums.class.php 2006-03-12 17:39:44 UTC (rev 3050)
+++ plog/trunk/class/gallery/dao/galleryalbums.class.php 2006-03-12 17:40:04 UTC (rev 3051)
@@ -4,9 +4,13 @@
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbum.class.php" );
include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+ //
+ // cache constants
+ //
define( "CACHE_USERALBUMS_NESTED", "useralbums_nested" );
define( "CACHE_USERALBUMS", "useralbums" );
define( "CACHE_GALLERYALBUM", "album" );
+ define( "CACHE_GALLERYALBUMBYNAME", "album_byname" );
/**
* \ingroup Gallery
@@ -96,7 +100,7 @@
*/
function getAlbum( $id, $ownerId = -1, $fetchResources = true, $onlyShownAlbums = false )
{
- $album = $this->get( "id", $id, CACHE_GALLERYALBUM, Array( CACHE_GALLERYALBUMBYNAME => "getMangledName" ));
+ $album = $this->get( "id", $id, CACHE_GALLERYALBUM );
if( !$album )
return false;
if( $ownerId > -1 && $album->getOwnerId() != $ownerId )
@@ -126,16 +130,32 @@
*/
function getAlbumByName( $id, $ownerId = -1, $fetchResources = true, $onlyShownAlbums = false )
{
- $album = $this->get( "mangled_name", $id, CACHE_GALLERYALBUMBYNAME, Array( CACHE_GALLERYALBUM => "getId" ));
- if( !$album )
- return false;
- if( $ownerId > -1 && $album->getOwnerId() != $ownerId )
- return false;
- if( $onlyShownAlbums && !$album->getShowAlbum())
- return false;
-
+ // there might be more than one with the same name...
+ $albums = $this->getMany( "mangled_name", $id, CACHE_GALLERYALBUMBYNAME );
+ $found = false;
+ foreach( $albums as $album ) {
+ if( $this->check( $album, $ownerId, $onlyShownAlbums )) {
+ $found = true;
+ break;
+ }
+ }
+
return( $album );
}
+
+ /**
+ * @private
+ */
+ function check( $album, $ownerId = -1, $onlyShownAlbums = false )
+ {
+ if( $ownerId > -1 && $album->getOwnerId() != $ownerId )
+ return false;
+ if( $onlyShownAlbums && !$album->getShowAlbum())
+ return false;
+
+ return( true );
+ }
+
/**
* Returns an array with all the child albums of the given album, but only
More information about the pLog-svn
mailing list