[pLog-svn] r3087 - in plog/trunk/class: action/admin dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Mar 19 22:14:56 GMT 2006
Author: oscar
Date: 2006-03-19 22:14:56 +0000 (Sun, 19 Mar 2006)
New Revision: 3087
Modified:
plog/trunk/class/action/admin/adminupdatepostaction.class.php
plog/trunk/class/dao/article.class.php
plog/trunk/class/dao/articles.class.php
plog/trunk/class/dao/globalarticlecategory.class.php
Log:
article categories were not being properly updated
Modified: plog/trunk/class/action/admin/adminupdatepostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatepostaction.class.php 2006-03-19 22:13:53 UTC (rev 3086)
+++ plog/trunk/class/action/admin/adminupdatepostaction.class.php 2006-03-19 22:14:56 UTC (rev 3087)
@@ -87,17 +87,18 @@
return false;
}
- // if we got it, update some fields
- $post->setTopic( stripslashes($this->_postTopic));
- $postText = $this->_postText.POST_EXTENDED_TEXT_MODIFIER.$this->_postExtendedText;
- $post->setText( stripslashes($postText));
- $post->setTopic( $this->_postTopic );
- $post->setText( $postText );
+ // if we got it, update some fields
+ $post->setTopic( stripslashes($this->_postTopic));
+ $postText = $this->_postText.POST_EXTENDED_TEXT_MODIFIER.$this->_postExtendedText;
+ $post->setText( stripslashes($postText));
+ $post->setTopic( $this->_postTopic );
+ $post->setText( $postText );
$post->setCategoryIds( $this->_postCategories );
$post->setStatus( $this->_postStatus );
$post->setDateObject( $this->_postTimestamp );
$post->setCommentsEnabled( $this->_commentsEnabled );
$post->setPostSlug( $this->_postSlug );
+ $post->setGlobalCategoryId( $this->_globalArticleCategoryId );
// prepare the custom fields
$fields = Array();
Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php 2006-03-19 22:13:53 UTC (rev 3086)
+++ plog/trunk/class/dao/article.class.php 2006-03-19 22:14:56 UTC (rev 3087)
@@ -1065,7 +1065,7 @@
if( $this->_globalCategory == null ) {
include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
$globalCategories = new GlobalArticleCategories();
- $this->_globalCategory = $globalCategories->getCategory( $this->_globalCategoryId );
+ $this->_globalCategory = $globalCategories->getGlobalArticleCategory( $this->_globalCategoryId );
}
return( $this->_globalCategory );
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-03-19 22:13:53 UTC (rev 3086)
+++ plog/trunk/class/dao/articles.class.php 2006-03-19 22:14:56 UTC (rev 3087)
@@ -733,6 +733,30 @@
return $this->addPostCategoriesLink( $article );
}
+
+ /**
+ * Updates global article category counters
+ *
+ * @private
+ */
+ function updateGlobalArticleCategoriesLink( $article, $oldArticle = null )
+ {
+ include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+ $cats = new GlobalArticleCategories();
+ $artCategory = $article->getGlobalCategory();
+ $artCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()));
+ $artCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
+ $cats->updateGlobalArticleCategory( $artCategory );
+
+ if( $oldArticle ) {
+ $oldCategory = $oldArticle->getGlobalCategory();
+ $oldCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()));
+ $oldCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
+ $cats->updateGlobalArticleCategory( $oldCategory );
+ }
+
+ return( true );
+ }
/**
* Adds a new article to the database
@@ -755,6 +779,9 @@
// and create the link between the post and its categories
$this->addPostCategoriesLink( $newArticle );
+
+ // update global article categories
+ $this->updateGlobalArticleCategoriesLink( $newArticle );
// and save the custom fields
$customFields = new CustomFieldsValues();
@@ -888,14 +915,21 @@
// update the article text
$this->updateArticleText( $article );
+ // update categories
if( !$this->updatePostCategoriesLink( $article, $oldArticle )) {
return false;
}
+ // update custom fields
if( !$this->updateArticleCustomFields( $article->getId(), $article->getBlogId(),
$article->getCustomFields())) {
return false;
}
+
+ // update global article categories
+ if( !$this->updateGlobalArticleCategoriesLink( $article, $oldArticle )) {
+ return false;
+ }
// clean up the cache
include_once( PLOG_CLASS_PATH."class/dao/recentarticles.class.php" );
@@ -904,9 +938,6 @@
$this->_cache->removeData( $article->getId(), CACHE_ARTICLETEXT );
$this->_cache->setData( $article->getId(), CACHE_ARTICLES, $article );
$this->_cache->removeData( $article->getPostSlug(), CACHE_ARTICLES_BYNAME );
-
- include_once( PLOG_CLASS_PATH."class/dao/recentarticles.class.php" );
- RecentArticles::resetRecentArticlesCache( $article->getBlogId());
return true;
}
@@ -1045,6 +1076,9 @@
// -- custom fields --
$customFields = new CustomFieldsValues();
$customFields->removeArticleCustomFields( $artId );
+
+ // update global article categories
+ $this->updateGlobalArticleCategoriesLink( $article );
include_once( PLOG_CLASS_PATH."class/dao/recentarticles.class.php" );
RecentArticles::resetRecentArticlesCache( $blogId );
Modified: plog/trunk/class/dao/globalarticlecategory.class.php
===================================================================
--- plog/trunk/class/dao/globalarticlecategory.class.php 2006-03-19 22:13:53 UTC (rev 3086)
+++ plog/trunk/class/dao/globalarticlecategory.class.php 2006-03-19 22:14:56 UTC (rev 3087)
@@ -93,7 +93,7 @@
* @param status A valid post status
* @return An integer value
*/
- function getNumArticles( $status = POST_STATUS_PUBLISHED )
+ function getNumArticles( $status = POST_STATUS_ALL )
{
if( $status == POST_STATUS_ALL )
return( $this->_numArticles );
More information about the pLog-svn
mailing list