[Fusionforge-commits] r11703 - in trunk/src: etc/config.ini.d plugins/mantisbt/common plugins/mantisbt/etc

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Sun Dec 5 13:06:36 CET 2010


Author: nerville
Date: 2010-12-05 13:06:36 +0100 (Sun, 05 Dec 2010)
New Revision: 11703

Added:
   trunk/src/etc/config.ini.d/mantisbt.ini
   trunk/src/plugins/mantisbt/etc/mantisbt.ini
Removed:
   trunk/src/etc/config.ini.d/mantisbt.ini
Modified:
   trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
Log:
use plugin_status flag and cleanup

Deleted: trunk/src/etc/config.ini.d/mantisbt.ini
===================================================================
--- trunk/src/etc/config.ini.d/mantisbt.ini	2010-12-04 19:07:38 UTC (rev 11702)
+++ trunk/src/etc/config.ini.d/mantisbt.ini	2010-12-05 12:06:36 UTC (rev 11703)
@@ -1,12 +0,0 @@
-[mantisbt]
-
-server_url = http://localhost/mantis
-adminsoap_user = administrator
-adminsoap_passwd = root
-
-db_type = pgsql
-db_host = locahost
-db_name = mantisbt
-db_port = 5431
-db_user = root
-db_password = root

Added: trunk/src/etc/config.ini.d/mantisbt.ini
===================================================================
--- trunk/src/etc/config.ini.d/mantisbt.ini	                        (rev 0)
+++ trunk/src/etc/config.ini.d/mantisbt.ini	2010-12-05 12:06:36 UTC (rev 11703)
@@ -0,0 +1 @@
+link ../../plugins/mantisbt/etc/mantisbt.ini
\ No newline at end of file


Property changes on: trunk/src/etc/config.ini.d/mantisbt.ini
___________________________________________________________________
Added: svn:special
   + *

Modified: trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
===================================================================
--- trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php	2010-12-04 19:07:38 UTC (rev 11702)
+++ trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php	2010-12-05 12:06:36 UTC (rev 11703)
@@ -60,7 +60,7 @@
 				$text = $this->text; // this is what shows in the tab
 				if ($G_SESSION->usesPlugin($this->name)) {
 					$param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
-					echo ' | ' . $HTML->PrintSubMenu (array ($text), array ('/plugins/mantisbt/index.php' . $param ));
+					echo $HTML->PrintSubMenu(array($text), array('/plugins/mantisbt/index.php' . $param ));
 				}
 				break;
 			}
@@ -79,12 +79,6 @@
 				}
 				break;
 			}
-			case "groupisactivecheckboxpost": {
-				// update users and roles in mantis
-
-
-				break;
-			}
 			case "user_personal_links": {
 				// this displays the link in the user's profile page to it's personal MantisBT (if you want other sto access it, youll have to change the permissions in the index.php
 				$userid = $params['user_id'];
@@ -121,7 +115,7 @@
 						$this->addProjetMantis($group->data_array['group_id'],$group->data_array['group_name'],$group->data_array['is_public'], $group->data_array['short_description']);
 					}
 					// mise a jour des utilisateurs avec les roles
-					$members = array ();
+					$members = array();
 					foreach($group->getMembers() as $member){
 						$members[] = $member->data_array['user_name'];
 					}
@@ -356,10 +350,7 @@
 		$returned = false;
 		global $role;
 
-		// recuperation de id mantis
-		$idMantis = getIdProjetMantis($groupObject->getID());
-
-		// @TODO corriger inclusion bug
+		// @TODO put that in config file ?
 		if ($role == null){
 			$role['Manager'] = 70;
 			$role['Concepteur'] = 55;
@@ -367,7 +358,7 @@
 			$role['Rapporteur'] = 55;
 		}
 
-		// etat forge
+		// @TODO : make a robust function there based on RBAC ?
 		$stateForge = array();
 		foreach ($members as $key => $member){
 			$resUserRole = db_query_params('SELECT role.role_name
@@ -385,40 +376,17 @@
 				$stateForge[$member]['role'] = $row['role_name'];
 			}
 		}
