[pLog-svn] r3993 - in plog/trunk/class: dao test/tests/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Tue Sep 19 11:48:01 GMT 2006


Author: oscar
Date: 2006-09-19 11:47:45 +0000 (Tue, 19 Sep 2006)
New Revision: 3993

Modified:
   plog/trunk/class/dao/permission.class.php
   plog/trunk/class/dao/permissions.class.php
   plog/trunk/class/test/tests/dao/permissions_test.class.php
Log:
added two more fields to identify permissions: one to determine whether they can be deleted or not (the core permissions cannot be deleted) and another one to know whether this permission can be assigned by anyone or only by administrator users


Modified: plog/trunk/class/dao/permission.class.php
===================================================================
--- plog/trunk/class/dao/permission.class.php	2006-09-18 22:25:01 UTC (rev 3992)
+++ plog/trunk/class/dao/permission.class.php	2006-09-19 11:47:45 UTC (rev 3993)
@@ -13,6 +13,8 @@
 		var $_id;
 		var $_name;
 		var $_description;
+		var $_corePerm;
+		var $_adminOnly;
 	
 		/**
 		 * Constructor
@@ -32,10 +34,14 @@
 			$this->_name = $name;
 			$this->_description = $description;
 			$this->_id = $id;
+			$this->_adMinOnly = false;
+			$this->_corePerm = false;
 			
 			$this->_fields = Array(
 				"permission" => "getName",
 				"description" => "getDescription",
+				"core_perm" => "isCorePermission",
+				"admin_only" => "isAdminOnlyPermission",
 				"id" => "getId"
 			);
 		}
@@ -68,6 +74,26 @@
 		function setDescription( $desc )
 		{
 			$this->_description = $desc;
-		}		
+		}
+		
+		function isCorePermission()
+		{
+			return( $this->_corePerm );	
+		}
+		
+		function setCorePermission( $corePerm )
+		{
+			$this->_corePerm = $corePerm;	
+		}
+		
+		function isAdminOnlyPermission()
+		{
+			return( $this->_adminOnly );	
+		}
+		
+		function setAdminOnlyPermission( $adminOnly )
+		{
+			$this->_adminOnly = $adminOnly;
+		}
 	}
 ?>
\ No newline at end of file

Modified: plog/trunk/class/dao/permissions.class.php
===================================================================
--- plog/trunk/class/dao/permissions.class.php	2006-09-18 22:25:01 UTC (rev 3992)
+++ plog/trunk/class/dao/permissions.class.php	2006-09-19 11:47:45 UTC (rev 3993)
@@ -102,6 +102,8 @@
 		function mapRow( $row )
 		{
 			$perm = new Permission( $row["permission"], $row["description"], $row["id"] );
+			$perm->setAdminOnlyPermission( $row["admin_only"] );
+			$perm->setCorePermission( $row["core_perm"] );
 			return( $perm  );	
 		}
 	}

Modified: plog/trunk/class/test/tests/dao/permissions_test.class.php
===================================================================
--- plog/trunk/class/test/tests/dao/permissions_test.class.php	2006-09-18 22:25:01 UTC (rev 3992)
+++ plog/trunk/class/test/tests/dao/permissions_test.class.php	2006-09-19 11:47:45 UTC (rev 3993)
@@ -14,6 +14,8 @@
 		function testAddPermission()
 		{
 			$perm = new Permission( "test_perm", "test_perm_desc" );
+			$perm->setAdminOnlyPermission( false );
+			$perm->setCorePermission( true );
 			$perms = new Permissions();
 			
 			// check that it was correctly added
@@ -29,6 +31,8 @@
 			// and that the object contains the same values
 			$this->assertEquals( $perm->getName(), $newPerm->getName(), "new permission is not the same as original" );
 			$this->assertEquals( $perm->getDescription(), $newPerm->getDescription(), "new permission is not the same as original" );
+			$this->assertEquals( $perm->isAdminOnlyPermission(), $newPerm->isAdminOnlyPermission(), "new permission is not the same as original" );
+			$this->assertEquals( $perm->isCorePermission(), $newPerm->isCorePermission(), "new permission is not the same as original" );
 		}
 		
 		function testGetPermission()



More information about the pLog-svn mailing list