[Fusionforge-commits] r7392 - trunk/gforge/common/tracker

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Thu Apr 9 22:20:50 CEST 2009


Author: aljeux
Date: 2009-04-09 22:20:49 +0200 (Thu, 09 Apr 2009)
New Revision: 7392

Modified:
   trunk/gforge/common/tracker/ArtifactExtraFieldElement.class.php
Log:
Adding control when creating/updating extrafield elements

Modified: trunk/gforge/common/tracker/ArtifactExtraFieldElement.class.php
===================================================================
--- trunk/gforge/common/tracker/ArtifactExtraFieldElement.class.php	2009-04-09 20:06:51 UTC (rev 7391)
+++ trunk/gforge/common/tracker/ArtifactExtraFieldElement.class.php	2009-04-09 20:20:49 UTC (rev 7392)
@@ -106,6 +106,12 @@
 			$this->setPermissionDeniedError();
 			return false;
 		}
+		$sql = "SELECT element_name FROM artifact_extra_field_elements WHERE element_name='$name' AND extra_field_id=".$this->ArtifactExtraField->getID();
+		$res = db_query($sql);
+		if (db_numrows($res) > 0) {
+			$this->setError(_('Element name already exists'));
+			return false;
+		}
 		$sql="INSERT INTO artifact_extra_field_elements (extra_field_id,element_name,status_id) 
 			VALUES ('".$this->ArtifactExtraField->getID()."','".htmlspecialchars($name)."','$status_id')";
 		db_begin();
@@ -207,9 +213,15 @@
 			$this->setPermissionDeniedError();
 			return false;
 		}
-		if (!$name) {
+		if (trim($name) == '') {
 			$this->setMissingParamsError();
 			return false;
+		}
+		$sql = "SELECT element_name FROM artifact_extra_field_elements WHERE element_name='$name' AND extra_field_id=".$this->ArtifactExtraField->getID();
+		$res = db_query($sql);
+		if (db_numrows($res) > 0) {
+			$this->setError(_('Element name already exists'));
+			return false;
 		}   
 		if ($status_id) {
 			if ($status_id==1) {




More information about the Fusionforge-commits mailing list