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

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Apr 14 16:14:11 CEST 2010


Author: lolando
Date: 2010-04-14 16:14:11 +0200 (Wed, 14 Apr 2010)
New Revision: 9476

Modified:
   trunk/gforge/common/include/Role.class.php
Log:
Cleaned up default values definitions

Modified: trunk/gforge/common/include/Role.class.php
===================================================================
--- trunk/gforge/common/include/Role.class.php	2010-04-14 14:14:00 UTC (rev 9475)
+++ trunk/gforge/common/include/Role.class.php	2010-04-14 14:14:11 UTC (rev 9476)
@@ -31,23 +31,95 @@
 	var $setting_array;
 	var $role_vals;
 	var $Group;
-	var $role_values=array(
-	'projectadmin'=>array('0','A'),
-	'frs'=>array('0','1'),
-	'scm'=>array('-1','0','1'),
-	'docman'=>array('0','1'),
-	'forumadmin'=>array('0','2'),
-	'forum'=>array('-1','0','1','2'),
-	'newforum'=>array('-1','0','1','2'),
-	'trackeradmin'=>array('0','2'),
-	'tracker'=>array('-1','0','1','2','3'),
-	'newtracker'=>array('-1','0','1','2','3'),
-	'pmadmin'=>array('0','2'),
-	'pm'=>array('-1','0','1','2','3'),
-	'newpm'=>array('-1','0','1','2','3'),
-	'webcal'=>array('0','1','2'));
+	var $role_values = array(
+		'projectadmin' => array ('0','A'),
+		'frs'	       => array ('0','1'),
+		'scm'	       => array ('-1','0','1'),
+		'docman'       => array ('0','1'),
+		'forumadmin'   => array ('0','2'),
+		'forum'	       => array ('-1','0','1','2'),
+		'newforum'     => array ('-1','0','1','2'),
+		'trackeradmin' => array ('0','2'),
+		'tracker'      => array ('-1','0','1','2','3'),
+		'newtracker'   => array ('-1','0','1','2','3'),
+		'pmadmin'      => array ('0','2'),
+		'pm'	       => array ('-1','0','1','2','3'),
+		'newpm'	       => array ('-1','0','1','2','3'),
+		'webcal'       => array ('0','1','2'));
+	
+	var $defaults = array(
+		'Admin'		  => array( 'projectadmin'=>'A',
+					    'frs'=>'1',
+					    'scm'=>'1',
+					    'docman'=>'1',
+					    'forumadmin'=>'2',
+					    'forum'=>'2',
+					    'newforum'=>'2',
+					    'trackeradmin'=>'2',
+					    'tracker'=>'2',
+					    'newtracker'=>'2',
+					    'pmadmin'=>'2',
+					    'pm'=>'2',
+					    'newpm'=>'2',
+					    'webcal'=>'1' ),
+		'Senior Developer'=> array( 'projectadmin'=>'0',
+					    'frs'=>'1',
+					    'scm'=>'1',
+					    'docman'=>'1',
+					    'forumadmin'=>'2',
+					    'forum'=>'2',
+					    'newforum'=>'2',
+					    'trackeradmin'=>'2',
+					    'tracker'=>'2',
+					    'newtracker'=>'2',
+					    'pmadmin'=>'2',
+					    'pm'=>'2',
+					    'newpm'=>'2',
+					    'webcal'=>'2' ),
+		'Junior Developer'=> array( 'projectadmin'=>'0',
+					    'frs'=>'0',
+					    'scm'=>'1',
+					    'docman'=>'0',
+					    'forumadmin'=>'0',
+					    'forum'=>'1',
+					    'newforum'=>'1',
+					    'trackeradmin'=>'0',
+					    'tracker'=>'1',
+					    'newtracker'=>'1',
+					    'pmadmin'=>'0',
+					    'pm'=>'1',
+					    'newpm'=>'1',
+					    'webcal'=>'2' ),
+		'Doc Writer'	  => array( 'projectadmin'=>'0',
+					    'frs'=>'0',
+					    'scm'=>'0',
+					    'docman'=>'1',
+					    'forumadmin'=>'0',
+					    'forum'=>'1',
+					    'newforum'=>'1',
+					    'trackeradmin'=>'0',
+					    'tracker'=>'0',
+					    'newtracker'=>'0',
+					    'pmadmin'=>'0',
+					    'pm'=>'0' ,
+					    'newpm'=>'0' ,
+					    'webcal'=>'2'),
+		'Support Tech'	  => array( 'projectadmin'=>'0',
+					    'frs'=>'0',
+					    'scm'=>'0',
+					    'docman'=>'1',
+					    'forumadmin'=>'0',
+					    'forum'=>'1',
+					    'newforum'=>'1',
+					    'trackeradmin'=>'0',
+					    'tracker'=>'2',
+					    'newtracker'=>'2',
+					    'pmadmin'=>'0',
+					    'pm'=>'0' ,
+					    'newpm'=>'0' ,
+					    'webcal'=>'2')
+		);
 