-		// on supprime les precedentes relations dans mantis
-		$dbConnection = db_connect_host(forge_get_config('db_name','mantisbt'), forge_get_config('db_user','mantisbt'), forge_get_config('db_password','mantisbt'), forge_get_config('db_host','mantisbt'), forge_get_config('db_port','mantisbt'));
-		if(!$dbConnection) {
-			$groupObject->setError('updateUsersProjectMantis::'. _('Error : Could not open connection') . db_error($dbConnection));
-			db_rollback($dbConnection);
-		}else{
-			$result = pg_delete($dbConnection,"mantis_project_user_list_table",array("project_id"=>$idMantis));
-			if (!$result){
-				echo 'updateUsersProjectMantis::Error '. _('Unable to clean roles in Mantisbt');
-			}else{
-				foreach($stateForge as $member => $array){
 
-					// recuperation de l'id user dans mantis
-					$resultIdUser = db_query_params('SELECT mantis_user_table.id FROM mantis_user_table WHERE mantis_user_table.username = $1',
-								array($member), '-1', 0, $dbConnection);
-
-					$rowIdUser = db_fetch_array($resultIdUser);
-					$idUser = $rowIdUser['id'];
-					// insertion de la relation
-					$resultInsert = pg_insert($dbConnection,
-									"mantis_project_user_list_table",
-									array("project_id" => $idMantis, "user_id" => $idUser, "access_level" => $role[$array['role']])
-								);
-					if (!isset($resultInsert)) {
-						echo 'updateUsersProjectMantis::Error '. _('Unable to update roles in mantisbt');
-					} else {
-						$returned = true;
-					}
-				}
+		if ($this->__getDBType() === "pgsql") {
+			if ($this->__updateUsersProjectMantisPgsql($groupObject, $stateForge)) {
+				$returned = true;
 			}
 		}
 		return $returned;
 	}
 
+
+
 	function refreshHierarchyMantisBt(){
 		global $sys_mantisbt_host, $sys_mantisbt_db_user, $sys_mantisbt_db_password, $sys_mantisbt_db_port, $sys_mantisbt_db_name;
 
@@ -451,6 +419,67 @@
 		return true;
 	}
 
+	/**
+	 * __updateUsersProjectMantisPgsql - update Users for this project in PostgreSQL DB
+	 *
+	 * @param	object	this Group object
+	 * @param	array	the role of this forge
+	 * @return	boolean	success or not
+	 * @private
+	 */
+	function __updateUsersProjectMantisPgsql(&$groupObject, $stateForge) {
+		$returned = false;
+		$dbConnection = db_connect_host(forge_get_config('db_name','mantisbt'), forge_get_config('db_user','mantisbt'), forge_get_config('db_password','mantisbt'), forge_get_config('db_host','mantisbt'), forge_get_config('db_port','mantisbt'));
+		if(!$dbConnection) {
+			$groupObject->setError('updateUsersProjectMantis::'. _('Error : Could not open connection') . db_error($dbConnection));
+			db_rollback($dbConnection);
+		}else{
+			$idMantis = getIdProjetMantis($groupObject->getID());
+			$result = pg_delete($dbConnection,"mantis_project_user_list_table",array("project_id"=>$idMantis));
+			if (!$result){
+				echo 'updateUsersProjectMantis::Error '. _('Unable to clean roles in Mantisbt');
+			}else{
+				foreach($stateForge as $member => $array){
+
+					$resultIdUser = db_query_params('SELECT mantis_user_table.id FROM mantis_user_table WHERE mantis_user_table.username = $1',
+								array($member), '-1', 0, $dbConnection);
+
+					$rowIdUser = db_fetch_array($resultIdUser);
+					$idUser = $rowIdUser['id'];
+
+					$resultInsert = pg_insert($dbConnection,
+									"mantis_project_user_list_table",
+									array("project_id" => $idMantis, "user_id" => $idUser, "access_level" => $role[$array['role']])
+								);
+					if (!isset($resultInsert)) {
+						echo 'updateUsersProjectMantis::Error '. _('Unable to update roles in mantisbt');
+					} else {
+						$returned = true;
+					}
+				}
+			}
+		}
+		return $returned;
+	}
+
+	/*
+	 * __getDBType - return the type of DB used for mantisbt
+	 *
+	 * @return	string	type of the DB
+	 * @private
+	 */
+	function __getDBType() {
+		switch (forge_get_config('db_name','mantisbt')) {
+			case "pgsql": {
+				return "pgsql";
+				break;
+			}
+			default: {
+				return false;
+				break;
+			}
+		}
+	}
 }
 
 function getIdProjetMantis($idProjet){

Added: trunk/src/plugins/mantisbt/etc/mantisbt.ini
===================================================================
--- trunk/src/plugins/mantisbt/etc/mantisbt.ini	                        (rev 0)
+++ trunk/src/plugins/mantisbt/etc/mantisbt.ini	2010-12-05 12:06:36 UTC (rev 11703)
@@ -0,0 +1,19 @@
+[mantisbt]
+
+; current mantisbt is broken
+; broken means : only available with installation_environment = developpement
+; valid means : production ready
+plugin_status = broken
+
+; Configuration for SOAP API
+server_url = http://localhost/mantis
+adminsoap_user = administrator
+adminsoap_passwd = root
+
+; Configuration for DB access
+db_type = pgsql
+db_host = locahost
+db_name = mantisbt
+db_port = 5431
+db_user = root
+db_password = root




More information about the Fusionforge-commits mailing list