Browse Source

Added support for hierarchical ZLists when checking the data model consistency

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1038 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 years ago
parent
commit
6bcee2e506
1 changed files with 19 additions and 1 deletions
  1. 19 1
      core/metamodel.class.php

+ 19 - 1
core/metamodel.class.php

@@ -1371,6 +1371,23 @@ abstract class MetaModel
 		}
 	}
 
+	public static function FlattenZList($aList)
+	{
+		$aResult = array();
+		foreach($aList as $value)
+		{
+			if (!is_array($value))
+			{
+				$aResult[] = $value;
+			}
+			else
+			{
+				$aResult = array_merge($aResult, self::FlattenZList($value));
+			}
+		}
+		return $aResult;
+	}
+	
 	public static function Init_DefineState($sStateCode, $aStateDef)
 	{
 		$sTargetClass = self::GetCallersPHPClass("Init");
@@ -2342,7 +2359,7 @@ abstract class MetaModel
 			//
 			foreach(self::EnumZLists() as $sListCode)
 			{
-				foreach (self::GetZListItems($sClass, $sListCode) as $sMyAttCode)
+				foreach (self::FlattenZList(self::GetZListItems($sClass, $sListCode)) as $sMyAttCode)
 				{
 					if (!self::IsValidAttCode($sClass, $sMyAttCode))
 					{
@@ -2352,6 +2369,7 @@ abstract class MetaModel
 				}
 			}
 		}
+		
 		if (count($aErrors) > 0)
 		{
 			echo "<div style=\"width:100%;padding:10px;background:#FFAAAA;display:;\">";