[pLog-svn] r3179 - plog/trunk/class/action/admin

mark at devel.lifetype.net mark at devel.lifetype.net
Tue Apr 4 04:16:37 GMT 2006


Author: mark
Date: 2006-04-04 04:16:36 +0000 (Tue, 04 Apr 2006)
New Revision: 3179

Modified:
   plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php
Log:
Make sure the global article category is empty (no articles assigened) before we delete it.

Modified: plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php	2006-04-04 03:33:39 UTC (rev 3178)
+++ plog/trunk/class/action/admin/admindeleteglobalarticlecategoryaction.class.php	2006-04-04 04:16:36 UTC (rev 3179)
@@ -57,10 +57,20 @@
 			
             foreach( $this->_categoryIds as $categoryId ) {
             	// get the category
-            	$this->notifyEvent( EVENT_PRE_DELETE_GLOBAL_CATEGORY, Array( "category" => &$category ));
-                $category   = $categories->getGlobalArticleCategory( $categoryId );
-						if( $category ) {
-									// if everything correct, we can proceed and delete it
+            	$category   = $categories->getGlobalArticleCategory( $categoryId );
+				
+				if( $category ) {
+					// get how many articles it has
+					$numArticles = $category->getNumArticles( POST_STATUS_ALL );
+										
+					// fire the pre-event
+					$this->notifyEvent( EVENT_PRE_DELETE_GLOBAL_CATEGORY, Array( "category" => &$category ));
+					
+					// if everything correct, we can proceed and delete it
+					if( $numArticles > 0 ) {
+						$errorMessage .= $this->_locale->pr( "error_global_category_has_articles", $category->getName())."<br/>";
+					}
+					else {									
 						if( !$categories->deleteGlobalArticleCategory( $categoryId))
 							$errorMessage .= $this->_locale->pr("error_deleting_global_category")."<br/>";
 						else {
@@ -71,14 +81,14 @@
 								
 							// fire the pre-event
 							$this->notifyEvent( EVENT_POST_DELETE_GLOBAL_CATEGORY, Array( "category" => &$category ));
-				
+						}
 					}
 				}
 				else {
 					$errorMessage .= $this->_locale->pr("error_deleting_global_category2", $categoryId)."<br/>";
-					}
-        }
-			
+				}
+        	}
+        				
 			// prepare the view and all the information it needs to know
 			$this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
 			if( $errorMessage != "" ) 



More information about the pLog-svn mailing list