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

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Feb 21 17:27:31 EST 2009


Author: jondaley
Date: 2009-02-21 17:27:31 -0500 (Sat, 21 Feb 2009)
New Revision: 6830

Modified:
   plog/branches/lifetype-1.2/class/dao/articles.class.php
Log:
don't allow an article to be added with an invalid category

Modified: plog/branches/lifetype-1.2/class/dao/articles.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/articles.class.php	2009-02-21 22:15:11 UTC (rev 6829)
+++ plog/branches/lifetype-1.2/class/dao/articles.class.php	2009-02-21 22:27:31 UTC (rev 6830)
@@ -782,6 +782,8 @@
          */
         function addArticle( &$newArticle )
         {
+            $blogInfo = $newArticle->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();
@@ -803,8 +805,15 @@
                 $newArticle->setPostSlug($slug);
             }
 
+                // check whether the categories are valid for this blog
+            $newCategoryIds = $newArticle->getCategoryIds();
+            $blogCategories = new ArticleCategories();
+            foreach($newCategoryIds as $catId){
+                if(!$blogCategories->getCategory($catId, $blogInfo->getId()))
+                    return false;
+            }
+            
             lt_include( PLOG_CLASS_PATH.'class/dao/customfields/customfields.class.php' );
-            lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
             
             $result = $this->add( $newArticle );
 			
@@ -834,8 +843,8 @@
             // update the blog counters
             if( $newArticle->getStatus() == POST_STATUS_PUBLISHED ) {
 				lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );	
+                lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
 	            $blogs = new Blogs();
-    	        $blogInfo = $newArticle->getBlogInfo();
         	    $blogInfo->setTotalPosts( $blogInfo->getTotalPosts() + 1 );
 				$blogInfo->setUpdateDate( Timestamp::getNowTimestamp());
             	$blogs->updateBlog( $blogInfo );



More information about the pLog-svn mailing list