[Fusionforge-commits] r9765 - trunk/gforge/common/include

Roland Mas lolando at libremir.placard.fr.eu.org
Fri May 21 09:41:07 CEST 2010


Author: lolando
Date: 2010-05-21 09:41:07 +0200 (Fri, 21 May 2010)
New Revision: 9765

Modified:
   trunk/gforge/common/include/PFO-RBAC.php
   trunk/gforge/common/include/RBAC.php
Log:
Updated to match new version of API

Modified: trunk/gforge/common/include/PFO-RBAC.php
===================================================================
--- trunk/gforge/common/include/PFO-RBAC.php	2010-05-21 07:40:55 UTC (rev 9764)
+++ trunk/gforge/common/include/PFO-RBAC.php	2010-05-21 07:41:07 UTC (rev 9765)
@@ -23,78 +23,53 @@
  * USA
  */
 
-// Constants for roles' “capabilities”
-define ("PFO_ROLE_CAP_EXPLICIT",  1) ;
-define ("PFO_ROLE_CAP_FORGEWIDE", 2) ;
-define ("PFO_ROLE_CAP_UNION",     4) ;
-define ("PFO_ROLE_CAP_ANONYMOUS", 8) ;
-define ("PFO_ROLE_CAP_LOGGEDIN", 16) ;
-
 // Constants to identify role classes
-define ("PFO_ROLE_STANDARD", PFO_ROLE_CAP_EXPLICIT) ;
-define ("PFO_ROLE_GLOBAL", PFO_ROLE_CAP_EXPLICIT | PFO_ROLE_CAP_FORGEWIDE) ;
-define ("PFO_ROLE_ANONYMOUS", PFO_ROLE_CAP_FORGEWIDE | PFO_ROLE_CAP_ANONYMOUS) ;
-define ("PFO_ROLE_LOGGEDIN", PFO_ROLE_CAP_FORGEWIDE | PFO_ROLE_CAP_LOGGEDIN) ;
-define ("PFO_ROLE_UNIONPROJECT", PFO_ROLE_CAP_UNION) ;
-define ("PFO_ROLE_UNIONGLOBAL", PFO_ROLE_CAP_FORGEWIDE | PFO_ROLE_CAP_UNION) ;
+define ("PFO_ROLE_EXPLICIT",  1) ;
+define ("PFO_ROLE_UNION",     2) ;
+define ("PFO_ROLE_ANONYMOUS", 3) ;
+define ("PFO_ROLE_LOGGEDIN",  4) ;
 
 // Interfaces for the capabilities
