[pLog-svn] r4178 - in plog/trunk/class/action/admin: . chooser

oscar at devel.lifetype.net oscar at devel.lifetype.net
Mon Oct 23 14:08:32 GMT 2006


Author: oscar
Date: 2006-10-23 14:08:32 +0000 (Mon, 23 Oct 2006)
New Revision: 4178

Modified:
   plog/trunk/class/action/admin/adminaddresourceaction.class.php
   plog/trunk/class/action/admin/adminaddresourcealbumaction.class.php
   plog/trunk/class/action/admin/admineditresourcealbumaction.class.php
   plog/trunk/class/action/admin/adminnewresourceaction.class.php
   plog/trunk/class/action/admin/adminnewresourcealbumaction.class.php
   plog/trunk/class/action/admin/adminresourceinfoaction.class.php
   plog/trunk/class/action/admin/adminresourcesaction.class.php
   plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php
   plog/trunk/class/action/admin/chooser/adminresourcelistaction.class.php
Log:
almost done implementing permissions for albums


Modified: plog/trunk/class/action/admin/adminaddresourceaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddresourceaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminaddresourceaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -50,6 +50,8 @@
 			$view->setErrorMessage( $this->_locale->tr( "error_no_resource_uploaded" ));
 			$this->setValidationErrorView( $view );
 			
+			$this->requirePermission( "add_resource" );
+			
         }
 
         /**

Modified: plog/trunk/class/action/admin/adminaddresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddresourcealbumaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminaddresourcealbumaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -35,6 +35,8 @@
 			$this->registerFieldValidator( "parentId", new IntegerValidator());
 			$this->_form->registerField( "albumDescription" );
 			$this->setValidationErrorView( new AdminNewAlbumView( $this->_blogInfo ));
+			
+			$this->requirePermission( "add_album" );
         }
 
         /**
@@ -62,7 +64,12 @@
 			$this->notifyEvent( EVENT_PRE_ALBUM_ADD, Array( "album" => &$album ));
 			// and add it to the database
             $result = $albums->addAlbum( $album );
-           	$this->_view = new AdminResourcesListView( $this->_blogInfo, Array( "albumId" => $this->_parentId ));
+            
+            if( $this->userHasPermission( "view_resources" ))
+           		$this->_view = new AdminResourcesListView( $this->_blogInfo, Array( "albumId" => $this->_parentId ));
+           	else
+           		$this->_view = new AdminNewAlbumView( $this->_blogInfo );
+           	
             if( $result ) {
                 $this->_view->setSuccessMessage( $this->_locale->pr( "album_added_ok", $album->getName()));
 				$this->notifyEvent( EVENT_POST_ALBUM_ADD, Array( "album" => &$album ));								

Modified: plog/trunk/class/action/admin/admineditresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditresourcealbumaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/admineditresourcealbumaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -29,6 +29,8 @@
 			$view = new AdminResourcesListView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("error_incorrect_album_id"));
 			$this->setValidationErrorView( $view );
+			
+			$this->requirePermission( "update_album" );
         }
 
         /**

Modified: plog/trunk/class/action/admin/adminnewresourceaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewresourceaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminnewresourceaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -23,6 +23,8 @@
         function AdminNewResourceAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
+        	
+        	$this->requirePermission( "add_resource" );
         }
 		
 		function validate()

Modified: plog/trunk/class/action/admin/adminnewresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewresourcealbumaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminnewresourcealbumaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -19,6 +19,8 @@
         function AdminNewResourceAlbumAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
+        	
+        	$this->requirePermission( "add_album" );
         }
 
         /**
@@ -26,7 +28,7 @@
          */
         function perform()
         {
-            $this->_view = new AdminNewAlbumView( $this->_blogInfo, "newresourcealbum" );
+            $this->_view = new AdminNewAlbumView( $this->_blogInfo );
             $this->setCommonData();
             return true;
         }

Modified: plog/trunk/class/action/admin/adminresourceinfoaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminresourceinfoaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminresourceinfoaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -22,8 +22,8 @@
          * Constructor. If nothing else, it also has to call the constructor of the parent
          * class, BlogAction with the same parameters
          */
