[pLog-svn] r546 - plog/trunk/class/action

oscar at devel.plogworld.net oscar at devel.plogworld.net
Sun Dec 19 15:43:50 GMT 2004


Author: oscar
Date: 2004-12-19 15:43:49 +0000 (Sun, 19 Dec 2004)
New Revision: 546

Modified:
   plog/trunk/class/action/defaultaction.class.php
Log:
the $category object is now always exported to the template so that we can have different behaviour in the template, depending on whether we're browsing a particular category or not.

Modified: plog/trunk/class/action/defaultaction.class.php
===================================================================
--- plog/trunk/class/action/defaultaction.class.php	2004-12-19 15:20:42 UTC (rev 545)
+++ plog/trunk/class/action/defaultaction.class.php	2004-12-19 15:43:49 UTC (rev 546)
@@ -74,8 +74,8 @@
             // if we got a category name instead of a category id, then we
             // should first look up this category in the database and see if
             // it exists
+            $categories = new ArticleCategories();			
             if( !is_numeric($this->_categoryId)) {
-                $categories = new ArticleCategories();
                 $category = $categories->getCategoryByName( $this->_categoryId, $this->_blogInfo->getId());
                 if( !$category ) {
                     $this->_view = new ErrorView( $this->_blogInfo );
@@ -86,10 +86,23 @@
                 
                 // if everything went fine...
                 $this->_categoryId = $category->getId();
-				// export the category object in case it is needed...
-				$this->_view->setValue( "category", $category );
             }
+			else {
+				// we don't do anything if the cateogry id is '0' or '-1'
+				if( $this->_categoryId > 0 ) {
+					$category = $categories->getCategory( $this->_categoryId, $this->_blogInfo->getId());
+					if( !$category ) {
+						$this->_view = new ErrorView( $this->_blogInfo );
+						$this->_view->setValue( 'message', "error_incorrect_category_id" );
+						$this->setCommonData();
+						return false;
+					}
+				}
+			}
 			
+			// export the category object in case it is needed
+			$this->_view->setValue( "category", $category );			
+			
             // if we got a user name instead of a user id, then we
             // should first look up this user in the database and see if
             // it exists




More information about the pLog-svn mailing list