[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1341-g64d451b

Franck Villaume nerville at libremir.placard.fr.eu.org
Mon Jan 16 14:59:22 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  64d451ba1bd08b64c931753fe3884b19b2b2c246 (commit)
       via  3a3621309317eef4f6665e47e2926e72660c5074 (commit)
      from  4d18d6c1b5d1a151268e6cce8d767c57109b3dbb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=64d451ba1bd08b64c931753fe3884b19b2b2c246

commit 64d451ba1bd08b64c931753fe3884b19b2b2c246
Author: St├ęphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Mon Jan 16 14:37:58 2017 +0100

    Tracker: update data on unit deletation

diff --git a/src/common/tracker/EffortUnit.class.php b/src/common/tracker/EffortUnit.class.php
index 156ab76..4b25d0c 100644
--- a/src/common/tracker/EffortUnit.class.php
+++ b/src/common/tracker/EffortUnit.class.php
@@ -262,6 +262,43 @@ class EffortUnit extends FFError {
 			db_rollback();
 			return false;
 		}
+
+		// Update unit define with this unit
+		$res = db_query_params('UPDATE effort_unit AS eu1
+								SET conversion_factor = eu1.conversion_factor*eu2.conversion_factor,
+									to_unit = eu2.to_unit
+								FROM effort_unit AS eu2
+								WHERE
+									eu1.to_unit = eu2.unit_id AND
+									eu2.unit_id = $1',
+								array($this->getID()));
+		if (!$res) {
+			$this->setError(_('Error deleting Effort Unit')._(': ').db_error());
+			db_rollback();
+			return false;
+		}
+
+		// Update extra_field data using this unit
+		$res = db_query_params('WITH t AS (
+									SELECT data_id
+										FROM artifact_extra_field_data
+										INNER JOIN artifact_extra_field_list USING (extra_field_id)
+										INNER JOIN artifact_group_list USING (group_artifact_id)
+									WHERE
+										field_type = $1 AND
+										field_data like $2 AND
+										unit_set_id = $3
+									)
+								UPDATE artifact_extra_field_data AS d
+								SET field_data = $4*CAST(SUBSTRING(field_data FROM \'#"%#"U%\' FOR \'#\') AS INTEGER) || \'U\' || $5 
+								FROM t 	
+								WHERE d.data_id = t.data_id',
+								array(ARTIFACT_EXTRAFIELDTYPE_EFFORT,'%U'.$this->getID(), $this->getEffortUnitSet()->getID(), $this->getConversionFactor(),$this->getToUnit()));
+		if (!$res) {
+			$this->setError(_('Error deleting Effort Unit')._(': ').db_error());
+			db_rollback();
+			return false;
+		}
 		$data_array['is_deleted'] = 1;
 		db_commit();
 		return true;

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=3a3621309317eef4f6665e47e2926e72660c5074

commit 3a3621309317eef4f6665e47e2926e72660c5074
Author: St├ęphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Fri Jan 13 01:00:30 2017 +0100

    Tracker: Extra field type Effort Fix 3

diff --git a/src/common/tracker/EffortUnit.class.php b/src/common/tracker/EffortUnit.class.php
index 32382b1..156ab76 100644
--- a/src/common/tracker/EffortUnit.class.php
+++ b/src/common/tracker/EffortUnit.class.php
@@ -104,6 +104,21 @@ class EffortUnit extends FFError {
 	 * @return	bool	success or not
 	 */
 	function create($name, $conversion_factor, $to_unit, $unit_position = false, $is_base_unit = false, $importData = array()) {
+		if (!ctype_digit(strval($conversion_factor)) || $conversion_factor<1) {
+			$this->setError(_('Conversion factor must be an integer greater or equal to 1'));
+			return false;
+		}
+		$name = trim($name);
+		if ($name=='') {
+			$this->setError(_('An Unit name is required'));
+			return false;
+		}
+		$res = db_query_params('SELECT 1 FROM effort_unit WHERE unit_name = $1 AND unit_set_id = $2', array(htmlspecialchars($name), $this->EffortUnitSet->GetID()));
+		if (db_numrows($res) > 0) {
+			$this->setError(sprintf(_('Unit name %s already exist'),$name));
+			return false;
+		}
+		
 		db_begin();
 		if(array_key_exists('user', $importData)){
 			$user = $importData['user'];
@@ -118,8 +133,18 @@ class EffortUnit extends FFError {
 		if ($is_base_unit) {
 			$to_unit = 1;
 		}
+		
+		if (!$unit_position) {
+			
+			$res = db_query_params('SELECT MAX(unit_position) AS max_position FROM effort_unit WHERE unit_set_id = $1', array($this->EffortUnitSet->GetID()));
+			if (db_numrows($res) > 0) {
+				$unit_position =  db_result($res, 0, 'max_position') + 1;
+			} else {
+				return 0;
+			}
+		}
 		$res = db_query_params('INSERT INTO effort_unit(unit_set_id, unit_name, conversion_factor, to_unit, unit_position, is_base_unit, created_date, created_by, modified_date, modified_by) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)',
-				array($this->EffortUnitSet->GetID(), $name, $conversion_factor, $to_unit, $unit_position, ($is_base_unit?1:0), $time, $user, $time, $user));
+				array($this->EffortUnitSet->GetID(), htmlspecialchars($name), $conversion_factor, $to_unit, $unit_position, ($is_base_unit?1:0), $time, $user, $time, $user));
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setError(_('Error')._(':').' '._('Cannot create Effort Unit')._(':').' '.db_error());
 			db_rollback();
@@ -243,6 +268,20 @@ class EffortUnit extends FFError {
 	}
 
 	function update($name, $conversion_factor, $to_unit, $importData = array()){
+		if (!ctype_digit(strval($conversion_factor)) || $conversion_factor<1) {
+			$this->setError(_('Conversion factor must be an integer greater or equal to 1'));
+			return false;
+		}
+		$name = trim($name);
+		if ($name=='') {
+			$this->setError(_('An Unit name is required'));
+			return false;
+		}
+		$res = db_query_params('SELECT 1 FROM effort_unit WHERE unit_name = $1 AND unit_set_id = $2', array(htmlspecialchars($name), $this->EffortUnitSet->GetID()));
+		if (db_numrows($res) > 0) {
+			$this->setError(sprintf(_('Unit name %s already exist'),$name));
+			return false;
+		}
 		db_begin();
 		if(array_key_exists('user', $importData)){
 			$user = $importData['user'];
@@ -255,7 +294,7 @@ class EffortUnit extends FFError {
 			$time = time();
 		}
 		$res = db_query_params('UPDATE effort_unit SET unit_name=$1, conversion_factor=$2, to_unit=$3, modified_date=$4, modified_by=$5 WHERE unit_id=$6',
-				array($name, $conversion_factor, $to_unit, $time, $user, $this->getID()));
+				array(htmlspecialchars($name), $conversion_factor, $to_unit, $time, $user, $this->getID()));
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setError(_('Error')._(':').' '._('Cannot update Effort Unit')._(':').' '.db_error());
 			db_rollback();
diff --git a/src/common/tracker/EffortUnitSet.class.php b/src/common/tracker/EffortUnitSet.class.php
index 47d3b53..00d23ac 100644
--- a/src/common/tracker/EffortUnitSet.class.php
+++ b/src/common/tracker/EffortUnitSet.class.php
@@ -194,7 +194,7 @@ class EffortUnitSet extends FFError {
 	function _recursive_copy($from_unit) {
 		$new_unit = new EffortUnit($this);
 		$new_unit_id = $new_unit->copy($from_unit);
-		$from_unit_set = $from_unit->getEffortUnits();
+		$from_unit_set = $from_unit->getEffortUnitSet();
 		$from_unit_factory = new EffortUnitFactory($from_unit_set);
 		$units = $from_unit_factory->getUnits();
 		foreach ($units as $unit) {
diff --git a/src/common/tracker/actions/effort_units.php b/src/common/tracker/actions/effort_units.php
index 641edb0..806fa95 100644
--- a/src/common/tracker/actions/effort_units.php
+++ b/src/common/tracker/actions/effort_units.php
@@ -296,12 +296,12 @@ function add_unit(&$effortUnitSet){
 	echo $inputParameters;
 	echo html_e('input', array('type'=>'hidden', 'name'=>'function', 'value'=>'postadd'));
 	echo html_ao('p');
-	echo html_e('label', array('for'=>'name'),_('Name'));
-	echo html_e('input', array('type'=>'text', 'name'=>'name', 'id'=>'name'));
+	echo html_e('label', array('for'=>'name'),_('Name').utils_requiredField()._(': '));
+	echo html_e('input', array('type'=>'text', 'name'=>'name', 'id'=>'name', 'required'=>'required'));
 	echo html_ac(html_ap() - 1);
 	echo html_ao('p');
-	echo html_e('label', array('for'=>'factor'),_('Definition'));
-	echo html_e('input', array('type'=>'number', 'name'=>'factor', 'id'=>'factor', 'min'=>0));
+	echo html_e('label', array('for'=>'factor'),_('Definition').utils_requiredField()._(': '));
+	echo html_e('input', array('type'=>'number', 'name'=>'factor', 'id'=>'factor', 'min'=>1, 'required'=>'required'));
 	$unitFactory = new EffortUnitFactory($effortUnitSet);
 	$unitsArr = $unitFactory->getUnitsArr();
 	echo html_build_select_box_from_array($unitsArr, 'to_unit');
@@ -359,16 +359,16 @@ function edit_unit (&$effortUnitSet) {
 	echo html_e('input', array('type'=>'hidden', 'name'=>'form_key', 'value'=>form_generate_key()));
 	echo $inputParameters;
 	echo html_ao('p');
-	echo html_e('label', array('for'=>'name'),_('Name'));
-	echo html_e('input', array('type'=>'text', 'name'=>'name', 'id'=>'name', 'value'=> $unit->getName()));
+	echo html_e('label', array('for'=>'name'),_('Name').utils_requiredField()._(': '));
+	echo html_e('input', array('type'=>'text', 'name'=>'name', 'id'=>'name', 'value'=> $unit->getName(), 'required'=>'required'));
 	echo html_ac(html_ap() - 1);
 	if ($unit->isBaseUnit()) {
 		echo html_e('input', array('type'=>'hidden', 'name'=>'factor', 'value'=>1 ));
 		echo html_e('input', array('type'=>'hidden', 'name'=>'to_unit', 'value'=>$unit->getToUnit() ));
 	} else {
 		echo html_ao('p');
-		echo html_e('label', array('for'=>'factor'),_('Definition'));
-		echo html_e('input', array('type'=>'number', 'name'=>'factor', 'id'=>'factor', 'min'=>0, 'value'=> $unit->getConversionFactor()));
+		echo html_e('label', array('for'=>'factor'),_('Definition').utils_requiredField()._(': '));
+		echo html_e('input', array('type'=>'number', 'name'=>'factor', 'id'=>'factor', 'min'=>1, 'value'=> $unit->getConversionFactor()));
 		$unitFactory = new EffortUnitFactory($effortUnitSet);
 		$unitsArr = $unitFactory->getUnitsArr();
 		unset($unitsArr[$unit->getID()]);
@@ -449,6 +449,7 @@ function postdelete_unit(&$effortUnitSet) {
 		echo $HTML->error_msg(_('You haven\' confirm the delete of the Unit'));
 		return false;
 	}
+	$name = $unit->getName();
 	$unit->delete();
 	if ($unit->isError()) {
 		echo $HTML->error_msg($unit->getErrorMessage());

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/EffortUnit.class.php     | 80 ++++++++++++++++++++++++++++-
 src/common/tracker/EffortUnitSet.class.php  |  2 +-
 src/common/tracker/actions/effort_units.php | 17 +++---
 3 files changed, 88 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list