[evolvis-commits] r18684: small-fixes pending merges:↵ Thorsten Glaser 2012-10-04 allow making custom status fields that map to any valid status_id

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Oct 4 13:23:45 CEST 2012


Author: mirabilos
Date: 2012-10-04 13:23:45 +0200 (Thu, 04 Oct 2012)
New Revision: 18684

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraFieldElement.class.php
Log:
small-fixes pending merges:
  Thorsten Glaser 2012-10-04 allow making custom status fields that map to any valid status_id

XXX this requires updating the template project

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraFieldElement.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraFieldElement.class.php	2012-10-04 09:58:11 UTC (rev 18683)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraFieldElement.class.php	2012-10-04 11:23:45 UTC (rev 18684)
@@ -117,14 +117,7 @@
 			$this->setError(_('an element name is required'));
 			return false;
 		}
-		if ($status_id) {
-			if ($status_id==1) {
-			} else {
-				$status_id=2;
-			}
-		} else {
-			$status_id=0;
-		}
+		$this->checkStatusId($status_id);
 		if (!forge_check_perm ('tracker_admin', $this->ArtifactExtraField->ArtifactType->Group->getID())) {
 			$this->setPermissionDeniedError();
 			return false;
@@ -257,14 +250,7 @@
 			$this->setError(_('Element name already exists'));
 			return false;
 		}
-		if ($status_id) {
-			if ($status_id==1) {
-			} else {
-				$status_id=2;
-			}
-		} else {
-			$status_id=0;
-		}
+		$this->checkStatusId($status_id);
 		$result = db_query_params ('UPDATE artifact_extra_field_elements 
 			SET element_name=$1, status_id=$2
 			WHERE element_id=$3',
@@ -312,6 +298,22 @@
 				    array ($this->getID())) ;
 		return true;
 	}
+
+	function checkStatusId(&$sid) {
+		$s = util_nat0($sid);
+		if (!$s) {
+			$sid = 0;
+			return;
+		}
+		$res = db_query_params('SELECT * FROM artifact_status WHERE id=$1',
+		    array($s));
+		if (!$res || db_numrows($res) < 1) {
+			$sid = 0;
+			return;
+		}
+		db_free_result($res);
+		$sid = $s;
+	}
 }
 
 // Local Variables:



More information about the evolvis-commits mailing list