[Fusionforge-commits] r12483 - trunk/src/common/import

Olivier Berger olberger at fusionforge.org
Tue Mar 1 21:55:02 CET 2011


Author: olberger
Date: 2011-03-01 21:55:02 +0100 (Tue, 01 Mar 2011)
New Revision: 12483

Modified:
   trunk/src/common/import/import_arrays.php
   trunk/src/common/import/import_tasks.php
   trunk/src/common/import/import_trackers.php
   trunk/src/common/import/import_users.php
Log:
Get rid of import_arrays if possible


Modified: trunk/src/common/import/import_arrays.php
===================================================================
--- trunk/src/common/import/import_arrays.php	2011-03-01 20:54:50 UTC (rev 12482)
+++ trunk/src/common/import/import_arrays.php	2011-03-01 20:55:02 UTC (rev 12483)
@@ -1,89 +1,6 @@
 <?php
-$equivs_text_value['projectadmin']['None']='0';
-$equivs_text_value['projectadmin']['Admin']='A';
-$equivs_text_value['frs']['Read']='0';
-$equivs_text_value['frs']['Write']='1';
-$equivs_text_value['scm']['No Access']='-1';
-$equivs_text_value['scm']['Read']='0';
-$equivs_text_value['scm']['Write']='1';
-$equivs_text_value['docman']['Read/Post']='0';
-$equivs_text_value['docman']['Admin']='1';
-$equivs_text_value['forumadmin']['None']='0';
-$equivs_text_value['forumadmin']['Admin']='2';
-$equivs_text_value['forum']['No Access']='-1';
-$equivs_text_value['forum']['Read']='0';
-$equivs_text_value['forum']['Post']='1';
-$equivs_text_value['forum']['Admin']='2';
-$equivs_text_value['trackeradmin']['None']='0';
-$equivs_text_value['trackeradmin']['Admin']='2';
-$equivs_text_value['tracker']['No Access']='-1';
-$equivs_text_value['tracker']['Read']='0';
-$equivs_text_value['tracker']['Tech']='1';
-$equivs_text_value['tracker']['Tech & Admin']='2';
-$equivs_text_value['tracker']['Admin Only']='3';
-$equivs_text_value['pmadmin']['None']='0';
-$equivs_text_value['pmadmin']['Admin']='2';
-$equivs_text_value['pm']['No Access']='-1';
-$equivs_text_value['pm']['Read']='0';
-$equivs_text_value['pm']['Tech']='1';
-$equivs_text_value['pm']['Tech & Admin']='2';
-$equivs_text_value['pm']['Admin Only']='3';
-$equivs_text_value['webcal']['No access']='0';
-$equivs_text_value['webcal']['Modify']='1';
-$equivs_text_value['webcal']['See']='2';
 
-$observer_equivs_text_value['projectpublic']['Private']=0;
-$observer_equivs_text_value['projectpublic']['Public']=1;
-$observer_equivs_text_value['scmpublic']['Private']=0;
-$observer_equivs_text_value['scmpublic']['Public (PServer)']=1;
-$observer_equivs_text_value['forumpublic']['Private']=0;
-$observer_equivs_text_value['forumpublic']['Public']=1;
-$observer_equivs_text_value['forumanon']['No Anonymous Posts']=0;
-$observer_equivs_text_value['forumanon']['Allow Anonymous Posts']=1;
-$observer_equivs_text_value['trackerpublic']['Private']=0;
-$observer_equivs_text_value['trackerpublic']['Public']=1;
-$observer_equivs_text_value['trackeranon']['No Anonymous Posts']=0;
-$observer_equivs_text_value['trackeranon']['Allow Anonymous Posts']=1;
-$observer_equivs_text_value['pmpublic']['Private']=0;
-$observer_equivs_text_value['pmpublic']['Public']=1;
-$observer_equivs_text_value['frspackage']['Private']=0;
-$observer_equivs_text_value['frspackage']['Public']=1;
 