-        function AdminNewResourceAlbumAction( $actionInfo, $request )
-        {
+        function AdminResourceInfoAction( $actionInfo, $request )
+        {	       	        
         	$this->AdminAction( $actionInfo, $request );
 			
 			// data validation
@@ -31,6 +31,8 @@
 			$view = new AdminResourcesListView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr( "error_fetching_resource" ));
 			$this->setValidationErrorView( $view );
+			
+			$this->requirePermission( "update_resource" );			
         }
 
         /**

Modified: plog/trunk/class/action/admin/adminresourcesaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminresourcesaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminresourcesaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -30,6 +30,8 @@
 			$view = new AdminResourcesListView( $this->_blogInfo, Array( "albumId" => 0 ));
 			$view->setErrorMessage( $this->_locale->tr("error_incorrect_album_id"));
 			$this->setValidationErrorView( $view );
+			
+			$this->requirePermission( "view_resources" );
         }
 
 		function checkFolders()

Modified: plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/adminupdateresourcealbumaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -36,9 +36,11 @@
 			$this->registerFieldValidator( "parentId", new IntegerValidator());
 			$this->registerField( "albumDescription" );
 			$this->registerField( "showAlbum" );
-			$view = new AdminEditResourceAlbumView( $this->_blogInfo, "editresourcealbum" );
+			$view = new AdminEditResourceAlbumView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("error_updating_album" ));
 			$this->setValidationErrorView( $view );
+			
+			$this->requirePermission( "update_album" );
         }
 
         /**
@@ -57,32 +59,38 @@
             // fetch the albums for this blog
             $albums = new GalleryAlbums();
             $album = $albums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
-
+            
+            if( $this->userHasPermission( "view_resources" ))
+            	$this->_view = new AdminResourcesListView( $this->_blogInfo );
+            else {
+            	$this->_view = new AdminEditResourceAlbumView( $this->_blogInfo );
+				$this->_view->setValue( "albumName", $this->_albumName );
+				$this->_view->setValue( "albumDescription", $this->_albumDescription );
+				$this->_view->setValue( "showAlbum", $this->_showAlbum );
+				$this->_view->setValue( "parentId", $this->_parentId );
+				$this->_view->setValue( "albumId", $this->_albumId );            	
+        	}
+            	
             if( !$album ) {
-            	$this->_view = new AdminResourcesListView( $this->_blogInfo );( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_album" ) );
                 $this->setCommonData();
-
                 return false;
             }
-
+            
             // update the fields in the object
             $album->setName( $this->_albumName );
             $album->setDescription( $this->_albumDescription );
             $album->setParentId( $this->_parentId );
-            $album->setShowAlbum( $this->_showAlbum );
+            $album->setShowAlbum( $this->_showAlbum );            
 			
 			$this->notifyEvent( EVENT_PRE_ALBUM_UPDATE, Array( "album" => &$album ));
             // and update the data in the database
             if( !$albums->updateAlbum( $album )) {
-            	$this->_view = new AdminResourcesListView( $this->_blogInfo );( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_album" ) );
             	$this->setCommonData();
-
                 return false;
             }
 
-            $this->_view = new AdminResourcesListView( $this->_blogInfo );
             $this->_view->setSuccessMessage( $this->_locale->pr("album_updated_ok", $album->getName()));
 			$this->notifyEvent( EVENT_POST_ALBUM_UPDATE, Array( "album" => &$album ));			
             $this->setCommonData();

Modified: plog/trunk/class/action/admin/chooser/adminresourcelistaction.class.php
===================================================================
--- plog/trunk/class/action/admin/chooser/adminresourcelistaction.class.php	2006-10-23 13:44:30 UTC (rev 4177)
+++ plog/trunk/class/action/admin/chooser/adminresourcelistaction.class.php	2006-10-23 14:08:32 UTC (rev 4178)
@@ -27,7 +27,9 @@
         	
             $this->_albumId = $this->_request->getValue( "albumId" );
             if( $this->_albumId == "" )
-            	$this->_albumId = 0;			
+            	$this->_albumId = 0;	
+            	
+            $this->requirePermission( "view_resources" );		
         }
 
         /**



More information about the pLog-svn mailing list