[Fusionforge-commits] FusionForge branch master updated. 6.0.4-636-g7808787

Franck Villaume nerville at libremir.placard.fr.eu.org
Mon Jul 4 13:03:20 CEST 2016


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  780878706a186d23b8635c53b35b29802e583483 (commit)
       via  ef2d60dff6aede8c70525ed5826a02bba562c9e4 (commit)
      from  956c614125dbb1325ed628d015ca2a55e6478769 (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=780878706a186d23b8635c53b35b29802e583483

commit 780878706a186d23b8635c53b35b29802e583483
Author: Stéphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Mon Jul 4 12:47:17 2016 +0200

    Tracker: Auto Assign, fix comment

diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 50deb5f..0a808b5 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -327,7 +327,7 @@ class ArtifactTypeHtml extends ArtifactType {
 
 				$str = $this->renderRelationField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
 				if ($mode == 'UPDATE') {
-					$post_name = html_image('ic/forum_edit.gif', 37, 15, array('title'=>"Click to edit", 'alt'=>"Click to edit", 'onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
+					$post_name = html_image('ic/forum_edit.gif','37','15',array('title'=>"Click to edit", 'alt'=>"Click to edit", 'onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
 				}
 			} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_USER) {
 				$str = $this->renderUserField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);

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

commit ef2d60dff6aede8c70525ed5826a02bba562c9e4
Author: Stéphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Mon Jul 4 12:39:25 2016 +0200

    Tracker: Auto Assign

diff --git a/src/common/tracker/Artifact.class.php b/src/common/tracker/Artifact.class.php
index ae9f774..1856bf8 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -904,8 +904,26 @@ class Artifact extends FFError {
 			$description=htmlspecialchars_decode($this->getDetails());
 			$canned_response=100;
 			$new_artifact_type_id=$this->ArtifactType->getID();
-			$assigned_to=$this->getAssignedTo();
-
+			$autoAssignField = $this->getArtifactType()->getAutoAssignField();
+			if ($autoAssignField!=100) {
+				$ef = new ArtifactExtraField($this->getArtifactType(),$autoAssignField);
+				if (!$ef || !is_object($ef)) {
+					exit_error(_('Unable to create ArtifactExtraField Object'),'tracker');
+				} elseif ($ef->isError()) {
+					exit_error($ef->getErrorMessage(),'tracker');
+				} else {
+					$efe = new ArtifactExtraFieldElement($ef,$extra_fields[$autoAssignField]);
+					if (!$efe || !is_object($efe)) {
+						exit_error(_('Unable to create ArtifactExtraFieldElement Object'),'tracker');
+					} elseif ($efe->isError()) {
+						exit_error($efe->getErrorMessage(),'tracker');
+					} else {
+						$assigned_to = $efe->getAutoAssignto();
+					}
+				}
+			} else {
+				$assigned_to=$this->getAssignedTo();
+			}
 			if (!forge_check_perm ('tracker', $this->ArtifactType->getID(), 'tech')) {
 				$this->setPermissionDeniedError();
 				return false;
diff --git a/src/common/tracker/ArtifactExtraField.class.php b/src/common/tracker/ArtifactExtraField.class.php
index 76f31fb..b82570b 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -104,9 +104,10 @@ class ArtifactExtraField extends FFError {
 	 * @param	string	$description	Description used for help text.
 	 * @param	string	$pattern	A regular expression to check the field.
 	 * @param	int	$parent		Parent extra field id.
+	 * @param	int	$autoassign	True or false whether it triggers auto-assignment rules
 	 * @return	bool	true on success / false on failure.
 	 */
-	function create($name, $field_type, $attribute1, $attribute2, $is_required = 0, $alias = '', $show100 = true, $show100label = 'none', $description = '', $pattern='', $parent=100) {
+	function create($name, $field_type, $attribute1, $attribute2, $is_required = 0, $alias = '', $show100 = true, $show100label = 'none', $description = '', $pattern='', $parent=100, $autoassign=0) {
 		//
 		//	data validation
 		//
@@ -149,13 +150,11 @@ class ArtifactExtraField extends FFError {
 		}  elseif ($field_type == ARTIFACT_EXTRAFIELDTYPE_USER) {
 			$show100label='nobody';
 		}
-		if ($is_required) {
-			$is_required=1;
-		} else {
-			$is_required=0;
-		}
+		$is_required = ($is_required ? 1 : 0);
+		$autoassign = ($autoassign ? 1 : 0);
 
 		if (!($alias = $this->generateAlias($alias,$name))) {
+			$this->setError(_('Unable to generate alias'));
 			return false;
 		}
 
@@ -185,8 +184,13 @@ class ArtifactExtraField extends FFError {
 				db_rollback();
 				return false;
 			}
+			if ($autoassign && $this->setAutoAssign()) {
+				$this->setError(_('Unable to set Auto Assign Field')._(':').db_error());
+				return false;
+			}
 			if ($field_type == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
 				if (!$this->ArtifactType->setCustomStatusField($id)) {
+					$this->setError(_('Unable to set Custom Status Field')._(':').db_error());
 					db_rollback();
 					return false;
 				} else {
@@ -195,18 +199,18 @@ class ArtifactExtraField extends FFError {
 					//
 					$ao = new ArtifactExtraFieldElement($this);
 					if (!$ao || !is_object($ao)) {
-						$feedback .= 'Unable to create ArtifactExtraFieldElement Object';
+						$this->setError(_('Unable to create ArtifactExtraFieldElement Object'));
 						db_rollback();
 						return false;
 					} else {
 						if (!$ao->create('Open', '1')) {
-							$feedback .= _('Insert Error')._(': ').$ao->getErrorMessage();
+							$this->setError(_('Insert Error')._(': ').$ao->getErrorMessage());
 							$ao->clearError();
 							db_rollback();
 							return false;
 						}
 						if (!$ao->create('Closed', '2')) {
-							$feedback .= _('Insert Error')._(': ').$ao->getErrorMessage();
+							$this->setError(_('Insert Error')._(': ').$ao->getErrorMessage());
 							$ao->clearError();
 							db_rollback();
 							return false;
@@ -417,6 +421,38 @@ class ArtifactExtraField extends FFError {
 	}
 
 	/**
+	 * isAutoAssign
+	 *
+	 * @return	boolean	assign.
+	 */
+	function isAutoAssign() {
+		if ($this->getArtifactType()->getAutoAssignField() == $this->getID()) {
+			return true;
+		}
+		else {
+			return false;
+		}
+	}
+
+	/**
+	 * setAutoAssign - set this field that triggers auto-assignment rules.
+	 *
+	 * @return	boolean
+	 */
+	function setAutoAssign() {
+		return $this->getArtifactType()->setAutoAssignField($this->getID());
+	}
+
+	/**
+	 * unsetAutoAssign - unset this field that triggers auto-assignment rules.
+	 *
+	 * @return	boolean
+	 */
+	function unsetAutoAssign() {
+		return $this->getArtifactType()->setAutoAssignField(100);
+	}
+
+	/**
 	 * getAvailableTypes - the types of text fields and their names available.
 	 *
 	 * @return	array	types.
@@ -520,7 +556,7 @@ class ArtifactExtraField extends FFError {
 	 * @param	int	$parent		Parent extra field id.
 	 * @return	bool	success.
 	 */
-	function update($name, $attribute1, $attribute2, $is_required = 0, $alias = "", $show100 = true, $show100label = 'none', $description = '', $pattern='', $parent=100) {
+	function update($name, $attribute1, $attribute2, $is_required = 0, $alias = "", $show100 = true, $show100label = 'none', $description = '', $pattern='', $parent=100, $autoassign=0) {
 		if (!forge_check_perm ('tracker_admin', $this->ArtifactType->Group->getID())) {
 			$this->setPermissionDeniedError();
 			return false;
@@ -542,11 +578,9 @@ class ArtifactExtraField extends FFError {
 			$this->setError(_('Field name already exists'));
 			return false;
 		}
-		if ($is_required) {
-			$is_required=1;
-		} else {
-			$is_required=0;
-		}
+
+		$is_required = ($is_required ? 1 : 0);
+		$autoassign = ($autoassign ? 1 : 0);
 
 		if (!($alias = $this->generateAlias($alias,$name))) {
 			return false;
@@ -577,6 +611,18 @@ class ArtifactExtraField extends FFError {
 							  $this->getID(),
 							  $this->ArtifactType->getID())) ;
 		if ($result && db_affected_rows($result) > 0) {
+			if ($autoassign && !$this->isAutoAssign()) {
+				if (!$this->setAutoAssign()) {
+					$this->setError(_('Unable to set Auto Assign Field')._(':').db_error());
+					return false;
+				}
+			}
+			if (!$autoassign && $this->isAutoAssign()) {
+				if (!$this->unsetAutoAssign()) {
+					$this->setError(_('Unable to unset Auto Assign Field')._(':').db_error());
+					return false;
+				}
+			}
 			return true;
 		} else {
 			$this->setError(db_error());
@@ -613,6 +659,12 @@ class ArtifactExtraField extends FFError {
 							return false;
 						}
 					}
+					if ($this->isAutoAssign()) {
+						if (!$this->unsetAutoAssign()) {
+							db_rollback();
+							return false;
+						}
+					}
 					db_commit();
 					return true;
 				} else {
diff --git a/src/common/tracker/ArtifactExtraFieldElement.class.php b/src/common/tracker/ArtifactExtraFieldElement.class.php
index f6b44c0..5d67f85 100644
--- a/src/common/tracker/ArtifactExtraFieldElement.class.php
+++ b/src/common/tracker/ArtifactExtraFieldElement.class.php
@@ -101,7 +101,7 @@ class ArtifactExtraFieldElement extends FFError {
 	 * @param	int	$status_id	Id the box that contains the choice (optional).
 	 * @return	bool	true on success / false on failure.
 	 */
-	function create($name,$status_id=0) {
+	function create($name,$status_id=0,$auto_assign_to=100) {
 		//
 		//	data validation
 		//
@@ -129,10 +129,11 @@ class ArtifactExtraFieldElement extends FFError {
 			return false;
 		}
 		db_begin();
-		$result = db_query_params ('INSERT INTO artifact_extra_field_elements (extra_field_id,element_name,status_id) VALUES ($1,$2,$3)',
+		$result = db_query_params ('INSERT INTO artifact_extra_field_elements (extra_field_id,element_name,status_id,auto_assign_to) VALUES ($1,$2,$3,$4)',
 					   array ($this->ArtifactExtraField->getID(),
 						  htmlspecialchars($name),
-						  $status_id)) ;
+						  $status_id,
+						  $auto_assign_to));
 		if ($result && db_affected_rows($result) > 0) {
 			$this->clearError();
 			$id=db_insertid($result,'artifact_extra_field_elements','element_id');
@@ -223,6 +224,15 @@ class ArtifactExtraFieldElement extends FFError {
 	}
 
 	/**
+	 * getAutoAssignedUser - return id of the user witch issue is auto assign to.
+	 *
+	 * @return	integer user id.
+	 */
+	function getAutoAssignto() {
+		return $this->data_array['auto_assign_to'];
+	}
+
+	/**
 	 * getParentElements - return the list of the elements of the parent field on which depends the current element
 	 *
 	 * @return	array of parent elements
@@ -339,7 +349,7 @@ class ArtifactExtraFieldElement extends FFError {
 	 * @param	int	$status_id	optional for status box - maps to either open/closed.
 	 * @return	bool	success.
 	 */
-	function update($name,$status_id=0) {
+	function update($name,$status_id=0,$auto_assign_to=100) {
 		if (!forge_check_perm ('tracker_admin', $this->ArtifactExtraField->ArtifactType->Group->getID())) {
 			$this->setPermissionDeniedError();
 			return false;
@@ -365,10 +375,11 @@ class ArtifactExtraFieldElement extends FFError {
 			$status_id=0;
 		}
 		$result = db_query_params ('UPDATE artifact_extra_field_elements
-			SET element_name=$1, status_id=$2
-			WHERE element_id=$3',
+			SET element_name=$1, status_id=$2, auto_assign_to=$3
+			WHERE element_id=$4',
 					   array (htmlspecialchars($name),
 						  $status_id,
+						  $auto_assign_to,
 						  $this->getID())) ;
 		if ($result && db_affected_rows($result) > 0) {
 			return true;
diff --git a/src/common/tracker/ArtifactType.class.php b/src/common/tracker/ArtifactType.class.php
index c071898..3a2fbaa 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -466,6 +466,29 @@ class ArtifactType extends FFError {
 	}
 
 	/**
+	 * getAutoAssignField - get the extra_field_id of the field that triggers auto-assignment rules.
+	 *
+	 * @return	int	extra_field_id.
+	 */
+	function getAutoAssignField() {
+		return $this->data_array['auto_assign_field'];
+	}
+
+	/**
+	 * setAutoAssignField - set the extra_field_id of the field that triggers auto-assignment rules.
+	 *
+	 * @param	int	$extra_field_id	The extra field id.
+	 * @return	boolean	success.
+	 */
+	function setAutoAssignField($extra_field_id) {
+		$res = db_query_params('UPDATE artifact_group_list SET auto_assign_field=$1
+			WHERE group_artifact_id=$2',
+				array ($extra_field_id,
+				       $this->getID()));
+		return $res;
+	}
+
+	/**
 	 * usesCustomStatuses - boolean
 	 *
 	 * @return	boolean	use_custom_statues.
diff --git a/src/common/tracker/actions/admin-updates.php b/src/common/tracker/actions/admin-updates.php
index 4ca6abe..4633603 100644
--- a/src/common/tracker/actions/admin-updates.php
+++ b/src/common/tracker/actions/admin-updates.php
@@ -45,7 +45,7 @@ if (getStringFromRequest('add_extrafield')) {
 	$alias = getStringFromRequest('alias');
 	$hide100 = getStringFromRequest('hide100');
 	$show100label = getStringFromRequest('show100label');
-
+	$autoassign = getStringFromRequest('autoassign');
 	$ab = new ArtifactExtraField($ath);
 
 	if (!$ab || !is_object($ab)) {
@@ -58,7 +58,7 @@ if (getStringFromRequest('add_extrafield')) {
 		} else {
 			$show100 = 1;
 		}
-		if (!$ab->create($name, $field_type, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description, $pattern, $parent)) {
+		if (!$ab->create($name, $field_type, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description, $pattern, $parent, $autoassign)) {
 			$error_msg .= _('Error inserting a custom field')._(': ').$ab->getErrorMessage();
 			$ab->clearError();
 		} else {
@@ -240,7 +240,7 @@ if (getStringFromRequest('add_extrafield')) {
 	$alias = getStringFromRequest('alias');
 	$hide100 = getStringFromRequest('hide100');
 	$show100label = getStringFromRequest('show100label');
-
+	$autoassign = getStringFromRequest('autoassign');
 	$ac = new ArtifactExtraField($ath, $id);
 	if (!$ac || !is_object($ac)) {
 		$error_msg .= _('Unable to create ArtifactExtraField Object');
@@ -252,7 +252,7 @@ if (getStringFromRequest('add_extrafield')) {
 		} else {
 			$show100 = 1;
 		}
-		if (!$ac->update($name, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description, $pattern, $parent)) {
+		if (!$ac->update($name, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description, $pattern, $parent, $autoassign)) {
 			$error_msg .= _('Update failed')._(': ').$ac->getErrorMessage();
 			$ac->clearError();
 		} else {
@@ -265,16 +265,14 @@ if (getStringFromRequest('add_extrafield')) {
 //	Update an Element
 //
 } elseif (getStringFromRequest('update_opt')) {
-	$id = getStringFromRequest('id');
 	$boxid = getStringFromRequest('boxid');
-	$parentElements = getStringFromRequest('parent_elements');
-
 	$ac = new ArtifactExtraField($ath,$boxid);
 	if (!$ac || !is_object($ac)) {
 		$error_msg .= _('Unable to create ArtifactExtraField Object');
 	} elseif ($ac->isError()) {
 		$error_msg .= $ac->getErrorMessage();
 	} else {
+		$id = getStringFromRequest('id');
 		$ao = new ArtifactExtraFieldElement($ac,$id);
 		if (!$ao || !is_object($ao)) {
 			$error_msg .= _('Unable to create ArtifactExtraFieldElement Object');
@@ -283,7 +281,8 @@ if (getStringFromRequest('add_extrafield')) {
 		} else {
 			$name = getStringFromRequest('name');
 			$status_id = getIntFromRequest('status_id');
-			if (!$ao->update($name,$status_id)) {
+			$autoAssignTo = getStringFromRequest('auto_assign_to');
+			if (!$ao->update($name,$status_id,$autoAssignTo)) {
 				$error_msg .= _('Update failed')._(': ').$ao->getErrorMessage();
 				$ao->clearError();
 			} else {
diff --git a/src/common/tracker/actions/browse.php b/src/common/tracker/actions/browse.php
index 9a3571c..251bf9c 100644
--- a/src/common/tracker/actions/browse.php
+++ b/src/common/tracker/actions/browse.php
@@ -732,7 +732,7 @@ if ($art_arr && $art_cnt > 0) {
 				$sel[$keys[$i]]='100';
 			}
 		}
-		$ath->renderExtraFields($sel,true,_('No Change'),false,'', array(ARTIFACT_EXTRAFIELD_FILTER_INT),true);
+		$ath->renderExtraFields($sel,true,_('No Change'),false,'', array(ARTIFACT_EXTRAFIELD_FILTER_INT),true,'UPDATE');
 		echo '<tr>';
 		echo '<td><strong>'._('Priority')._(':').'</strong><br />';
 		echo build_priority_select_box ('priority', '100', true);
diff --git a/src/common/tracker/actions/mod-limited.php b/src/common/tracker/actions/mod-limited.php
index bb5ced2..fc81746 100644
--- a/src/common/tracker/actions/mod-limited.php
+++ b/src/common/tracker/actions/mod-limited.php
@@ -147,7 +147,7 @@ if (session_loggedin()) {
 			<strong><?php echo _('State')._(':'); ?></strong><br />
 			<span id="tracker-status_id" title="<?php echo util_html_secure(html_get_tooltip_description('status_id_tracker')) ?>">
 			<?php echo $ath->statusBox ('status_id', $ah->getStatusID() ); ?>
-			<span>
+			</span>
 		</td>
 		<td>
 		</td>
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 8ef2679..50deb5f 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -31,6 +31,7 @@ require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
 require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
 require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
 require_once $gfcommon.'include/utils_crossref.php';
+require_once $gfcommon.'include/UserManager.class.php';
 
 class ArtifactTypeHtml extends ArtifactType {
 
@@ -346,6 +347,18 @@ class ArtifactTypeHtml extends ArtifactType {
 		}
 		return false;
 	};
+	$(".autoassign[name^='extra_fields']").on('change', function(){
+		if ($(this).prop('tagName') == 'SELECT') {
+			var elmnts = $(this).children('option:selected');
+		} else {
+			var elmnts = $(this).siblings('input:checked');
+		}
+		elmnts.each(function(i){
+			var aat = $(this).data("autoassignto");
+			$("select#tracker-assigned_to option[value="+aat.id+"]").prop('selected', true);
+			$("span#tracker-assigned_to").text(aat.name);
+		});
+	});
 	$(".with-depcy[name^='extra_fields']").on('change', function(){
 		if ($(this).prop('tagName') == 'SELECT') {
 			var elmnts = $(this).children('option:selected');
@@ -659,6 +672,9 @@ EOS;
 		if (!empty($aefChildren)) {
 			$attrs['class'] = (empty($attrs['class']) ? '':$attrs['class'].' ').'with-depcy';
 		}
+		if ($aef->isAutoAssign())  {
+			$attrs['class'] = (empty($attrs['class']) ? '':$attrs['class'].' ').'autoassign';
+		}
 		$vals = array();
 		$texts = array();
 		$opt_attrs = array();
@@ -682,6 +698,10 @@ EOS;
 					$opt_attrs[$i]= array( 'data-dependency'=>$dependency);
 				}
 			}
+			if ($aef->isAutoAssign()) {
+				$autoAssignTo = UserManager::instance()->getUserById($aefe->getAutoAssignto());
+				$opt_attrs[$i]=array_merge(isset($opt_attrs[$i]) ? $opt_attrs[$i] : array(), array( 'data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
+			}
 		}
 
 		if ($show_100 && !empty($aefChildren)) {
@@ -775,6 +795,10 @@ EOS;
 					$radios_attrs[$i]['data-dependency']=$dependency;
 				}
 			}
+			if ($aef->isAutoAssign()) {
+				$autoAssignTo = UserManager::instance()->getUserById($aefe->getAutoAssignto());
+				$radios_attrs[$i]=array_merge(isset($radios_attrs[$i]) ? $radios_attrs[$i] : array(), array( 'data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
+			}
 		}
 		if ($show_100 && !empty($aefChildren)) {
 			$attrs_100 = array( 'data-dependency'=>'{"fields": ['.implode(', ',$aefChildren).']}');
diff --git a/src/common/tracker/views/form-addextrafield.php b/src/common/tracker/views/form-addextrafield.php
index 4de2cac..71d4571 100644
--- a/src/common/tracker/views/form-addextrafield.php
+++ b/src/common/tracker/views/form-addextrafield.php
@@ -44,8 +44,11 @@ if ($rows > 0) {
 	$title_arr=array();
 	$title_arr[]=_('Custom Fields Defined');
 	$title_arr[]=_('Type');
+	$title_arr[]=_('Auto Assign');
+	$title_arr[]=_('Depend on');
 	$title_arr[]=_('Elements Defined');
 	$title_arr[]=_('Add Options');
+	$autoAssignFieldId = $ath->getAutoAssignField();
 	echo $HTML->listTableTop($title_arr);
 	$rownb = 0;
 	for ($k=0; $k < $rows; $k++) {
@@ -59,6 +62,17 @@ if ($rows > 0) {
 				util_make_link('/tracker/admin/?copy_opt=1&id='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='. $ath->getID(), ' ['._('Copy').']').
 				"</td>\n";
 		echo '<td>'.$eftypes[$efarr[$i]['field_type']]."</td>\n";
+		if ($autoAssignFieldId==$i) {
+			echo '<td class="align-center">'.html_image("ic/check.png",'15','13').'</td>'."\n";
+		} else {
+			echo '<td></td>'."\n";
+		}
+		$parentFieldId = $efarr[$i]['parent'];
+		if ($parentFieldId!=100) {
+			echo '<td>'.$efarr[$parentFieldId]['field_name'].'</td>'."\n";
+		} else {
+			echo '<td></td>'."\n";
+		}
 		/*
 			List of possible options for a user built Selection Box
 		*/
@@ -111,8 +125,10 @@ if ($rows > 0) {
 	echo $HTML->warning_msg(_('You have not defined any custom fields'));
 }
 
-echo "<h2>"._('Add New Custom Field')."</h2>";
+echo html_e('h2', array(), _('Add New Custom Field'));
+
 echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID(), 'method' => 'post'));
+
 echo html_ao('p');
 echo html_e('input', array('type'=>'hidden', 'name'=>'add_extrafield', 'value'=>'y'));
 
@@ -131,14 +147,17 @@ echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>'', '
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
-echo html_e('strong', array(), _('Type of custom field').utils_requiredField()._(':')).html_e('br');
+echo html_build_checkbox('is_required', false, false);
+echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
+echo html_ac(html_ap() - 1);
 
+echo html_ao('p');
+echo html_e('strong', array(), _('Type of custom field').utils_requiredField()._(':')).html_e('br');
 if ($ath->usesCustomStatuses()) {
 	unset($eftypes[ARTIFACT_EXTRAFIELDTYPE_STATUS]);
 }
 $vals = array_keys($eftypes);
 $texts = array_values($eftypes);
-
 echo html_build_radio_buttons_from_arrays($vals, $texts, 'field_type', '', false, '', false ,'', false, array('required'=>'required') );
 echo html_ac(html_ap() - 1);
 
@@ -148,9 +167,24 @@ echo _('Text Field Size/Text Area Rows');
 echo html_e('input', array('type'=>'text', 'name'=>'attribute1', 'value'=>'20', 'size'=>'2', 'maxlength'=>'2')).html_e('br');
 echo _('Text Field Maxlength/Text Area Columns');
 echo html_e('input', array('type'=>'text', 'name'=>'attribute2', 'value'=>'80', 'size'=>'2', 'maxlength'=>'2')).html_e('br');
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
 echo _('Text Field Pattern');
-echo html_e('input', array('type'=>'text', 'name'=>'pattern', 'value'=>'', 'size'=>'80', 'maxlength'=>'255')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'pattern', 'value'=>'', 'size'=>'50', 'maxlength'=>'255')).html_e('br');
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo html_build_checkbox('hide100', false, false);
+echo html_e('label', array('for'=>'hide100'), _('Hide the default none value'));
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo _('Label for the none value');
+echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>_('none'), 'size'=>'30')).html_e('br');
+echo html_ac(html_ap() - 1);
 
+echo html_ao('p');
 $pfarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT));
 $parentField = array();
 if (is_array($pfarr)) {
@@ -161,15 +195,11 @@ if (is_array($pfarr)) {
 asort($parentField,SORT_FLAG_CASE | SORT_STRING);
 echo _('Parent Field');
 echo html_build_select_box_from_arrays(array_keys($parentField), array_values($parentField), 'parent', null, true, 'none').html_e('br');
-echo _('Hide the default none value');
-echo html_build_checkbox('hide100','',false).html_e('br');
-echo _('Label for the none value');
-echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>_('none'), 'size'=>'30')).html_e('br');
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
-echo html_build_checkbox('is_required','',false);
-echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
+echo html_build_checkbox('autoassign', false, false);
+echo html_e('label', array('for'=>'autoassign'), _('Field that triggers auto-assignment rules'));
 echo html_ac(html_ap() - 1);
 
 echo $HTML->warning_msg(_('Warning: this add new custom field'));
diff --git a/src/common/tracker/views/form-updateextrafield.php b/src/common/tracker/views/form-updateextrafield.php
index 2a36247..0a938af 100644
--- a/src/common/tracker/views/form-updateextrafield.php
+++ b/src/common/tracker/views/form-updateextrafield.php
@@ -55,35 +55,63 @@ if (!$ac || !is_object($ac)) {
 	echo html_ac(html_ap() - 1);
 
 	echo html_ao('p');
+	echo html_e('label', array('for'=>'alias'), html_e('strong', array(), _('Field alias')._(':')).html_e('br'));
+	echo html_e('input', array('type'=>'text', 'id'=>'alias', 'name'=>'alias', 'value'=>$ac->getAlias(), 'size'=>'15', 'maxlength'=>'30'));
+	echo html_ac(html_ap() - 1);
+
+	echo html_ao('p');
 	echo html_e('label', array('for'=>'description'), html_e('strong', array(), _('Description')._(':')).html_e('br'));
 	echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>$ac->getDescription(), 'size'=>'50', 'maxlength'=>'255'));
 	echo html_ac(html_ap() - 1);
 
 	echo html_ao('p');
+	echo html_build_checkbox('is_required', false, $ac->isRequired());
+	echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
+	echo html_ac(html_ap() - 1);
+
 	$efType=$ac->getType();
 	if ($efType == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
-		echo html_e('label', array('for'=>'attribute1'), html_e('b', array(), _('Text Area Columns')).html_e('br'));
+		echo html_ao('p');
+		echo html_e('label', array('for'=>'attribute1'), _('Text Area Columns'));
 		echo html_e('input', array('type'=>'text', 'id'=>'attribute1', 'name'=>'attribute1', 'value'=>$ac->getAttribute1(), 'size'=>'2', 'maxlength'=>'2'));
 		echo html_ac(html_ap() - 1);
+
 		echo html_ao('p');
-		echo html_e('label', array('for'=>'attribute2'), html_e('b', array(), _('Text Area Columns')).html_e('br'));
+		echo html_e('label', array('for'=>'attribute2'), _('Text Area Columns'));
 		echo html_e('input', array('type'=>'text', 'id'=>'attribute2', 'name'=>'attribute2', 'value'=>$ac->getAttribute2(), 'size'=>'2', 'maxlength'=>'2'));
+		echo html_ac(html_ap() - 1);
+
 	} elseif ($efType == ARTIFACT_EXTRAFIELDTYPE_TEXT || $efType == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
-		echo html_e('label', array('for'=>'attribute1'), html_e('b', array(), _('Text Field Size')).html_e('br'));
+		echo html_ao('p');
+		echo html_e('label', array('for'=>'attribute1'), _('Text Field Size'));
 		echo html_e('input', array('type'=>'text', 'id'=>'attribute1', 'name'=>'attribute1', 'value'=>$ac->getAttribute1(), 'size'=>'2', 'maxlength'=>'2'));
 		echo html_ac(html_ap() - 1);
+
 		echo html_ao('p');
-		echo html_e('label', array('for'=>'attribute2'), html_e('b', array(), _('Text Field Maxlength')).html_e('br'));
+		echo html_e('label', array('for'=>'attribute2'), _('Text Field Maxlength'));
 		echo html_e('input', array('type'=>'text', 'id'=>'attribute2', 'name'=>'attribute2', 'value'=>$ac->getAttribute2(), 'size'=>'2', 'maxlength'=>'2'));
+		echo html_ac(html_ap() - 1);
+
 		if ($efType == ARTIFACT_EXTRAFIELDTYPE_TEXT) {
-			echo html_ac(html_ap() - 1);
 			echo html_ao('p');
-			echo html_e('label', array('for'=>'pattern'), html_e('b', array(), _('Text Field Pattern')).html_e('br'));
-			echo html_e('input', array('type'=>'text', 'id'=>'pattern', 'name'=>'pattern', 'value'=>$ac->getPattern(), 'size'=>'80', 'maxlength'=>'255'));
+			echo html_e('label', array('for'=>'pattern'), _('Text Field Pattern'));
+			echo html_e('input', array('type'=>'text', 'id'=>'pattern', 'name'=>'pattern', 'value'=>$ac->getPattern(), 'size'=>'50', 'maxlength'=>'255'));
+			echo html_ac(html_ap() - 1);
 		}
 	} else {
 		echo html_e('input', array('type'=>'hidden', 'name'=>'attribute1', 'value'=>'0'));
 		echo html_e('input', array('type'=>'hidden', 'name'=>'attribute2', 'value'=>'0'));
+
+		echo html_ao('p');
+		echo html_build_checkbox('hide100', false, !$ac->getShow100());
+		echo html_e('label', array('for'=>'hide100'), _('Hide the default none value'));
+		echo html_ac(html_ap() - 1);
+
+		echo html_ao('p');
+		echo html_e('label', array('for'=>'show100label'), html_e('b', array(), _('Label for the none value')).html_e('br'));
+		echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>$ac->getShow100label(), 'size'=>'30'));
+		echo html_ac(html_ap() - 1);
+
 		if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT))) {
 			$pfarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT));
 			$parentField = array();
@@ -100,24 +128,13 @@ if (!$ac || !is_object($ac)) {
 			echo html_build_select_box_from_arrays(array_keys($parentField), array_values($parentField), 'parent', $ac->getParent(), true, 'none').html_e('br');
 			echo html_ac(html_ap() - 1);
 		}
-		echo html_e('label', array('for'=>'hide100'), html_e('b', array(), _('Hide the default none value')).html_e('br'));
-		echo html_build_checkbox('hide100','',!$ac->getShow100());
-		echo html_ac(html_ap() - 1);
-		echo html_ao('p');
-		echo html_e('label', array('for'=>'show100label'), html_e('b', array(), _('Label for the none value')).html_e('br'));
-		echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>$ac->getShow100label(), 'size'=>'30'));
+		if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_SELECT))) {
+			echo html_ao('p');
+			echo html_build_checkbox('autoassign', false, $ac->isAutoAssign());
+			echo html_e('label', array('for'=>'autoassign'), _('Field that triggers auto-assignment rules'));
+			echo html_ac(html_ap() - 1);
+		}
 	}
-	echo html_ac(html_ap() - 1);
-
-	echo html_ao('p');
-	echo html_e('label', array('for'=>'alias'), html_e('strong', array(), _('Field alias')._(':')).html_e('br'));
-	echo html_e('input', array('type'=>'text', 'id'=>'alias', 'name'=>'alias', 'value'=>$ac->getAlias(), 'size'=>'15', 'maxlength'=>'30'));
-	echo html_ac(html_ap() - 1);
-
-	echo html_ao('p');
-	echo html_build_checkbox('is_required','',$ac->isRequired());
-	echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
-	echo html_ac(html_ap() - 1);
 
 	echo $HTML->warning_msg(_('It is not recommended that you change the custom field name because other things are dependent upon it. When you change the custom field name, all related items will be changed to the new name.'));
 
diff --git a/src/common/tracker/views/form-updateextrafieldelement.php b/src/common/tracker/views/form-updateextrafieldelement.php
index 6af9164..6514166 100644
--- a/src/common/tracker/views/form-updateextrafieldelement.php
+++ b/src/common/tracker/views/form-updateextrafieldelement.php
@@ -71,11 +71,24 @@ if (!$ac || !is_object($ac)) {
 			$checkedElmntsArr = $ao->getParentElements();
 			echo html_build_checkboxes_from_array($parentFieldElmntVals, 'parent_elements', $checkedElmntsArr, true);
 		}
+		if ($ac->isAutoAssign()) {
+			echo html_e('strong',array(),_('Auto assign to')._(':')).html_e('br');
+			$engine = RBACEngine::getInstance () ;
+			$techs = $engine->getUsersByAllowedAction ('tracker', $ath->getID(), 'tech') ;
+			sortUserList($techs);
+			foreach ($techs as $tech) {
+				$ids[] = $tech->getID() ;
+				$names[] = $tech->getRealName().(($tech->getStatus()=='S') ? ' '._('[SUSPENDED]') : '');
+			}
+			$AutoAssignTo = $ao->getAutoAssignTo();
+			echo html_build_select_box_from_arrays($ids, $names, 'auto_assign_to', $AutoAssignTo, true,'nobody');
+		} else {
+			echo html_e('input', array('type'=>'hidden', 'name'=>'auto_assign_to', 'value'=>100));
+		}
 		echo $HTML->warning_msg(_('It is not recommended that you change the custom field name because other things are dependent upon it. When you change the custom field name, all related items will be changed to the new name.'));
-			?>
-			<p>
-			<input type="submit" name="post_changes" value="<?php echo _('Update') ?>" /></p>
-		<?php
+		echo html_ao('p');
+		echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=> _('Update')));
+		echo html_ac(html_ap()-1);
 		echo $HTML->closeForm();
 		$ath->footer();
 	}
diff --git a/src/db/20160627-tracker-autoassign.sql b/src/db/20160627-tracker-autoassign.sql
new file mode 100644
index 0000000..0e82ab0
--- /dev/null
+++ b/src/db/20160627-tracker-autoassign.sql
@@ -0,0 +1,26 @@
+ALTER TABLE artifact_group_list
+   ADD auto_assign_field integer NOT NULL DEFAULT 100;
+
+ALTER TABLE artifact_group_list
+   ADD CONSTRAINT auto_assign_field_extra_field_id_fkey FOREIGN KEY (auto_assign_field)
+      REFERENCES artifact_extra_field_list (extra_field_id) MATCH FULL;
+
+DROP VIEW artifact_group_list_vw;
+
+CREATE VIEW artifact_group_list_vw AS 
+ SELECT agl.group_artifact_id, agl.group_id, agl.name, agl.description, 
+    agl.email_all_updates, agl.email_address, agl.due_period, 
+    agl.submit_instructions, agl.browse_instructions, agl.browse_list, 
+    agl.datatype, agl.status_timeout, agl.custom_status_field, 
+    agl.custom_renderer, agl.auto_assign_field, aca.count, aca.open_count
+   FROM artifact_group_list agl
+   LEFT JOIN artifact_counts_agg aca USING (group_artifact_id);
+
+INSERT INTO artifact_extra_field_list(extra_field_id, group_artifact_id, field_name, alias, description) VALUES (100, 100, 'Default', 'default', 'Default Data - Dont Edit');
+
+ALTER TABLE artifact_extra_field_elements
+   ADD auto_assign_to integer NOT NULL DEFAULT 100;
+
+ALTER TABLE artifact_extra_field_elements
+   ADD CONSTRAINT artifact_extra_field_elements_user_id_fkey FOREIGN KEY (auto_assign_to)
+      REFERENCES users (user_id) MATCH FULL;
diff --git a/src/www/include/html.php b/src/www/include/html.php
index f633c92..780ed5d 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -584,6 +584,9 @@ function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked
 	if ($text_100 == 'none') {
 		$text_100 = _('None');
 	}
+	if ($text_100 == 'nobody') {
+		$text_100 = _('Nobody');
+	}
 	$have_a_subelement = false;
 	$return = '';
 
@@ -816,14 +819,18 @@ function html_build_multiple_select_box_from_arrays($vals, $texts, $name, $check
 /**
  * html_build_checkbox() - Render checkbox control
  *
- * @param	string	$name		name of control
- * @param	string	$value		value of control
- * @param	bool	$checked	true if control should be checked
- * @param	array	$attrs		Array of other attributes for this element
+ * @param	string		$name		name of control
+ * @param	bool|string	$value		value of control (if false then no attribute value)
+ * @param	bool		$checked	true if control should be checked
+ * @param	array		$attrs		Array of other attributes for this element
  * @return	html code for checkbox control
  */
 function html_build_checkbox($name, $value, $checked, $attrs=array()) {
-	$attrs = array_merge(array('id' => $name, 'name' => $name, 'value' => $value, 'type' => 'checkbox'), $attrs);
+	if ($value === false) {
+		$attrs = array_merge(array('id' => $name, 'name' => $name, 'type' => 'checkbox'), $attrs);
+	} else {
+		$attrs = array_merge(array('id' => $name, 'name' => $name, 'value' => $value, 'type' => 'checkbox'), $attrs);
+	}
 	if ($checked) {
 		$attrs['checked'] = 'checked';
 	}

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

Summary of changes:
 src/common/tracker/Artifact.class.php              | 22 +++++-
 src/common/tracker/ArtifactExtraField.class.php    | 82 ++++++++++++++++++----
 .../tracker/ArtifactExtraFieldElement.class.php    | 23 ++++--
 src/common/tracker/ArtifactType.class.php          | 23 ++++++
 src/common/tracker/actions/admin-updates.php       | 15 ++--
 src/common/tracker/actions/browse.php              |  2 +-
 src/common/tracker/actions/mod-limited.php         |  2 +-
 .../tracker/include/ArtifactTypeHtml.class.php     | 26 ++++++-
 src/common/tracker/views/form-addextrafield.php    | 50 ++++++++++---
 src/common/tracker/views/form-updateextrafield.php | 65 ++++++++++-------
 .../tracker/views/form-updateextrafieldelement.php | 21 ++++--
 src/db/20160627-tracker-autoassign.sql             | 26 +++++++
 src/www/include/html.php                           | 17 +++--
 13 files changed, 297 insertions(+), 77 deletions(-)
 create mode 100644 src/db/20160627-tracker-autoassign.sql


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list