[pLog-svn] r6813 - plog/branches/lifetype-1.2/class/dao

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Feb 21 08:37:23 EST 2009


Author: jondaley
Date: 2009-02-21 08:37:22 -0500 (Sat, 21 Feb 2009)
New Revision: 6813

Modified:
   plog/branches/lifetype-1.2/class/dao/articles.class.php
Log:
fixes http://bugs.lifetype.net/view.php?id=1424 check to make sure that the assigned categories are actually in the blog that the article is in

Modified: plog/branches/lifetype-1.2/class/dao/articles.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/articles.class.php	2009-02-21 12:52:09 UTC (rev 6812)
+++ plog/branches/lifetype-1.2/class/dao/articles.class.php	2009-02-21 13:37:22 UTC (rev 6813)
@@ -925,6 +925,8 @@
          */
         function updateArticle( $article )
         {
+            $blogInfo = $article->getBlogInfo();
+
                 // Check if we need to force the article slug to be unique
             lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
 			$config =& Config::getConfig();
@@ -941,6 +943,11 @@
                                                                       $article->getBlog()))
                 {
                         // if we found ourselves, it is okay to keep using this name
+                        // NOTE: if someone changed the unique setting after two posts
+                        // were published with the same slug, they will have to update
+                        // BOTH articles in order to make sure that all slugs are unique
+                        // (or at least update the later article, since the first article
+                        // will continue to use the same slug)
                     if($existingArticle->getId() == $article->getId())
                         break;
 
@@ -956,7 +963,17 @@
             
 			// keep the old version, since we're going to need it to udpate the category counters
 			$oldArticle = $this->getArticle( $article->getId());
-		
+
+                // check whether the categories are valid for this blog
+            if($article->getStatus() != POST_STATUS_DELETED){
+                $newCategoryIds = $article->getCategoryIds();
+                $blogCategories = new ArticleCategories();
+                foreach($newCategoryIds as $catId){
+                    if(!$blogCategories->getCategory($catId, $blogInfo->getId()))
+                        return false;
+                }
+            }
+            
 			// and now update the new version
         	$result = $this->update( $article );
 
@@ -987,14 +1004,12 @@
 			if( $oldArticle->getStatus() == POST_STATUS_PUBLISHED && $article->getStatus() != POST_STATUS_PUBLISHED ) {
 				lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );				
 		    	$blogs = new Blogs();
-	    	    $blogInfo = $article->getBlogInfo();
 	        	$blogInfo->setTotalPosts( $blogInfo->getTotalPosts() - 1 );
 				$blogInfo->setUpdateDate( Timestamp::getNowTimestamp());
 	            $blogs->updateBlog( $blogInfo );
 	        } elseif ( $oldArticle->getStatus() != POST_STATUS_PUBLISHED && $article->getStatus() == POST_STATUS_PUBLISHED ) {
 				lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );		
 		    	$blogs = new Blogs();
-	    	    $blogInfo = $article->getBlogInfo();
 	        	$blogInfo->setTotalPosts( $blogInfo->getTotalPosts() + 1 );
 				$blogInfo->setUpdateDate( Timestamp::getNowTimestamp());	
 	            $blogs->updateBlog( $blogInfo );



More information about the pLog-svn mailing list