Index: common/tracker/Artifact.class.php
===================================================================
--- common/tracker/Artifact.class.php (revision 9938)
+++ common/tracker/Artifact.class.php (working copy)
@@ -252,6 +252,15 @@
$this->setError(_('Artifact: Error remapping status'));
return false;
}
+ //
+ // They may be using an extra field "autoassign" box so we have to remap
+ // assigned_to based on the extra field
+ //
+ $assigned_to=$this->ArtifactType->remapAssignedTo($assigned_to,$extra_fields);
+ if (!$assigned_to) {
+ $this->setError(_('Artifact: Error remapping autoassign'));
+ return false;
+ }
db_begin();
Index: common/tracker/ArtifactType.class.php
===================================================================
--- common/tracker/ArtifactType.class.php (revision 9938)
+++ common/tracker/ArtifactType.class.php (working copy)
@@ -533,6 +533,60 @@
}
/**
+ * remap assigned to - pass the extra_fields array and return assigned_to
+ * @param int The assigned_to valued
+ * @param array Complex array of extra_field_data
+ * @return int new assigned_to.
+ */
+ function remapAssignedTo($assigned_to,$extra_fields) {
+ // check if already set
+ if ($assigned_to && $assigned_to != 100)
+ return $assigned_to;
+
+ $aa = $this->getExtraFields(10);
+ if (!$aa)
+ return $assigned_to;
+
+ // fetch assign auto assign rules
+ $elements = $this->getExtraFieldElements(key($aa));
+ if (!$elements)
+ return $assigned_to;
+
+ $ef = $this->getExtraFields();
+ $found = false;
+ $rule = '';
+ // iterate through auto assign rules
+ foreach($elements as $key => $element) {
+ $rule = $element['element_name'];
+ list($field_name,$field_value,$user) = explode('|',$rule);
+
+ foreach($extra_fields as $extra_id => $value) {
+ $name = $ef[$extra_id]['field_name'];
+ $type = $ef[$extra_id]['field_type'];
+ if ($name != $field_name) {
+ continue;
+ }
+ $element_name = $this->getElementName($value);
+ if ($element_name != $field_value) {
+ continue;
+ }
+ $found = true;
+ }
+ }
+ if (!$found) {
+ //error_log("no related extra field value found for auto assign rule '$rule'");
+ return $assigned_to;
+ }
+ $res = db_query_params ("SELECT user_id FROM users where user_name=$1 OR realname=$1",array($user));
+ $user_data = db_fetch_array($res);
+ if (!$user_data || !$user_data['user_id'] ) {
+ error_log("did not find the user id of the request user for auto assignment.");
+ return $assigned_to;
+ }
+ return $user_data['user_id'];
+ }
+
+ /**
* getDataType - flag that is generally unused but can mark the difference between bugs, patches, etc.
*
* @return int The type (1) bug (2) support (3) patch (4) feature (0) other.
Index: common/tracker/ArtifactExtraField.class.php
===================================================================
--- common/tracker/ArtifactExtraField.class.php (revision 9938)
+++ common/tracker/ArtifactExtraField.class.php (working copy)
@@ -35,7 +36,8 @@
define('ARTIFACT_EXTRAFIELDTYPE_STATUS',7);
//define('ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE',8);
define('ARTIFACT_EXTRAFIELDTYPE_RELATION',9);
-define('ARTIFACT_EXTRAFIELDTYPE_INTEGER',10);
+define('ARTIFACT_EXTRAFIELDTYPE_INTEGER',10);
+define('ARTIFACT_EXTRAFIELDTYPE_AUTOASSIGN',11);
class ArtifactExtraField extends Error {
@@ -327,7 +345,8 @@
6=>_('Text Area'),
7=>_('Status'),
9=>_('Relation'),
- 10=>_('Integer')
+ 10=>_('Integer'),
+ 11=>_('AutoAssign')
);
}
Index: www/tracker/admin/form-addextrafield.php
===================================================================
--- www/tracker/admin/form-addextrafield.php (revision 9938)
+++ www/tracker/admin/form-addextrafield.php (working copy)
@@ -71,7 +71,8 @@
|| $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO
|| $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX
|| $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT
- || $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+ || $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS
+ || $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_AUTOASSIGN) {
echo '['.
_('add choices').']';
@@ -112,6 +113,9 @@
+
+
+ '); ?>