[pLog-svn] r3908 - plog/trunk/class/dao
mark at devel.lifetype.net
mark at devel.lifetype.net
Wed Aug 23 17:12:18 GMT 2006
Author: mark
Date: 2006-08-23 17:12:15 +0000 (Wed, 23 Aug 2006)
New Revision: 3908
Modified:
plog/trunk/class/dao/articles.class.php
Log:
Fixed a bug of blog post count. We need to write a script to update the counter in previous installation. :(
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-08-23 08:24:17 UTC (rev 3907)
+++ plog/trunk/class/dao/articles.class.php 2006-08-23 17:12:15 UTC (rev 3908)
@@ -971,6 +971,19 @@
return false;
}
+ // update the blog counter
+ if( $oldArticle->getStatus() == POST_STATUS_PUBLISHED && $article->getStatus() != POST_STATUS_PUBLISHED ) {
+ $blogs = new Blogs();
+ $blogInfo = $article->getBlogInfo();
+ $blogInfo->setTotalPosts( $blogInfo->getTotalPosts() - 1 );
+ $blogs->updateBlog( $blogInfo );
+ } elseif ( $oldArticle->getStatus() != POST_STATUS_PUBLISHED && $article->getStatus() == POST_STATUS_PUBLISHED ) {
+ $blogs = new Blogs();
+ $blogInfo = $article->getBlogInfo();
+ $blogInfo->setTotalPosts( $blogInfo->getTotalPosts() + 1 );
+ $blogs->updateBlog( $blogInfo );
+ }
+
// clean up the cache
include_once( PLOG_CLASS_PATH."class/dao/recentarticles.class.php" );
RecentArticles::resetRecentArticlesCache( $article->getBlogId());
@@ -1132,18 +1145,18 @@
$this->_cache->removeData( $artId, CACHE_ARTICLES );
}
else {
+ // update the blog counters
+ if( $article->getStatus() == POST_STATUS_PUBLISHED ) {
+ $blogs = new Blogs();
+ $blogInfo = $article->getBlogInfo();
+ $blogInfo->setTotalPosts( $blogInfo->getTotalPosts() - 1 );
+ $blogs->updateBlog( $blogInfo );
+ }
+
$article->setStatus( POST_STATUS_DELETED );
$this->updateArticle( $article );
}
- // update the blog counters
- if( $article->getStatus() == POST_STATUS_PUBLISHED ) {
- $blogs = new Blogs();
- $blogInfo = $article->getBlogInfo();
- $blogInfo->setTotalPosts( $blogInfo->getTotalPosts() - 1 );
- $blogs->updateBlog( $blogInfo );
- }
-
return true;
}
More information about the pLog-svn
mailing list