-$equivs_name_value['Documentation Manager']='docman';
-$equivs_name_value['File Release System']='frs';
-$equivs_name_value['Forum Admin']='forumadmin';
-$equivs_name_value['Forum:']='forum';
-$equivs_name_value['Project Admin']='projectadmin';
-$equivs_name_value['Tasks Admin']='pmadmin';
-$equivs_name_value['Tasks:']='pm';
-$equivs_name_value['Tracker Admin']='trackeradmin';
-$equivs_name_value['Tracker:']='tracker';
-$equivs_name_value['Webcal']='webcal';
-$equivs_name_value['SCM']='scm';
-
-$observer_equivs_name_value['Project']='projectpublic';
-$observer_equivs_name_value['SCM']='scmpublic';
-$observer_equivs_name_value['Forum:']='forumpublic';
-$observer_equivs_name_value['Forum:AnonPost:']='forumanon';
-$observer_equivs_name_value['Tracker:']='trackerpublic';
-$observer_equivs_name_value['Project']='projectpublic';
-$observer_equivs_name_value['Tracker:AnonPost:']='trackeranon';
-$observer_equivs_name_value['Tasks:']='pmpublic';
-$observer_equivs_name_value['Files']='frspackage';
-
 //Default values for trackers
 
-
-$is_public = 1;
-$allow_anon = 0;
-$email_all = '';
-$email_address = '';
-$due_period = 30;
-$use_resolution = 0;
-$submit_instructions = 0;
-$use_resolution = 0;
-$base_tracker_association = array( 'bugs' => 1, 'support' => 2, 'patches' => 3, 'features' => 4 );
 
-$notExtraFields = array('assigned_to', 'attachments', 'class', 'comments', 'date', 'history', 'priority', 'status_id', 'submitter', 'summary', 'closed_at', 'description', 'type', 'type_of_search', 'id');//last 3 should not be there at all.
-$defaultExtraFieldsSettings = array(0,0,0);
-$defaultTextFieldsSettings = array(40,100,0);

Modified: trunk/src/common/import/import_tasks.php
===================================================================
--- trunk/src/common/import/import_tasks.php	2011-03-01 20:54:50 UTC (rev 12482)
+++ trunk/src/common/import/import_tasks.php	2011-03-01 20:55:02 UTC (rev 12483)
@@ -7,7 +7,7 @@
 require_once $gfcommon.'pm/ProjectGroup.class.php';
 require_once $gfcommon.'pm/ProjectTask.class.php';
 require_once($gfcommon.'include/User.class.php');
