[pLog-svn] r2502 - plog/trunk/class/gallery/dao

oscar at devel.plogworld.net oscar at devel.plogworld.net
Tue Sep 20 19:17:02 GMT 2005


Author: oscar
Date: 2005-09-20 19:17:02 +0000 (Tue, 20 Sep 2005)
New Revision: 2502

Modified:
   plog/trunk/class/gallery/dao/galleryalbums.class.php
Log:
this should take care of keeping the counters in album updated


Modified: plog/trunk/class/gallery/dao/galleryalbums.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryalbums.class.php	2005-09-20 19:07:47 UTC (rev 2501)
+++ plog/trunk/class/gallery/dao/galleryalbums.class.php	2005-09-20 19:17:02 UTC (rev 2502)
@@ -196,12 +196,30 @@
 				return false;
 			}
 			
+			// load the previous version of this album
+			$prevVersion = $this->getAlbum( $album->getId());			
+			
 			$result = $this->update( $album );
 			if( $result ) {
 	            // remove the album from the cache
     	        $this->_cache->removeData( $album->getId(), CACHE_GALLERYALBUM );
-        	    // and remove the cached album hierarchy array
+        	    // remove the cached album hierarchy array
             	$this->_cache->removeData( $album->getOwnerId(), CACHE_USERALBUMS );			
+				// and the cache for nested albums too
+				$this->_cache->removeData( $album->getOwnerId(), CACHE_USERALBUMS_NESTED );
+				
+				// update the counters of the parent album
+				if( $prevVersion->getParentId() != $album->getParentId()) {
+					// increase the counter of the new album
+					$parent = $album->getParent();
+					$parent->setNumChildren( $parent->getNumChildren() + 1 );
+					// decrease the number of children in the previous parent
+					$prevParent = $prevVersion->getParent();
+					$prevParent->setNumChildren( $prevParent->getNumChildren() - 1 );
+					// update the objects
+					$this->updateAlbum( $parent );
+					$this->updateAlbum( $prevParent );
+				}
 			}			
 
             return( $result );




More information about the pLog-svn mailing list