[Fusionforge-commits] r13007 - in trunk/src/plugins/mantisbt: action common view/admin www www/admin www/group www/scripts

Franck VILLAUME nerville at fusionforge.org
Sun Apr 3 17:21:01 CEST 2011


Author: nerville
Date: 2011-04-03 17:21:01 +0200 (Sun, 03 Apr 2011)
New Revision: 13007

Added:
   trunk/src/plugins/mantisbt/action/updateGlobalConf.php
Modified:
   trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
   trunk/src/plugins/mantisbt/view/admin/viewConfiguration.php
   trunk/src/plugins/mantisbt/view/admin/viewGlobalConfiguration.php
   trunk/src/plugins/mantisbt/www/admin/index.php
   trunk/src/plugins/mantisbt/www/group/index.php
   trunk/src/plugins/mantisbt/www/index.php
   trunk/src/plugins/mantisbt/www/scripts/MantisBTController.js
Log:
finalize implementation global conf + tipsy in submenu

Copied: trunk/src/plugins/mantisbt/action/updateGlobalConf.php (from rev 13005, trunk/src/plugins/mantisbt/action/updateConf.php)
===================================================================
--- trunk/src/plugins/mantisbt/action/updateGlobalConf.php	                        (rev 0)
+++ trunk/src/plugins/mantisbt/action/updateGlobalConf.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -0,0 +1,40 @@
+<?php
+/**
+ * MantisBT plugin
+ *
+ * Copyright 2011, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+global $mantisbt; // the mantisbt object
+
+$confArr = array();
+$confArr['url'] = getStringFromRequest('url');
+$confArr['sync_roles'] = 0;
+$confArr['soap_user'] = getStringFromRequest('soap_user');
+$confArr['soap_password'] = getStringFromRequest('soap_password');
+
+if (!$mantisbt->updateGlobalConf($confArr)) {
+	$error_msg = _('Failed to update global configuration.');
+	session_redirect('/plugins/mantisbt/?type=globaladmin&pluginname='.$mantisbt->name.'&error_msg='.urlencode($error_msg));
+}
+
+$feedback = _('MantisBT global configuration successfully updated.');
+session_redirect('/plugins/mantisbt/?type=globaladmin&pluginname='.$mantisbt->name.'&feedback='.urlencode($feedback));
+?>

Modified: trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php
===================================================================
--- trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/common/MantisBTPlugin.class.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -4,6 +4,7 @@
  *
  * Copyright 2009, Fabien Dubois - Capgemini
  * Copyright 2009-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -490,10 +491,18 @@
 
 		$row = db_fetch_array($resIdProjetMantis);
 		$mantisbtConfArray['id_mantisbt'] = $row['id_mantisbt'];
-		$mantisbtConfArray['url'] = $row['url'];
-		$mantisbtConfArray['soap_user'] = $row['soap_user'];
-		$mantisbtConfArray['soap_password'] = $row['soap_password'];
 		$mantisbtConfArray['sync_roles'] = $row['sync_roles'];
+		$mantisbtConfArray['use_global'] = $row['use_global'];
+		if ($mantisbtConfArray['use_global']) {
+			$mantisbtGlobConf = $this->getGlobalconf();
+			$mantisbtConfArray['url'] = $mantisbtGlobConf['url'];
+			$mantisbtConfArray['soap_user'] = $mantisbtGlobConf['soap_user'];
+			$mantisbtConfArray['soap_password'] = $mantisbtGlobConf['soap_password'];
+		} else {
+			$mantisbtConfArray['url'] = $row['url'];
+			$mantisbtConfArray['soap_user'] = $row['soap_user'];
+			$mantisbtConfArray['soap_password'] = $row['soap_password'];
+		}
 		return $mantisbtConfArray;
 	}
 
@@ -767,6 +776,33 @@
 	}
 
 	/**
+	 * updateGlobalConf - update the global configuration in database
+	 *
+	 * @param	array	configuration array (url, soap_user, soap_password)
+	 * @return	bool	true on success
+	 */
+	function updateGlobalConf($confArr) {
+		if (!isset($confArr['url']) || !isset($confArr['soap_user']) || !isset($confArr['soap_password']))
+			return false;
+
+		$res = db_query_params('truncate plugin_mantisbt_global',array());
+		if (!$res)
+			return false;
+
+		$res = db_query_params('insert into plugin_mantisbt_global (url, soap_user, soap_password)
+					values ($1, $2, $3)',
+					array(
+						$confArr['url'],
+						$confArr['soap_user'],
+						$confArr['soap_password'],
+					));
+		if (!$res)
+			return false;
+
+		return true;
+	}
+
+	/**
 	 * getGlobalAdminView - display the Global Admin View
 	 *
 	 * @return	bool	true
@@ -775,8 +811,7 @@
 		global $gfplugins;
 		$user = session_get_user();
 		$use_tooltips = $user->usesTooltips();
-		$mantisbtGlobalConf = $this->getGlobalconf();
-		require_once $gfplugins.$this->name.'/view/admin/viewGlobalConfiguration.php';
+		include $gfplugins.$this->name.'/view/admin/viewGlobalConfiguration.php';
 		return true;
 	}
 }

Modified: trunk/src/plugins/mantisbt/view/admin/viewConfiguration.php
===================================================================
--- trunk/src/plugins/mantisbt/view/admin/viewConfiguration.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/view/admin/viewConfiguration.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -57,7 +57,11 @@
 echo '<tr><td><label id="mantisbtinit-global" ';
 if ($use_tooltips)
 	echo 'title="'._('Use the global configuration defined at forge level').'"';
-echo ' >'._('Use global configuration').'</label></td><td><input id="mantisbtglobalconf" type="checkbox" name="global_conf" /></td></tr>';
+echo ' >'._('Use global configuration').'</label></td><td><input id="mantisbtglobalconf" type="checkbox" name="global_conf" ';
+if ($mantisbtConf['use_global']) {
+	echo 'checked="checked" ';
+}
+echo '/></td></tr>';
 echo '<tr><td><label id="mantisbtinit-url" ';
 if ($use_tooltips)
 	echo 'title="'._('Specify the Full URL of the MantisBT Web Server.').'"';

Modified: trunk/src/plugins/mantisbt/view/admin/viewGlobalConfiguration.php
===================================================================
--- trunk/src/plugins/mantisbt/view/admin/viewGlobalConfiguration.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/view/admin/viewGlobalConfiguration.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -25,9 +25,10 @@
 
 global $HTML;
 global $mantisbt;
-global $mantisbtGlobalConf;
 global $use_tooltips;
 
+$mantisbtGlobalConf = $mantisbt->getGlobalconf();
+
 ?>
 <script type="text/javascript">
 var controller;
@@ -49,8 +50,8 @@
 </script>
 <?php
 
-echo $HTML->boxTop(_('Manage Global configuration'));
-echo '<form method="POST" Action="?type=admin&pluginname='.$mantisbt->name.'&action=updateGlobalConf">';
+echo $HTML->boxTop(_('Manage configuration'));
+echo '<form method="POST" Action="?type=globaladmin&pluginname='.$mantisbt->name.'&action=updateGlobalConf">';
 echo '<table>';
 echo '<tr><td><label id="mantisbtinit-url" ';
 if ($use_tooltips)

Modified: trunk/src/plugins/mantisbt/www/admin/index.php
===================================================================
--- trunk/src/plugins/mantisbt/www/admin/index.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/www/admin/index.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -3,6 +3,7 @@
  * Admin MantisBT page
  *
  * Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -29,6 +30,24 @@
 global $use_tooltips;
 global $view;
 
+?>
+<script type="text/javascript">
+var controller;
+
+jQuery(document).ready(function() {
+	controlerMantisBTMenuControler = new MantisBTMenuControler({
+		tipsyElements:		[
+						{selector: '#roadmapView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#ticketView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#adminView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#statView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+					],
+	});
+});
+
+</script>
+<?php
+
 $mantisbt->getSubMenu($use_tooltips);
 
 switch ($view) {

Modified: trunk/src/plugins/mantisbt/www/group/index.php
===================================================================
--- trunk/src/plugins/mantisbt/www/group/index.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/www/group/index.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -3,6 +3,7 @@
  * Project MantisBT page
  *
  * Copyright 2009-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -28,6 +29,24 @@
 global $gfplugins;
 global $use_tooltips;
 
+?>
+<script type="text/javascript">
+var controller;
+
+jQuery(document).ready(function() {
+	controlerMantisBTMenuControler = new MantisBTMenuControler({
+		tipsyElements:		[
+						{selector: '#roadmapView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#ticketView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#adminView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+						{selector: '#statView', options:{gravity: 'nw', delayIn: 500, delayOut: 0, fade: true}},
+					],
+	});
+});
+
+</script>
+<?php
+
 $mantisbt->getSubMenu($use_tooltips);
 
 // page a afficher

Modified: trunk/src/plugins/mantisbt/www/index.php
===================================================================
--- trunk/src/plugins/mantisbt/www/index.php	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/www/index.php	2011-04-03 15:21:01 UTC (rev 13007)
@@ -5,6 +5,7 @@
  * Copyright 2009-2011, Franck Villaume - Capgemini
  * Copyright 2009, Fabien Dubois - Capgemini
  * Copyright 2010, Antoine Mercadal - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -317,6 +318,14 @@
 		break;
 	}
 	case 'globaladmin': {
+		$action = getStringFromRequest('action');
+		switch ($action) {
+			case 'updateGlobalConf': {
+				global $gfplugins;
+				include($gfplugins.$mantisbt->name.'/action/'.$action.'.php');
+				break;
+			}
+		}
 		$mantisbt->getHeader('globaladmin');
 		$mantisbt->getGlobalAdminView();
 		break;

Modified: trunk/src/plugins/mantisbt/www/scripts/MantisBTController.js
===================================================================
--- trunk/src/plugins/mantisbt/www/scripts/MantisBTController.js	2011-04-03 14:25:25 UTC (rev 13006)
+++ trunk/src/plugins/mantisbt/www/scripts/MantisBTController.js	2011-04-03 15:21:01 UTC (rev 13007)
@@ -53,9 +53,18 @@
 		this.initTipsy();
 	}
 	this.bindControls();
+	this.initCheckboxGlobalConf();
 };
 
+MantisBTMenuControler = function(params)
+{
+	this.params	= params;
 
+	if ( typeof(jQuery(window).tipsy) == 'function') {
+		this.initTipsy();
+	}
+};
+
 MantisBTInitController.prototype =
 {
 	/*! Binds the controls to the actions
@@ -129,6 +138,20 @@
 		}
 	},
 
+	initCheckboxGlobalConf: function() {
+		if (typeof(this.params.checkboxGlobalConf) != "undefined") {
+			if (!this.params.checkboxGlobalConf.is(":checked")) {
+				this.params.inputUrl.attr('disabled',false);
+				this.params.inputUser.attr('disabled',false);
+				this.params.inputPassword.attr('disabled',false);
+			} else {
+				this.params.inputUrl.attr('disabled',true);
+				this.params.inputUser.attr('disabled',true);
+				this.params.inputPassword.attr('disabled',true);
+			}
+		}
+	},
+
 	/*! initializes tipsy
 	*/
 	initTipsy: function() {
@@ -153,4 +176,20 @@
 			this.params.inputPassword.attr('disabled',true);
 		}
 	},
+}
+
+MantisBTMenuControler.prototype =
+{
+	/*! initializes tipsy
+	*/
+	initTipsy: function() {
+		for(var i = 0; i < this.params.tipsyElements.length; i++) {
+			var el = this.params.tipsyElements[i];
+			jQuery(el.selector).tipsy({
+				gravity: el.options.gravity,
+						  delayIn: el.options.delayIn,
+						  delayOut: el.options.delayOut,
+						  fade: el.options.fade});
+		}
+	},
 }
\ No newline at end of file




More information about the Fusionforge-commits mailing list