[pLog-svn] r3079 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Mar 17 17:53:13 GMT 2006
Author: oscar
Date: 2006-03-17 17:53:12 +0000 (Fri, 17 Mar 2006)
New Revision: 3079
Modified:
plog/trunk/class/dao/blogcategories.class.php
plog/trunk/class/dao/blogs.class.php
Log:
This should fix the problems with blog categories.
Modified: plog/trunk/class/dao/blogcategories.class.php
===================================================================
--- plog/trunk/class/dao/blogcategories.class.php 2006-03-17 13:29:08 UTC (rev 3078)
+++ plog/trunk/class/dao/blogcategories.class.php 2006-03-17 17:53:12 UTC (rev 3079)
@@ -68,7 +68,12 @@
*/
function updateBlogCategory( $category )
{
- return( $this->update( $category ));
+ if( ($result = $this->update( $category ))) {
+ $this->_cache->removeData( $category->getId(), CACHE_BLOGCATEGORIES );
+ $this->_cache->removeData( "_all_", CACHE_BLOGCATEGORIES_ALL );
+ }
+
+ return( $result );
}
/**
Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php 2006-03-17 13:29:08 UTC (rev 3078)
+++ plog/trunk/class/dao/blogs.class.php 2006-03-17 17:53:12 UTC (rev 3079)
@@ -67,30 +67,22 @@
// reset the caches
$this->_cache->removeData( $blog->getMangledBlogName(), CACHE_BLOGIDBYNAME );
$this->_cache->removeData( $blog->getId(), CACHE_BLOGINFOS );
- // and update the blog category counters if necessary
- if( $prevVersion->getBlogCategoryId() != $blog->getBlogCategoryId()) {
- // remove one item from the old category
- $oldCategory = $prevVersion->getBlogCategory();
- if( $oldCategory ) {
- if( $prevVersion->getStatus() == BLOG_STATUS_ACTIVE )
- $oldCategory->setNumActiveBlogs( $oldCategory->getNumActiveBlogs() - 1 );
- elseif( $prevVersion->getStatus() == BLOG_STATUS_DISABLED )
- $oldCategory->setNumBlogs( $oldCategory->getNumBlogs() + 1 );
- }
-
- // add one item to the new one
- $newCategory = $blog->getBlogCategory();
- if( $newCategory ) {
- if( $blog->getStatus() == BLOG_STATUS_ACTIVE )
- $newCategory->setNumActiveBlogs( $newCategory->getNumActiveBlogs() - 1 );
- elseif( $blog->getStatus() == BLOG_STATUS_DISABLED )
- $newCategory->setNumBlogs( $newCategory->getNumBlogs() + 1 );
- }
-
- // finally, update the categories
- include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
- $blogCategories = new BlogCategories();
- $blogCategories->updateBlogCategory( $oldCategory );
+
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
+ $blogCategories = new BlogCategories();
+
+ // old category
+ $oldCategory = $prevVersion->getBlogCategory();
+ if( $oldCategory ) {
+ $oldCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
+ $oldCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldCategory->getId()));
+ $blogCategories->updateBlogCategory( $oldCategory );
+ }
+ // new category
+ $newCategory = $blog->getBlogCategory();
+ if( $newCategory ) {
+ $newCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$newCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
+ $newCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$newCategory->getId()));
$blogCategories->updateBlogCategory( $newCategory );
}
}
More information about the pLog-svn
mailing list