-interface PFO_BaseRole {
+interface PFO_Role {
 	public function getName() ;
-	public function setName() ;
+	public function setName($name) ;
 	public function getID() ;
+
+	public function isPublic() ;
+	public function setPublic($flag) ;
+	public function getHomeProject() ;
+	public function getLinkedProjects() ;
+	public function linkProject($project) ;
+	public function unlinkProject($project) ;
+
 	public function getUsers() ;
 	public function hasUser($user) ;
 	public function hasPermission($section, $reference, $permission) ;
 	public function normalizeData() ;
 	public function getSettings() ;
 	public function setSettings($data) ;
-	public function getLinkedProjects() ;
 }
 
-interface PFO_RoleExplicit extends PFO_BaseRole {
+interface PFO_RoleExplicit extends PFO_Role {
+	const roleclass = PFO_ROLE_EXPLICIT ;
 	public function addUser($user) ;
 	public function removeUser($user) ;
 }
 
-interface PFO_RoleForgeWide extends PFO_BaseRole {
-	public function linkProject($project) ;
-	public function unlinkProject($project) ;
-
-}
-
-interface PFO_RoleUnion extends PFO_BaseRole {
+interface PFO_RoleUnion extends PFO_Role {
+	const roleclass = PFO_ROLE_UNION ;
 	public function addRole($role) ;
 	public function removeRole($role) ;
 }
 
-// Interfaces for the combination of capabilities
-
-interface PFO_RoleStandard extends PFO_RoleExplicit {
-	const role_caps = PFO_ROLE_STANDARD ;
+interface PFO_RoleAnonymous extends PFO_Role {
+	const roleclass = PFO_ROLE_ANONYMOUS ;
 }
 
-interface PFO_RoleGlobal extends PFO_RoleExplicit {
-	const role_caps = PFO_ROLE_GLOBAL ;
+interface PFO_RoleLoggedin extends PFO_Role {
+	const roleclass = PFO_ROLE_LOGGEDIN ;
 }
 
-interface PFO_RoleAnonymous extends PFO_RoleForgeWide {
-	const role_caps = PFO_ROLE_ANONYMOUS ;
-}
-
-interface PFO_RoleLoggedin extends PFO_RoleForgeWide {
-	const role_caps = PFO_ROLE_LOGGEDIN ;
-}
-
-interface PFO_RoleUnionProject extends PFO_RoleUnion {
-	const role_caps = PFO_ROLE_UNIONPROJECT ;
-}
-
-interface PFO_RoleUnionGlobal extends PFO_RoleForgeWide, PFO_RoleUnion {
-	const role_caps = PFO_ROLE_UNIONGLOBAL ;
-}
-
-
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/gforge/common/include/RBAC.php
===================================================================
--- trunk/gforge/common/include/RBAC.php	2010-05-21 07:40:55 UTC (rev 9764)
+++ trunk/gforge/common/include/RBAC.php	2010-05-21 07:41:07 UTC (rev 9765)
@@ -29,16 +29,36 @@
 
 abstract class Error {}
 
-abstract class BaseRole extends Error implements PFO_BaseRole {
+abstract class BaseRole extends Error implements PFO_Role {
 	public function getName() {
 		return $this->name ;
 	}
-	public function setName() {
+	public function setName($name) {
 		return true ;
 	}
 	public function getID() {
 		return $this->ID ;
 	}
+
+	public function isPublic() {
+		return false ;
+	}
+	public function setPublic($flag) {
+		return false ;
+	}
+	public function getHomeProject() {
+		return true ;
+	}
+	public function getLinkedProjects() {
+		return array () ;
+	}
+	public function linkProject($project) {
+		return true ;
+	}
+	public function unlinkProject($project) {
+		return true ;
+	}
+
 	public function getUsers() {
 		return array () ;
 	}
@@ -57,23 +77,11 @@
 	public function setSettings($data) {
 		return true ;
 	}
-	public function getLinkedProjects() {
-		return array () ;
-	}
 }
 
-abstract class BaseRoleGlobal extends BaseRole implements PFO_RoleForgeWide {
-	public function linkProject($project) {
-		return true ;
-	}
-	public function unlinkProject($project) {
-		return true ;
-	}
-}
-
 // Actual classes
 
-class RoleStandard extends BaseRole implements PFO_RoleStandard {
+class RoleExplicit extends BaseRole implements PFO_RoleExplicit {
 	public function addUser($user) {
 		return true ;
 	}
@@ -83,21 +91,9 @@
 	public function getUsers() {
 		return array () ;
 	}
-	public function getProject() {
-		return false ;
-	}
 }
 
-class RoleGlobal extends BaseRoleGlobal implements PFO_RoleGlobal {
-	public function addUser($user) {
-		return true ;
-	}
-	public function removeUser($user) {
-		return true ;
-	}
-}
-
-class RoleAnonymous extends BaseRoleGlobal implements PFO_RoleAnonymous {
+class RoleAnonymous extends BaseRole implements PFO_RoleAnonymous {
 	public function getName () {
 		return _('Anonymous/not logged in') ;
 	}
@@ -106,7 +102,7 @@
 	}
 }
 
-class RoleLoggedIn extends BaseRoleGlobal implements PFO_RoleLoggedIn {
+class RoleLoggedIn extends BaseRole implements PFO_RoleLoggedIn {
 	public function getName () {
 		return _('Any user logged in') ;
 	}
@@ -115,7 +111,7 @@
 	}
 }
 
-class RoleUnionProject extends BaseRole implements PFO_RoleUnionProject {
+class RoleUnion extends BaseRole implements PFO_RoleUnion {
 	public function addRole ($role) {
 		return true ;
 	}
@@ -124,21 +120,10 @@
 	}
 }
 
-class RoleUnionGlobal extends BaseRoleGlobal implements PFO_RoleUnionGlobal {
-	public function addRole ($role) {
-		return true ;
-	}
-	public function removeRole ($role) {
-		return true ;
-	}
-}
-
-$rs = new RoleStandard () ;
-$rg = new RoleGlobal () ;
+$rs = new RoleExplicit () ;
 $ra = new RoleAnonymous () ;
 $rl = new RoleLoggedIn () ;
-$rup = new RoleUnionProject () ;
-$rug = new RoleUnionGlobal () ;
+$ru = new RoleUnion () ;
 
 // Local Variables:
 // mode: php




More information about the Fusionforge-commits mailing list