Przeglądaj źródła

Fixed bug in the data model: organization status was not an enum

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@268 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 lat temu
rodzic
commit
2c847897ba

+ 0 - 2
business/KEDB.business.php

@@ -1,7 +1,5 @@
 <?php
 <?php
 
 
-$oAllowedStatuses = new ValueSetEnum('production,implementation,obsolete');
-
 ////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////
 /**
 /**
 * Description of known error
 * Description of known error

+ 3 - 5
business/itop.business.class.inc.php

@@ -19,7 +19,7 @@ require_once('../application/template.class.inc.php');
 /**
 /**
  * Possible values for the statuses of objects
  * Possible values for the statuses of objects
  */
  */
-$oAllowedStatuses = new ValueSetEnum('production,implementation,obsolete');
+define('STANDARD_STATUSES', 'production,implementation,obsolete');
 
 
 /**
 /**
  * Relation graphs
  * Relation graphs
@@ -72,7 +72,7 @@ class bizOrganization extends cmdbAbstractObject
 		MetaModel::Init_Params($aParams);
 		MetaModel::Init_Params($aParams);
 		MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array() )));
 		MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array() )));
 		MetaModel::Init_AddAttribute(new AttributeString("code", array("label"=>"Code", "description"=>"Organization code (Siret, DUNS,...)", "allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array() )));
 		MetaModel::Init_AddAttribute(new AttributeString("code", array("label"=>"Code", "description"=>"Organization code (Siret, DUNS,...)", "allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array() )));
-		MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
+		MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>new ValueSetEnum(STANDARD_STATUSES), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"bizOrganization", "label"=>"Parent", "description"=>"Parent organization", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"bizOrganization", "label"=>"Parent", "description"=>"Parent organization", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Name", "description"=>"Name of the parent organization", "allowed_values"=>null, "extkey_attcode"=> 'parent_id', "target_attcode"=>"name")));
 		MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Name", "description"=>"Name of the parent organization", "allowed_values"=>null, "extkey_attcode"=> 'parent_id', "target_attcode"=>"name")));
 
 
@@ -126,8 +126,6 @@ class logRealObject extends cmdbAbstractObject
 {
 {
 	public static function Init()
 	public static function Init()
 	{
 	{
-		global $oAllowedStatuses;
-		
 		$aParams = array
 		$aParams = array
 		(
 		(
 			"category" => "bizmodel,searchable",
 			"category" => "bizmodel,searchable",
@@ -145,7 +143,7 @@ class logRealObject extends cmdbAbstractObject
 		);
 		);
 		MetaModel::Init_Params($aParams);
 		MetaModel::Init_Params($aParams);
 		MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
-		MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
+		MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>new ValueSetEnum(STANDARD_STATUSES), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Organization", "description"=>"ID of the object owner organization", "allowed_values"=>null, "sql"=>"org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Organization", "description"=>"ID of the object owner organization", "allowed_values"=>null, "sql"=>"org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
 		MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
 
 

+ 3 - 1
core/attributedef.class.inc.php

@@ -813,7 +813,8 @@ class AttributeEnum extends AttributeString
 		}
 		}
 		else
 		else
 		{
 		{
-			$sLabel = $sValue.' ERROR could not find';
+			// #@# todo - record an error silently... 
+			$sLabel = $sValue;
 		}
 		}
 		// later, we could imagine a detailed description in the title
 		// later, we could imagine a detailed description in the title
 		return "<span title=\"\">".parent::GetAsHtml($sLabel)."</span>";
 		return "<span title=\"\">".parent::GetAsHtml($sLabel)."</span>";
@@ -843,6 +844,7 @@ class AttributeDate extends AttributeDBField
 		self::$const_TIMEZONE = new DateTimeZone(self::MYDATETIMEZONE);
 		self::$const_TIMEZONE = new DateTimeZone(self::MYDATETIMEZONE);
 
 
 		// #@# Init default timezone -> do not get a notice... to be improved !!!
 		// #@# Init default timezone -> do not get a notice... to be improved !!!
+		// duplicated in the email test page (the mail function does trigger a notice as well)
 		date_default_timezone_set(self::MYDATETIMEZONE);
 		date_default_timezone_set(self::MYDATETIMEZONE);
 	}
 	}