-	var $defaults;
 
 	/**
 	 *  Role($group,$id) - CONSTRUCTOR.
@@ -56,20 +128,6 @@
 	 *  @param  int	 The role_id.
 	 */
 	function Role ($Group,$role_id=false) {
-		# Initialize the default group settings
-		if ($GLOBALS['default_roles']) {
-			$this->defaults=$GLOBALS['default_roles'];
-		} else {
-			$this->defaults=array(
-				'Admin'=>array( 'projectadmin'=>'A', 'frs'=>'1', 'scm'=>'1', 'docman'=>'1', 'forumadmin'=>'2', 'forum'=>'2', 'newforum'=>'2', 'trackeradmin'=>'2', 'tracker'=>'2', 'newtracker'=>'2', 'pmadmin'=>'2', 'pm'=>'2', 'newpm'=>'2', 'webcal'=>'1' ),
-				'Senior Developer'=>array( 'projectadmin'=>'0', 'frs'=>'1', 'scm'=>'1', 'docman'=>'1', 'forumadmin'=>'2', 'forum'=>'2', 'newforum'=>'2', 'trackeradmin'=>'2', 'tracker'=>'2', 'newtracker'=>'2', 'pmadmin'=>'2', 'pm'=>'2', 'newpm'=>'2', 'webcal'=>'2' ),
-				'Junior Developer'=>array( 'projectadmin'=>'0', 'frs'=>'0', 'scm'=>'1', 'docman'=>'0', 'forumadmin'=>'0', 'forum'=>'1', 'newforum'=>'1', 'trackeradmin'=>'0', 'tracker'=>'1', 'newtracker'=>'1', 'pmadmin'=>'0', 'pm'=>'1', 'newpm'=>'1', 'webcal'=>'2' ),
-				'Doc Writer'=>array( 'projectadmin'=>'0', 'frs'=>'0', 'scm'=>'0', 'docman'=>'1', 'forumadmin'=>'0', 'forum'=>'1', 'newforum'=>'1', 'trackeradmin'=>'0', 'tracker'=>'0', 'newtracker'=>'0', 'pmadmin'=>'0', 'pm'=>'0' , 'newpm'=>'0' , 'webcal'=>'2'),
-				'Support Tech'=>array( 'projectadmin'=>'0', 'frs'=>'0', 'scm'=>'0', 'docman'=>'1', 'forumadmin'=>'0', 'forum'=>'1', 'newforum'=>'1', 'trackeradmin'=>'0', 'tracker'=>'2', 'newtracker'=>'2', 'pmadmin'=>'0', 'pm'=>'0' , 'newpm'=>'0' , 'webcal'=>'2')
-			);
-		}
-
-
 		$this->Error();
 		if (!$Group || !is_object($Group) || $Group->isError()) {
 			$this->setError('Role::'.$Group->getErrorMessage());
@@ -81,7 +139,16 @@
 		$hook_params['role'] =& $this;
 		plugin_hook ("role_get", $hook_params);
 
-
+		if ($GLOBALS['default_roles']) {
+			$this->defaults = array_merge_recursive ($this->defaults,
+								 $GLOBALS['default_roles']) ;
+			foreach ($this->defaults as $k => $v) {
+				if (!array_key_exists ($GLOBALS['default_roles'], $k)) {
+					unset ($this->defaults[$k]) ;
+				}
+			}
+		}
+		
 		if (!$role_id) {
 			//setting up an empty object
 			//probably going to call create()




More information about the Fusionforge-commits mailing list