Przeglądaj źródła

Filter audit results using the hierarchies

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1388 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 lat temu
rodzic
commit
cc8b102e99
1 zmienionych plików z 40 dodań i 2 usunięć
  1. 40 2
      pages/audit.php

+ 40 - 2
pages/audit.php

@@ -53,9 +53,47 @@ try
 				if ($sValue != null)
 				{
 					$sAttCode = call_user_func($aCallSpec, $sParamName); // Returns null when there is no mapping for this parameter
-					if ($sAttCode != null && MetaModel::IsValidAttCode($sObjClass, $sAttCode))
+					if ( ($sAttCode != null) && MetaModel::IsValidAttCode($sObjClass, $sAttCode))
 					{
-						$oFilter->AddCondition($sAttCode, $sValue);
+						$oFilter  = new DBObjectSearch($sObjClass);
+
+						// Check if the condition points to a hierarchical key
+						if ($sAttCode == 'id')
+						{
+							// Filtering on the objects themselves
+							$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sObjClass);
+							
+							if ($sHierarchicalKeyCode !== false)
+							{
+								$oRootFilter = new DBObjectSearch($sObjClass);
+								$oRootFilter->AddCondition($sAttCode, $sValue);
+								$oFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW); // Use the 'below' operator by default
+								$bConditionAdded = true;
+							}
+						}
+						else
+						{
+							$oAttDef = MetaModel::GetAttributeDef($sObjClass, $sAttCode);
+							$bConditionAdded = false;
+							if ($oAttDef->IsExternalKey())
+							{
+								$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
+								
+								if ($sHierarchicalKeyCode !== false)
+								{
+									$oRootFilter = new DBObjectSearch($oAttDef->GetTargetClass());
+									$oRootFilter->AddCondition('id', $sValue);
+									$oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
+									$oHKFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW); // Use the 'below' operator by default
+									$oFilter->AddCondition_PointingTo($oHKFilter, $sAttCode);
+									$bConditionAdded = true;
+								}
+							}
+						}
+						if (!$bConditionAdded)
+						{
+							$oFilter->AddCondition($sAttCode, $sValue);
+						}
 					}
 				}
 			}