[Fusionforge-commits] r12465 - trunk/src/common/include

Olivier Berger olberger at fusionforge.org
Tue Mar 1 19:15:20 CET 2011


Author: olberger
Date: 2011-03-01 19:15:19 +0100 (Tue, 01 Mar 2011)
New Revision: 12465

Modified:
   trunk/src/common/include/RBAC.php
Log:
Somme docs/comments and some style checks

Modified: trunk/src/common/include/RBAC.php
===================================================================
--- trunk/src/common/include/RBAC.php	2011-03-01 18:11:32 UTC (rev 12464)
+++ trunk/src/common/include/RBAC.php	2011-03-01 18:15:19 UTC (rev 12465)
@@ -26,6 +26,7 @@
 
 require "PFO-RBAC.interface.php";
 
+// TODO : remove this which is security issue ?
 if (true || file_exists ('/tmp/fusionforge-use-pfo-rbac')) {
 	define ('USE_PFO_RBAC', true);
 } else {
@@ -34,13 +35,34 @@
 
 // Code shared between classes
 
+/**
+ * TODO: RBAC::BaseRole Enter description here ...
+ *
+ */
 abstract class BaseRole extends Error {
+	/**
+	 * TODO: Enter description here ...
+	 * @var unknown_type
+	 */
 	var $role_values;
+	/**
+	 * TODO: Enter description here ...
+	 * @var unknown_type
+	 */
 	var $defaults;
+	/**
+	 * TODO: Enter description here ...
+	 * @var unknown_type
+	 */
 	var $global_settings;
 
+	// var $perms_array;
+	// var $setting_array;
+	
 	public function BaseRole() {
 		if (USE_PFO_RBAC) {
+			// TODO: document these tables
+			// $gfcommon.'include/rbac_texts.php' may provide some hints...
 			$this->role_values = array(
 				'forge_admin' => array(0, 1),
 				'approve_projects' => array(0, 1),
@@ -69,13 +91,15 @@
 				'webcal' => array(0, 1, 2),
 				);
 
+			// Global permissions
 			$this->global_settings = array(
-				'forge_admin',
-				'approve_projects',
-				'approve_news',
+				'forge_admin', // “God mode”: all actions allowed 
+				'approve_projects', // Ability to approve pending projects 
+				'approve_news', // Ability to approve news bits to the forge front page 
 				'forge_stats'
 				);
 
+			// TODO: document these	(Project-related permissions ?)
 			$this->defaults = array(
 				'Admin' => array(            'project_admin'=> 1,
 							     'project_read' => 1,
@@ -344,6 +368,7 @@
 				$this->setError('BaseRole::fetchData()::'.db_error());
 				return false;
 			}
+			// TODO: document perms_array
 			$this->perms_array=array();
 			while ($arr = db_fetch_array($res)) {
 				$this->perms_array[$arr['section_name']][$arr['ref_id']] = $arr['perm_val'];
@@ -578,12 +603,16 @@
 		return $result ;
 	}
 
+	/**
+	 * TODO: Enter description here ...
+	 * @return multitype:
+	 */
 	function getGlobalSettings () {
 		$result = array () ;
 
 		$sections = array ('forge_admin', 'forge_stats', 'approve_projects', 'approve_news') ;
 		foreach ($sections as $section) {
-			$result[$section][-1] = $this->getVal ($section, -1) ;
+			$result[$section][-1] = $this->getVal($section, -1) ;
 		}
 		// Add settings not yet listed so far (probably plugins)
 		foreach (array_keys ($this->perms_array) as $section) {
@@ -597,8 +626,14 @@
 		return $result ;
 	}
 
-        function getSetting($section, $reference) {
-                if (isset ($this->perms_array[$section][$reference])) {
+    /**
+     * TODO: Enter description here ...
+     * @param unknown_type $section
+     * @param unknown_type $reference
+     * @return number|boolean
+     */
+    function getSetting($section, $reference) {
+        if (isset ($this->perms_array[$section][$reference])) {
 			$value = $this->perms_array[$section][$reference] ;
 		} else {
 			$value = 0 ;
@@ -723,15 +758,15 @@
 	 *	@param	integer	The ref_id (ex: group_artifact_id, group_forum_id) for this item.
 	 *	@return integer	The value of this item.
 	 */
-	function getVal($section,$ref_id) {
+	function getVal($section, $ref_id) {
 		global $role_default_array;
 		if (!$ref_id) {
 			$ref_id=0;
 		}
 		if (USE_PFO_RBAC) {
-			return $this->getSetting ($section, $ref_id) ;
+			return $this->getSetting($section, $ref_id) ;
 		} else {
-			if (array_key_exists ($section, $this->setting_array)) {
+			if (array_key_exists($section, $this->setting_array)) {
 				return $this->setting_array[$section][$ref_id];
 			} else {
 				return 0 ;
@@ -1332,6 +1367,10 @@
 
 // Actual classes
 
+/**
+ * TODO: RBAC::RoleExplicit Enter description here ...
+ *
+ */
 abstract class RoleExplicit extends BaseRole implements PFO_RoleExplicit {
 	public function addUsers($users) {
 		global $SYS;
@@ -1527,6 +1566,10 @@
 	}
 }
 
+/**
+ * TODO: Enter description here ...
+ *
+ */
 class RoleComparator {
 	var $criterion = 'composite' ;
 	var $reference_project = NULL ;
@@ -1564,6 +1607,12 @@
 		}
 	}
 
+	/**
+	 * TODO: Enter description here ...
+	 * @param Role $a
+	 * @param Role $b
+	 * @return number
+	 */
 	function CompareNoRef ($a, $b) {
 		$ap = $a->getHomeProject() ;
 		$bp = $b->getHomeProject() ;




More information about the Fusionforge-commits mailing list