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

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


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

Modified:
   trunk/gforge/common/include/Role.class.php
Log:
Allow delegating role settings normalization to plugins too

Modified: trunk/gforge/common/include/Role.class.php
===================================================================
--- trunk/gforge/common/include/Role.class.php	2010-04-14 14:14:31 UTC (rev 9478)
+++ trunk/gforge/common/include/Role.class.php	2010-04-14 14:14:41 UTC (rev 9479)
@@ -331,26 +331,36 @@
 		return true;
 	}
 
+	function normalizeDataForSection (&$new_sa, $section) {
+		if (array_key_exists ($section, $this->setting_array)) {
+			$new_sa[$section][0] = $this->setting_array[$section][0] ;
+		} elseif (array_key_exists ($this->data_array['role_name'], $this->defaults)
+			  && array_key_exists ($section, $this->defaults[$this->data_array['role_name']])) {
+			$new_sa[$section][0] = $this->defaults[$this->data_array['role_name']][$section] ;
+		} else {
+			$new_sa[$section][0] = 0 ;
+		}
+		return $new_sa ;
+	}
+
 	function normalizeData () {
 		db_begin () ;
 		$this->fetchData ($this->getID()) ;
 		
 		$new_sa = array () ;
-
+		
 		// Add missing settings
 		// ...project-wide settings
 		$arr = array ('projectadmin', 'frs', 'scm', 'docman', 'forumadmin', 'trackeradmin', 'newtracker', 'pmadmin', 'newpm', 'webcal') ;
 		foreach ($arr as $section) {
-			if (array_key_exists ($section, $this->setting_array)) {
-				$new_sa[$section][0] = $this->setting_array[$section][0] ;
-			} elseif (array_key_exists ($this->data_array['role_name'], $this->defaults)
-						    && array_key_exists ($section, $this->defaults[$this->data_array['role_name']])) {
-					  $new_sa[$section][0] = $this->defaults[$this->data_array['role_name']][$section] ;
-			} else {
-				$new_sa[$section][0] = 0 ;
-			}
+			$this->normalizeDataForSection ($new_sa, $section) ;
 		}
 
+		$hook_params = array ();
+		$hook_params['role'] =& $this;
+		$hook_params['new_sa'] =& $new_sa ; 
+		plugin_hook ("role_normalize", $hook_params);
+		
 		// ...tracker-related settings
 		$new_sa['tracker'] = array () ;
 		$res = db_query_params ('SELECT group_artifact_id FROM artifact_group_list WHERE group_id=$1',




More information about the Fusionforge-commits mailing list