-require_once($gfcommon.'import/import_arrays.php');
+//require_once($gfcommon.'import/import_arrays.php');
 
 class Tasks{
 

Modified: trunk/src/common/import/import_trackers.php
===================================================================
--- trunk/src/common/import/import_trackers.php	2011-03-01 20:54:50 UTC (rev 12482)
+++ trunk/src/common/import/import_trackers.php	2011-03-01 20:55:02 UTC (rev 12483)
@@ -6,9 +6,17 @@
 require_once($gfcommon.'include/User.class.php');
 require_once($gfcommon.'tracker/ArtifactExtraField.class.php');
 require_once($gfcommon.'tracker/ArtifactFile.class.php');
-require_once($gfcommon.'import/import_arrays.php');
+//require_once($gfcommon.'import/import_arrays.php');
+
+define('TRACKER_IS_PUBLIC', 1);
+define('TRACKER_ALLOW_ANON', 0);
+define('TRACKER_BUGS', 1);
+define('TRACKER_SUPPORT', 2);
+define('TRACKER_PATCHES', 3);
+define('TRACKER_FEATURES', 4);
+
+static $NOT_EXTRA_FIELDS = array('assigned_to', 'attachments', 'class', 'comments', 'date', 'history', 'priority', 'status_id', 'submitter', 'summary', 'closed_at', 'description', 'type', 'type_of_search', 'id');//last 3 should not be there at all.
 
-
 /**
  * findType - get the type of a field from its name, value, and vocabulary : default 0 (text box), otherwise 1 (select box) or 2 (multi choice field)
  * @param string	Name of the field
@@ -55,17 +63,22 @@
  * @param array	Vocabulary and artifacts for the ArtifactType
  * @return false if failed
  */
-function createFields($at, $data){
+function createFields($at, $data){
+	global $NOT_EXTRA_FIELDS;
 //new dBug($data);
 	//TODO:Create ExtraFields	
-	include $GLOBALS['gfcommon'].'import/import_arrays.php';
+	//include $GLOBALS['gfcommon'].'import/import_arrays.php';
 	$artifactToCheck = $data["artifacts"][0];
 	foreach($artifactToCheck as $fieldName => $fieldValue){
-		if (!in_array($fieldName, $notExtraFields)){
+		if (!in_array($fieldName, $NOT_EXTRA_FIELDS)){
 			$type = findType($fieldName, $fieldValue, $data["vocabulary"]);
-			$aef = new ArtifactExtraField($at);
+			$aef = new ArtifactExtraField($at);
+			
+			$defaultExtraFieldsSettings = array(0,0,0);
+			$defaultTextFieldsSettings = array(40,100,0);
+			
 			if($type==ARTIFACT_EXTRAFIELDTYPE_TEXT){
-				$extraFieldSettings = $defaultTextFieldsSettings;
+				$extraFieldSettings = $defaultTextFieldsSettings;				
 			}
 			else{
 				$extraFieldSettings = $defaultExtraFieldsSettings;
@@ -91,6 +104,7 @@
  * @param array	Tracker data from JSON
  * @return ArtifactType	the tracker created
  */
+
 function createTracker($tracker, $group, $data){
 	//	Create a tracker
 	db_begin();
@@ -99,12 +113,24 @@
 		db_rollback();
 		return false;
 	}
-	include $GLOBALS['gfcommon'].'import/import_arrays.php';
+	//include $GLOBALS['gfcommon'].'import/import_arrays.php';
+	
+	$base_tracker_association = array( 'bugs' => TRACKER_BUGS, 'support' => TRACKER_SUPPORT, 'patches' => TRACKER_PATCHES, 'features' => TRACKER_FEATURES );
 	if(array_key_exists($tracker, $base_tracker_association)){
 		$valueType = $base_tracker_association[$tracker];
 	} else {
 		$valueType = 0;
-	}
+	}
+	
+	$is_public = TRACKER_IS_PUBLIC;
+	$allow_anon = TRACKER_ALLOW_ANON;
+	$email_all = '';
+	$email_address = '';
+	$due_period = 30;
+	$use_resolution = 0;
+	$submit_instructions = 0;
+	$use_resolution = 0;
+	
 	if (!$at->create($data["label"], $data["label"], $is_public, $allow_anon, $email_all, $email_address, $due_period, $use_resolution, $submit_instructions, $use_resolution, $valueType)) {
 		db_rollback();
 		return false;
@@ -213,11 +239,15 @@
 /**
  * createArtifacts - Create all the artifacts for an ArtifactType from an array of data.
  * @param ArtifactType The ArtifactType object which the artifacts to be added belong to.
- * @param array	The data of all the artifacts of the current Type (dictionary)
+ * @param array	The data of all the artifacts of the current Type (dictionary)
+ * @param $hashrn
+ * @param $hashlogin
  */
-function createArtifacts($at, $data, $hashrn, $hashlogin){
+function createArtifacts($at, $data, $hashrn, $hashlogin) {
+	global $NOT_EXTRA_FIELDS;
+	
 	$name_id = array();
-	include $GLOBALS['gfcommon'].'import/import_arrays.php';
+	//include $GLOBALS['gfcommon'].'import/import_arrays.php';
 	$extra_fields_ids = $at->getExtraFields();
 
 
@@ -240,7 +270,7 @@
 		$arti = new Artifact($at);
 		$extra_fields_array = array();
 		foreach($artifact as $fieldName => $fieldValue){
-			if(!in_array($fieldName, $notExtraFields)){
+			if(!in_array($fieldName, $NOT_EXTRA_FIELDS)){
 //new dBug(array($fieldName,$fieldValue));
 				if(is_array($fieldValue)){
 					$mf = array();

Modified: trunk/src/common/import/import_users.php
===================================================================
--- trunk/src/common/import/import_users.php	2011-03-01 20:54:50 UTC (rev 12482)
+++ trunk/src/common/import/import_users.php	2011-03-01 20:55:02 UTC (rev 12483)
@@ -1,6 +1,6 @@
 <?php
 
-require_once('import_arrays.php');
+//require_once('import_arrays.php');
 
 require_once $gfwww.'include/pre.php';
 require_once $gfwww.'project/admin/project_admin_utils.php';
@@ -8,6 +8,81 @@
 require_once $gfcommon.'include/RoleObserver.class.php';
 require_once $gfcommon.'include/rbac_texts.php';
 
+$equivs_text_value['projectadmin']['None']='0';
+$equivs_text_value['projectadmin']['Admin']='A';
+$equivs_text_value['frs']['Read']='0';
+$equivs_text_value['frs']['Write']='1';
+$equivs_text_value['scm']['No Access']='-1';
+$equivs_text_value['scm']['Read']='0';
+$equivs_text_value['scm']['Write']='1';
+$equivs_text_value['docman']['Read/Post']='0';
+$equivs_text_value['docman']['Admin']='1';
+$equivs_text_value['forumadmin']['None']='0';
+$equivs_text_value['forumadmin']['Admin']='2';
+$equivs_text_value['forum']['No Access']='-1';
+$equivs_text_value['forum']['Read']='0';
+$equivs_text_value['forum']['Post']='1';
+$equivs_text_value['forum']['Admin']='2';
+$equivs_text_value['trackeradmin']['None']='0';
+$equivs_text_value['trackeradmin']['Admin']='2';
+$equivs_text_value['tracker']['No Access']='-1';
+$equivs_text_value['tracker']['Read']='0';
+$equivs_text_value['tracker']['Tech']='1';
+$equivs_text_value['tracker']['Tech & Admin']='2';
+$equivs_text_value['tracker']['Admin Only']='3';
+$equivs_text_value['pmadmin']['None']='0';
+$equivs_text_value['pmadmin']['Admin']='2';
+$equivs_text_value['pm']['No Access']='-1';
+$equivs_text_value['pm']['Read']='0';
+$equivs_text_value['pm']['Tech']='1';
+$equivs_text_value['pm']['Tech & Admin']='2';
+$equivs_text_value['pm']['Admin Only']='3';
+$equivs_text_value['webcal']['No access']='0';
+$equivs_text_value['webcal']['Modify']='1';
+$equivs_text_value['webcal']['See']='2';
+
+
+$observer_equivs_text_value['projectpublic']['Private']=0;
+$observer_equivs_text_value['projectpublic']['Public']=1;
+$observer_equivs_text_value['scmpublic']['Private']=0;
+$observer_equivs_text_value['scmpublic']['Public (PServer)']=1;
+$observer_equivs_text_value['forumpublic']['Private']=0;
+$observer_equivs_text_value['forumpublic']['Public']=1;
+$observer_equivs_text_value['forumanon']['No Anonymous Posts']=0;
+$observer_equivs_text_value['forumanon']['Allow Anonymous Posts']=1;
+$observer_equivs_text_value['trackerpublic']['Private']=0;
+$observer_equivs_text_value['trackerpublic']['Public']=1;
+$observer_equivs_text_value['trackeranon']['No Anonymous Posts']=0;
+$observer_equivs_text_value['trackeranon']['Allow Anonymous Posts']=1;
+$observer_equivs_text_value['pmpublic']['Private']=0;
+$observer_equivs_text_value['pmpublic']['Public']=1;
+$observer_equivs_text_value['frspackage']['Private']=0;
+$observer_equivs_text_value['frspackage']['Public']=1;
+
+
+$equivs_name_value['Documentation Manager']='docman';
+$equivs_name_value['File Release System']='frs';
+$equivs_name_value['Forum Admin']='forumadmin';
+$equivs_name_value['Forum:']='forum';
+$equivs_name_value['Project Admin']='projectadmin';
+$equivs_name_value['Tasks Admin']='pmadmin';
+$equivs_name_value['Tasks:']='pm';
+$equivs_name_value['Tracker Admin']='trackeradmin';
+$equivs_name_value['Tracker:']='tracker';
+$equivs_name_value['Webcal']='webcal';
+$equivs_name_value['SCM']='scm';
+
+
+$observer_equivs_name_value['Project']='projectpublic';
+$observer_equivs_name_value['SCM']='scmpublic';
+$observer_equivs_name_value['Forum:']='forumpublic';
+$observer_equivs_name_value['Forum:AnonPost:']='forumanon';
+$observer_equivs_name_value['Tracker:']='trackerpublic';
+$observer_equivs_name_value['Project']='projectpublic';
+$observer_equivs_name_value['Tracker:AnonPost:']='trackeranon';
+$observer_equivs_name_value['Tasks:']='pmpublic';
+$observer_equivs_name_value['Files']='frspackage';
+
 global $cache_forums;
 global $cache_tasks;
 global $cache_trackers;
@@ -304,40 +379,40 @@
                   ... }
 */
 function user_fill($users, $group_id, $check=False){
-	
-  $group =& group_get_object($group_id);
-  if (!$group || !is_object($group)) {
-    exit_error('Error','Could Not Get Group');
-  } elseif ($group->isError()) {
-    exit_error('Error',$group->getErrorMessage());
-  }
 
-  foreach ($users as $user => $role){
-    global $feedback;
-    global $message;
-    $user_object = &user_get_object_by_name($user);
-    if (!$user_object) {
-      $feedback .= sprintf(_('Failed to find user %s'), $user);
-    } else {
-      $user_id = $user_object->getID();
-      $role_id = get_role_by_name($role['role'],$group_id);
-      if(!$check) {
-	if (!$group->addUser($user,$role_id)) {
-	  $feedback = $group->getErrorMessage();
-	} else {
-	  echo 'User added:'.$user.'<br>';
-	  $feedback = _('User Added Successfully');
-	
-	  //plugin webcal
-	  //change assistant for webcal 
-	  $params[0] = $user_id;
-	  $params[1] = $group_id;
-	  plugin_hook('change_cal_permission',$params);
+	$group =& group_get_object($group_id);
+	if (!$group || !is_object($group)) {
+		exit_error('Error','Could Not Get Group');
+	} elseif ($group->isError()) {
+		exit_error('Error',$group->getErrorMessage());
 	}
-      }
-      else {
-	$message .= 'Need to add user: '.$user.' to group with role '. $role_id. "<br />\n";
-      }
-    }
-  }
-}	
+
+	foreach ($users as $user => $role){
+		global $feedback;
+		global $message;
+		$user_object = &user_get_object_by_name($user);
+		if (!$user_object) {
+			$feedback .= sprintf(_('Failed to find user %s'), $user);
+		} else {
+			$user_id = $user_object->getID();
+			$role_id = get_role_by_name($role['role'],$group_id);
+			if(!$check) {
+				if (!$group->addUser($user,$role_id)) {
+					$feedback = $group->getErrorMessage();
+				} else {
+					echo 'User added:'.$user.'<br>';
+					$feedback = _('User Added Successfully');
+
+					//plugin webcal
+					//change assistant for webcal
+					$params[0] = $user_id;
+					$params[1] = $group_id;
+					plugin_hook('change_cal_permission',$params);
+				}
+			}
+			else {
+				$message .= 'Need to add user: '.$user.' to group with role '. $role_id. "<br />\n";
+			}
+		}
+	}
+}




More information about the Fusionforge-commits mailing list