N°4690 - Deprecate "FilterCodes"

This commit is contained in:
acognet
2022-05-13 10:28:53 +02:00
parent c20cedf266
commit 8b26b34f96
6 changed files with 120 additions and 312 deletions

View File

@@ -566,7 +566,7 @@ class DisplayBlock
if (($this->m_sStyle != 'links') && ($this->m_sStyle != 'search') && ($this->m_sStyle != 'list_search')) { if (($this->m_sStyle != 'links') && ($this->m_sStyle != 'search') && ($this->m_sStyle != 'list_search')) {
$oAppContext = new ApplicationContext(); $oAppContext = new ApplicationContext();
$sClass = $this->m_oFilter->GetClass(); $sClass = $this->m_oFilter->GetClass();
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass)); $aFilterCodes = MetaModel::GetFiltersList($sClass);
$aCallSpec = array($sClass, 'MapContextParam'); $aCallSpec = array($sClass, 'MapContextParam');
if (is_callable($aCallSpec)) { if (is_callable($aCallSpec)) {
foreach ($oAppContext->GetNames() as $sContextParam) { foreach ($oAppContext->GetNames() as $sContextParam) {

View File

@@ -854,6 +854,11 @@ abstract class AttributeDefinition
//abstract protected GetBasicFilterHTMLInput(); //abstract protected GetBasicFilterHTMLInput();
abstract public function GetBasicFilterSQLExpr($sOpCode, $value); abstract public function GetBasicFilterSQLExpr($sOpCode, $value);
/**
* since 3.1.0 return has changed (N°4690 - Deprecate "FilterCodes")
*
* @return array filtercode => attributecode
*/
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
return array(); return array();
@@ -2452,7 +2457,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
return array($this->GetCode() => new FilterFromAttribute($this)); return array($this->GetCode() => $this->GetCode());
} }
public function GetBasicFilterOperators() public function GetBasicFilterOperators()
@@ -7486,7 +7491,7 @@ class AttributeExternalField extends AttributeDefinition
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
return array($this->GetCode() => new FilterFromAttribute($this)); return array($this->GetCode() => $this->GetCode());
} }
public function GetBasicFilterOperators() public function GetBasicFilterOperators()
@@ -8523,18 +8528,17 @@ class AttributeStopWatch extends AttributeDefinition
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
$aRes = array( $aRes = array(
$this->GetCode() => new FilterFromAttribute($this), $this->GetCode() => $this->GetCode(),
$this->GetCode().'_started' => new FilterFromAttribute($this, '_started'), $this->GetCode().'_started' => $this->GetCode(),
$this->GetCode().'_laststart' => new FilterFromAttribute($this, '_laststart'), $this->GetCode().'_laststart' => $this->GetCode(),
$this->GetCode().'_stopped' => new FilterFromAttribute($this, '_stopped') $this->GetCode().'_stopped' => $this->GetCode(),
); );
foreach($this->ListThresholds() as $iThreshold => $aFoo) foreach ($this->ListThresholds() as $iThreshold => $aFoo) {
{
$sPrefix = $this->GetCode().'_'.$iThreshold; $sPrefix = $this->GetCode().'_'.$iThreshold;
$aRes[$sPrefix.'_deadline'] = new FilterFromAttribute($this, '_deadline'); $aRes[$sPrefix.'_deadline'] = $this->GetCode();
$aRes[$sPrefix.'_passed'] = new FilterFromAttribute($this, '_passed'); $aRes[$sPrefix.'_passed'] = $this->GetCode();
$aRes[$sPrefix.'_triggered'] = new FilterFromAttribute($this, '_triggered'); $aRes[$sPrefix.'_triggered'] = $this->GetCode();
$aRes[$sPrefix.'_overrun'] = new FilterFromAttribute($this, '_overrun'); $aRes[$sPrefix.'_overrun'] = $this->GetCode();
} }
return $aRes; return $aRes;
@@ -9276,7 +9280,7 @@ class AttributeSubItem extends AttributeDefinition
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
return array($this->GetCode() => new FilterFromAttribute($this)); return array($this->GetCode() => $this->GetCode());
} }
public function GetBasicFilterOperators() public function GetBasicFilterOperators()
@@ -11935,7 +11939,7 @@ class AttributeFriendlyName extends AttributeDefinition
public function GetFilterDefinitions() public function GetFilterDefinitions()
{ {
return array($this->GetCode() => new FilterFromAttribute($this)); return array($this->GetCode() => $this->GetCode());
} }
public function GetBasicFilterOperators() public function GetBasicFilterOperators()

View File

@@ -430,17 +430,13 @@ class DBObjectSearch extends DBSearch
*/ */
public function AddCondition($sFilterCode, $value, $sOpCode = null, $bParseSearchString = false) public function AddCondition($sFilterCode, $value, $sOpCode = null, $bParseSearchString = false)
{ {
MyHelpers::CheckKeyInArray('filter code in class: '.$this->GetClass(), $sFilterCode, MetaModel::GetClassFilterDefs($this->GetClass())); MyHelpers::CheckKeyInArray('filter code in class: '.$this->GetClass(), $sFilterCode, MetaModel::GetFilterAttribList($this->GetClass()));
$oField = new FieldExpression($sFilterCode, $this->GetClassAlias()); $oField = new FieldExpression($sFilterCode, $this->GetClassAlias());
if (empty($sOpCode)) if (empty($sOpCode)) {
{ if ($sFilterCode == 'id') {
if ($sFilterCode == 'id')
{
$sOpCode = '='; $sOpCode = '=';
} } else {
else
{
$oAttDef = MetaModel::GetAttributeDef($this->GetClass(), $sFilterCode); $oAttDef = MetaModel::GetAttributeDef($this->GetClass(), $sFilterCode);
$oNewCondition = $oAttDef->GetSmartConditionExpression($value, $oField, $this->m_aParams); $oNewCondition = $oAttDef->GetSmartConditionExpression($value, $oField, $this->m_aParams);
$this->AddConditionExpression($oNewCondition); $this->AddConditionExpression($oNewCondition);

View File

@@ -31,8 +31,9 @@ require_once('MyHelpers.class.inc.php');
/** /**
* Definition of a filter (could be made out of an existing attribute, or from an expression) * Definition of a filter (could be made out of an existing attribute, or from an expression)
* *
* @deprecated 3.1.0 not used N°4690 - Deprecate "FilterCodes"
* @package iTopORM * @package iTopORM
*/ */
abstract class FilterDefinition abstract class FilterDefinition
@@ -46,6 +47,7 @@ abstract class FilterDefinition
public function __construct($sCode, $aParams = array()) public function __construct($sCode, $aParams = array())
{ {
DeprecatedCallsLog::NotifyDeprecatedPhpMethod("Deprecated class ".$this->GetClass().". Do not use. Will be removed in next version.");
$this->m_sCode = $sCode; $this->m_sCode = $sCode;
$this->m_aParams = $aParams; $this->m_aParams = $aParams;
$this->ConsistencyCheck(); $this->ConsistencyCheck();
@@ -98,8 +100,9 @@ abstract class FilterDefinition
} }
/** /**
* Match against the object unique identifier * Match against the object unique identifier
* *
* @deprecated 3.1.0 N°4690 - Deprecate "FilterCodes"
* @package iTopORM * @package iTopORM
*/ */
class FilterPrivateKey extends FilterDefinition class FilterPrivateKey extends FilterDefinition
@@ -145,8 +148,9 @@ class FilterPrivateKey extends FilterDefinition
} }
/** /**
* Match against an existing attribute (the attribute type will determine the available operators) * Match against an existing attribute (the attribute type will determine the available operators)
* *
* @deprecated 3.1.0 N°4690 - Deprecate "FilterCodes"
* @package iTopORM * @package iTopORM
*/ */
class FilterFromAttribute extends FilterDefinition class FilterFromAttribute extends FilterDefinition

View File

@@ -1119,9 +1119,7 @@ abstract class MetaModel
return self::$m_aAttribOrigins[$sClass][$sAttCode]; return self::$m_aAttribOrigins[$sClass][$sAttCode];
} }
/** /** *
* @deprecated do not use : dead code, will be removed in the future
*
* @param string $sClass * @param string $sClass
* @param string $sAttCode * @param string $sAttCode
* *
@@ -1130,9 +1128,11 @@ abstract class MetaModel
*/ */
final public static function GetFilterCodeOrigin($sClass, $sAttCode) final public static function GetFilterCodeOrigin($sClass, $sAttCode)
{ {
self::_check_subclass($sClass); if ($sAttCode == 'id') {
return MetaModel::GetRootClass($sClass);
}
return self::$m_aFilterOrigins[$sClass][$sAttCode]; return MetaModel::GetAttributeOrigin($sClass, self::$m_aFilterAttribList[$sClass][$sAttCode]);
} }
/** /**
@@ -1481,7 +1481,6 @@ abstract class MetaModel
} }
/** /**
* @deprecated do not use : dead code, will be removed in the future
* *
* @param string $sClass * @param string $sClass
* *
@@ -1490,11 +1489,9 @@ abstract class MetaModel
*/ */
final public static function GetFiltersList($sClass) final public static function GetFiltersList($sClass)
{ {
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
self::_check_subclass($sClass); self::_check_subclass($sClass);
return array_keys(self::$m_aFilterDefs[$sClass]); return array_keys(self::$m_aFilterAttribList[$sClass]);
} }
/** /**
@@ -1564,9 +1561,7 @@ abstract class MetaModel
$oKeyAttDef = MetaModel::GetAttributeDef($sClass, $sExtKeyAttCode); $oKeyAttDef = MetaModel::GetAttributeDef($sClass, $sExtKeyAttCode);
$sRemoteClass = $oKeyAttDef->GetTargetClass(); $sRemoteClass = $oKeyAttDef->GetTargetClass();
$bRes = MetaModel::IsValidAttCode($sRemoteClass, $sRemoteAttCode, true); $bRes = MetaModel::IsValidAttCode($sRemoteClass, $sRemoteAttCode, true);
} } else {
else
{
$bRes = false; $bRes = false;
} }
} }
@@ -1591,7 +1586,6 @@ abstract class MetaModel
} }
/** /**
* @deprecated do not use : dead code, will be removed in the future
* *
* @param string $sClass * @param string $sClass
* @param string $sFilterCode * @param string $sFilterCode
@@ -1600,13 +1594,11 @@ abstract class MetaModel
*/ */
final public static function IsValidFilterCode($sClass, $sFilterCode) final public static function IsValidFilterCode($sClass, $sFilterCode)
{ {
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core ! if (!array_key_exists($sClass, self::$m_aFilterAttribList)) {
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
if (!array_key_exists($sClass, self::$m_aFilterDefs)) {
return false; return false;
} }
return (array_key_exists($sFilterCode, self::$m_aFilterDefs[$sClass])); return (array_key_exists($sFilterCode, self::$m_aFilterAttribList[$sClass]));
} }
/** /**
@@ -1880,31 +1872,21 @@ abstract class MetaModel
public static function GetDescription($sClass, $sAttCode) public static function GetDescription($sClass, $sAttCode)
{ {
$oAttDef = self::GetAttributeDef($sClass, $sAttCode); $oAttDef = self::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef) if ($oAttDef) {
{
return $oAttDef->GetDescription(); return $oAttDef->GetDescription();
} }
return ""; return "";
} }
/** /**
* Filters of a given class may contain filters defined in a parent class * @var array array of (FilterCode => AttributeCode)
* - Some filters are a copy of the definition
* - Some filters correspond to the upper class table definition (compound objects)
* (see also attributes definition)
*
* @deprecated do not use : dead code, will be removed in the future
* @var array array of ("classname" => array filterdef)
*/ */
private static $m_aFilterDefs = array(); private static $m_aFilterAttribList = array();
/**
* @deprecated do not use : dead code, will be removed in the future
* @var array array of ("classname" => array of ("attcode"=>"sourceclass"))
*/
private static $m_aFilterOrigins = array();
/** /**
* @deprecated do not use : dead code, will be removed in the future * @deprecated 3.0.0 do not use : dead code, will be removed in the future N°4690 - Deprecate "FilterCodes"
* instead of array_keys(MetaModel::GetClassFilterDefs($sClass)); use MetaModel::GetFiltersList($sClass)
* *
* @param string $sClass * @param string $sClass
* *
@@ -1914,34 +1896,25 @@ abstract class MetaModel
public static function GetClassFilterDefs($sClass) public static function GetClassFilterDefs($sClass)
{ {
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core ! // cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future'); DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use MetaModel::GetClassFilterDefs: dead code, will be removed in the future. Use MetaModel::GetFiltersList or MetaModel::GetFiltersAttributes');
self::_check_subclass($sClass);
return self::$m_aFilterDefs[$sClass]; return self::$m_aFilterAttribList[$sClass];
} }
/** /**
* @deprecated do not use : dead code, will be removed in the future
* *
* @param string $sClass * @param string $sClass
* @param string $sFilterCode
* *
* @return mixed * @return array ($sFilterCode=>$sAttributeCode) + id=>id
* @throws \CoreException * @throws \CoreException
*/ */
final public static function GetClassFilterDef($sClass, $sFilterCode) public static function GetFilterAttribList($sClass)
{ {
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future'); return self::$m_aFilterAttribList[$sClass];
self::_check_subclass($sClass);
if (!array_key_exists($sFilterCode, self::$m_aFilterDefs[$sClass])) {
throw new CoreException("Unknown filter code '$sFilterCode' for class '$sClass'");
}
return self::$m_aFilterDefs[$sClass][$sFilterCode];
} }
/** /**
* @deprecated do not use : dead code, will be removed in the future * @deprecated 3.0.0 do not use : dead code, will be removed in the future use GetLabel instead N°4690 - Deprecate "FilterCodes"
* *
* @param string $sClass * @param string $sClass
* @param string $sFilterCode * @param string $sFilterCode
@@ -1951,103 +1924,9 @@ abstract class MetaModel
*/ */
public static function GetFilterLabel($sClass, $sFilterCode) public static function GetFilterLabel($sClass, $sFilterCode)
{ {
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future'); DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use MetaModel::GetFilterLabel : dead code, will be removed in the future. Use MetaModel::GetLabel instead');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter) {
return $oFilter->GetLabel();
}
return ""; return this::GetLabel($sClass, $sFilterCode);
}
/**
* @deprecated do not use : dead code, will be removed in the future
* @param string $sClass
* @param string $sFilterCode
*
* @return string
* @throws \CoreException
*/
public static function GetFilterDescription($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter) {
return $oFilter->GetDescription();
}
return "";
}
/**
* @deprecated do not use : dead code, will be removed in the future
* @param string $sClass
* @param string $sFilterCode
*
* @return array
* @throws \CoreException
*/
public static function GetFilterOperators($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter) {
return $oFilter->GetOperators();
}
return array();
}
/**
* @deprecated do not use : dead code, will be removed in the future
* @param string $sClass
* @param string $sFilterCode
*
* @return array
* @throws \CoreException
*/
public static function GetFilterLooseOperator($sClass, $sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter) {
return $oFilter->GetLooseOperator();
}
return array();
}
/**
* @deprecated do not use : dead code, will be removed in the future
* @param string $sClass
* @param string $sFilterCode
* @param string $sOpCode
*
* @return string
* @throws \CoreException
*/
public static function GetFilterOpDescription($sClass, $sFilterCode, $sOpCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
$oFilter = self::GetClassFilterDef($sClass, $sFilterCode);
if ($oFilter) {
return $oFilter->GetOpDescription($sOpCode);
}
return "";
}
/**
* @deprecated do not use : dead code, will be removed in the future
* @param string $sFilterCode
*
* @return string
*/
public static function GetFilterHTMLInput($sFilterCode)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use : dead code, will be removed in the future');
return "<INPUT name=\"$sFilterCode\">";
} }
/** /**
@@ -2889,6 +2768,8 @@ abstract class MetaModel
} }
/** /**
* @deprecated 3.1.0 use GetAllowedValues_att N°4690 - Deprecate "FilterCodes"
*
* @param string $sClass * @param string $sClass
* @param string $sFltCode * @param string $sFltCode
* @param array $aArgs * @param array $aArgs
@@ -2899,10 +2780,12 @@ abstract class MetaModel
*/ */
public static function GetAllowedValues_flt($sClass, $sFltCode, $aArgs = array(), $sContains = '') public static function GetAllowedValues_flt($sClass, $sFltCode, $aArgs = array(), $sContains = '')
{ {
$oFltDef = self::GetClassFilterDef($sClass, $sFltCode); DeprecatedCallsLog::NotifyDeprecatedPhpMethod('do not use MetaModel::GetAllowedValues_flt: dead code, will be removed in the future. Use MetaModel::GetAllowedValues');
return $oFltDef->GetAllowedValues($aArgs, $sContains);
return self::GetAllowedValues_att($sClass, $sFltCode);
} }
/** /**
* @param string $sClass * @param string $sClass
* @param string $sAttCode * @param string $sAttCode
@@ -2969,17 +2852,14 @@ abstract class MetaModel
private static function AddMagicAttribute(AttributeDefinition $oAttribute, $sTargetClass, $sOriginClass = null) private static function AddMagicAttribute(AttributeDefinition $oAttribute, $sTargetClass, $sOriginClass = null)
{ {
$sCode = $oAttribute->GetCode(); $sCode = $oAttribute->GetCode();
if (is_null($sOriginClass)) if (is_null($sOriginClass)) {
{
$sOriginClass = $sTargetClass; $sOriginClass = $sTargetClass;
} }
$oAttribute->SetHostClass($sTargetClass); $oAttribute->SetHostClass($sTargetClass);
self::$m_aAttribDefs[$sTargetClass][$sCode] = $oAttribute; self::$m_aAttribDefs[$sTargetClass][$sCode] = $oAttribute;
self::$m_aAttribOrigins[$sTargetClass][$sCode] = $sOriginClass; self::$m_aAttribOrigins[$sTargetClass][$sCode] = $sOriginClass;
$oFlt = new FilterFromAttribute($oAttribute); self::$m_aFilterAttribList[$sTargetClass][$sCode] = $sCode;
self::$m_aFilterDefs[$sTargetClass][$sCode] = $oFlt;
self::$m_aFilterOrigins[$sTargetClass][$sCode] = $sOriginClass;
} }
/** /**
@@ -3171,44 +3051,38 @@ abstract class MetaModel
self::$m_aClassParams[$sRootClass]["db_finalclass_field"] = 'finalclass'; self::$m_aClassParams[$sRootClass]["db_finalclass_field"] = 'finalclass';
} }
$oClassAtt = new AttributeFinalClass('finalclass', array( $oClassAtt = new AttributeFinalClass('finalclass', array(
"sql" => $sDbFinalClassField, "sql" => $sDbFinalClassField,
"default_value" => $sRootClass, "default_value" => $sRootClass,
"is_null_allowed" => false, "is_null_allowed" => false,
"depends_on" => array() "depends_on" => array(),
)); ));
self::AddMagicAttribute($oClassAtt, $sRootClass); self::AddMagicAttribute($oClassAtt, $sRootClass);
$bObsoletable = array_key_exists($sRootClass, $aObsoletableRootClasses); $bObsoletable = array_key_exists($sRootClass, $aObsoletableRootClasses);
if ($bObsoletable && is_null(self::$m_aClassParams[$sRootClass]['obsolescence_expression'])) if ($bObsoletable && is_null(self::$m_aClassParams[$sRootClass]['obsolescence_expression'])) {
{
self::$m_aClassParams[$sRootClass]['obsolescence_expression'] = '0'; self::$m_aClassParams[$sRootClass]['obsolescence_expression'] = '0';
} }
foreach(self::EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_EXCLUDETOP) as $sChildClass) foreach (self::EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_EXCLUDETOP) as $sChildClass) {
{ if (array_key_exists('finalclass', self::$m_aAttribDefs[$sChildClass])) {
if (array_key_exists('finalclass', self::$m_aAttribDefs[$sChildClass]))
{
throw new CoreException("Class $sChildClass, 'finalclass' is a reserved keyword, it cannot be used as an attribute code"); throw new CoreException("Class $sChildClass, 'finalclass' is a reserved keyword, it cannot be used as an attribute code");
} }
if (array_key_exists('finalclass', self::$m_aFilterDefs[$sChildClass])) if (array_key_exists('finalclass', self::$m_aFilterAttribList[$sChildClass])) {
{
throw new CoreException("Class $sChildClass, 'finalclass' is a reserved keyword, it cannot be used as a filter code"); throw new CoreException("Class $sChildClass, 'finalclass' is a reserved keyword, it cannot be used as a filter code");
} }
$oCloned = clone $oClassAtt; $oCloned = clone $oClassAtt;
$oCloned->SetFixedValue($sChildClass); $oCloned->SetFixedValue($sChildClass);
self::AddMagicAttribute($oCloned, $sChildClass, $sRootClass); self::AddMagicAttribute($oCloned, $sChildClass, $sRootClass);
if ($bObsoletable && is_null(self::$m_aClassParams[$sChildClass]['obsolescence_expression'])) if ($bObsoletable && is_null(self::$m_aClassParams[$sChildClass]['obsolescence_expression'])) {
{
self::$m_aClassParams[$sChildClass]['obsolescence_expression'] = '0'; self::$m_aClassParams[$sChildClass]['obsolescence_expression'] = '0';
} }
} }
} }
// Add magic attributes to the classes // Add magic attributes to the classes
foreach(self::GetClasses() as $sClass) foreach (self::GetClasses() as $sClass) {
{
$sRootClass = self::$m_aRootClasses[$sClass]; $sRootClass = self::$m_aRootClasses[$sClass];
// Create the friendly name attribute // Create the friendly name attribute
@@ -3216,40 +3090,35 @@ abstract class MetaModel
$oFriendlyName = new AttributeFriendlyName($sFriendlyNameAttCode); $oFriendlyName = new AttributeFriendlyName($sFriendlyNameAttCode);
self::AddMagicAttribute($oFriendlyName, $sClass); self::AddMagicAttribute($oFriendlyName, $sClass);
if (self::$m_aClassParams[$sClass]["archive_root"]) if (self::$m_aClassParams[$sClass]["archive_root"]) {
{
// Create archive attributes on top the archivable hierarchy // Create archive attributes on top the archivable hierarchy
$oArchiveFlag = new AttributeArchiveFlag('archive_flag'); $oArchiveFlag = new AttributeArchiveFlag('archive_flag');
self::AddMagicAttribute($oArchiveFlag, $sClass); self::AddMagicAttribute($oArchiveFlag, $sClass);
$oArchiveDate = new AttributeArchiveDate('archive_date', array('magic' => true, "allowed_values" => null, "sql" => 'archive_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array())); $oArchiveDate = new AttributeArchiveDate('archive_date', array('magic' => true, "allowed_values" => null, "sql" => 'archive_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array()));
self::AddMagicAttribute($oArchiveDate, $sClass); self::AddMagicAttribute($oArchiveDate, $sClass);
} } elseif (self::$m_aClassParams[$sClass]["archive"]) {
elseif (self::$m_aClassParams[$sClass]["archive"])
{
$sArchiveRoot = self::$m_aClassParams[$sClass]['archive_root_class']; $sArchiveRoot = self::$m_aClassParams[$sClass]['archive_root_class'];
// Inherit archive attributes // Inherit archive attributes
$oArchiveFlag = clone self::$m_aAttribDefs[$sArchiveRoot]['archive_flag']; $oArchiveFlag = clone self::$m_aAttribDefs[$sArchiveRoot]['archive_flag'];
$oArchiveFlag->SetHostClass($sClass); $oArchiveFlag->SetHostClass($sClass);
self::$m_aAttribDefs[$sClass]['archive_flag'] = $oArchiveFlag; self::$m_aAttribDefs[$sClass]['archive_flag'] = $oArchiveFlag;
self::$m_aAttribOrigins[$sClass]['archive_flag'] = $sArchiveRoot; self::$m_aAttribOrigins[$sClass]['archive_flag'] = $sArchiveRoot;
$oArchiveDate = clone self::$m_aAttribDefs[$sArchiveRoot]['archive_date']; $oArchiveDate = clone self::$m_aAttribDefs[$sArchiveRoot]['archive_date'];
$oArchiveDate->SetHostClass($sClass); $oArchiveDate->SetHostClass($sClass);
self::$m_aAttribDefs[$sClass]['archive_date'] = $oArchiveDate; self::$m_aAttribDefs[$sClass]['archive_date'] = $oArchiveDate;
self::$m_aAttribOrigins[$sClass]['archive_date'] = $sArchiveRoot; self::$m_aAttribOrigins[$sClass]['archive_date'] = $sArchiveRoot;
} }
if (!is_null(self::$m_aClassParams[$sClass]['obsolescence_expression'])) if (!is_null(self::$m_aClassParams[$sClass]['obsolescence_expression'])) {
{
$oObsolescenceFlag = new AttributeObsolescenceFlag('obsolescence_flag'); $oObsolescenceFlag = new AttributeObsolescenceFlag('obsolescence_flag');
self::AddMagicAttribute($oObsolescenceFlag, $sClass); self::AddMagicAttribute($oObsolescenceFlag, $sClass);
if (self::$m_aRootClasses[$sClass] == $sClass) if (self::$m_aRootClasses[$sClass] == $sClass) {
{
$oObsolescenceDate = new AttributeObsolescenceDate('obsolescence_date', array('magic' => true, "allowed_values" => null, "sql" => 'obsolescence_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array())); $oObsolescenceDate = new AttributeObsolescenceDate('obsolescence_date', array('magic' => true, "allowed_values" => null, "sql" => 'obsolescence_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array()));
self::AddMagicAttribute($oObsolescenceDate, $sClass); self::AddMagicAttribute($oObsolescenceDate, $sClass);
} } else {
else
{
$oObsolescenceDate = clone self::$m_aAttribDefs[$sRootClass]['obsolescence_date']; $oObsolescenceDate = clone self::$m_aAttribDefs[$sRootClass]['obsolescence_date'];
$oObsolescenceDate->SetHostClass($sClass); $oObsolescenceDate->SetHostClass($sClass);
self::$m_aAttribDefs[$sClass]['obsolescence_date'] = $oObsolescenceDate; self::$m_aAttribDefs[$sClass]['obsolescence_date'] = $oObsolescenceDate;
@@ -3261,40 +3130,24 @@ abstract class MetaModel
// Prepare external fields and filters // Prepare external fields and filters
// Add final class to external keys // Add final class to external keys
// Add magic attributes to external keys (finalclass, friendlyname, archive_flag, obsolescence_flag) // Add magic attributes to external keys (finalclass, friendlyname, archive_flag, obsolescence_flag)
foreach(self::GetClasses() as $sClass) foreach (self::GetClasses() as $sClass) {
{ foreach (self::$m_aAttribDefs[$sClass] as $sAttCode => $oAttDef) {
foreach(self::$m_aAttribDefs[$sClass] as $sAttCode => $oAttDef)
{
// Compute the filter codes // Compute the filter codes
// //
foreach($oAttDef->GetFilterDefinitions() as $sFilterCode => $oFilterDef) foreach ($oAttDef->GetFilterDefinitions() as $sFilterCode => $sCode) {
{ self::$m_aFilterAttribList[$sClass][$sFilterCode] = $sCode;
self::$m_aFilterDefs[$sClass][$sFilterCode] = $oFilterDef;
if ($oAttDef->IsExternalField())
{
$sKeyAttCode = $oAttDef->GetKeyAttCode();
$oKeyDef = self::GetAttributeDef($sClass, $sKeyAttCode);
self::$m_aFilterOrigins[$sClass][$sFilterCode] = $oKeyDef->GetTargetClass();
}
else
{
self::$m_aFilterOrigins[$sClass][$sFilterCode] = self::$m_aAttribOrigins[$sClass][$sAttCode];
}
} }
// Compute the fields that will be used to display a pointer to another object // Compute the fields that will be used to display a pointer to another object
// //
if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
{
// oAttDef is either // oAttDef is either
// - an external KEY / FIELD (direct), // - an external KEY / FIELD (direct),
// - an external field pointing to an external KEY / FIELD // - an external field pointing to an external KEY / FIELD
// - an external field pointing to an external field pointing to.... // - an external field pointing to an external field pointing to....
$sRemoteClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE); $sRemoteClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE);
if ($oAttDef->IsExternalField()) if ($oAttDef->IsExternalField()) {
{
// This is a key, but the value comes from elsewhere // This is a key, but the value comes from elsewhere
// Create an external field pointing to the remote friendly name attribute // Create an external field pointing to the remote friendly name attribute
$sKeyAttCode = $oAttDef->GetKeyAttCode(); $sKeyAttCode = $oAttDef->GetKeyAttCode();
@@ -3302,24 +3155,21 @@ abstract class MetaModel
$sFriendlyNameAttCode = $sAttCode.'_friendlyname'; $sFriendlyNameAttCode = $sAttCode.'_friendlyname';
$oFriendlyName = new AttributeExternalField($sFriendlyNameAttCode, array("allowed_values" => null, "extkey_attcode" => $sKeyAttCode, "target_attcode" => $sRemoteAttCode, "depends_on" => array())); $oFriendlyName = new AttributeExternalField($sFriendlyNameAttCode, array("allowed_values" => null, "extkey_attcode" => $sKeyAttCode, "target_attcode" => $sRemoteAttCode, "depends_on" => array()));
self::AddMagicAttribute($oFriendlyName, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]); self::AddMagicAttribute($oFriendlyName, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]);
} } else {
else
{
// Create the friendly name attribute // Create the friendly name attribute
$sFriendlyNameAttCode = $sAttCode.'_friendlyname'; $sFriendlyNameAttCode = $sAttCode.'_friendlyname';
$oFriendlyName = new AttributeExternalField($sFriendlyNameAttCode, array('allowed_values' => null, 'extkey_attcode' => $sAttCode, "target_attcode" => 'friendlyname', 'depends_on' => array())); $oFriendlyName = new AttributeExternalField($sFriendlyNameAttCode, array('allowed_values' => null, 'extkey_attcode' => $sAttCode, "target_attcode" => 'friendlyname', 'depends_on' => array()));
self::AddMagicAttribute($oFriendlyName, $sClass, self::$m_aAttribOrigins[$sClass][$sAttCode]); self::AddMagicAttribute($oFriendlyName, $sClass, self::$m_aAttribOrigins[$sClass][$sAttCode]);
if (self::HasChildrenClasses($sRemoteClass)) if (self::HasChildrenClasses($sRemoteClass)) {
{
// First, create an external field attribute, that gets the final class // First, create an external field attribute, that gets the final class
$sClassRecallAttCode = $sAttCode.'_finalclass_recall'; $sClassRecallAttCode = $sAttCode.'_finalclass_recall';
$oClassRecall = new AttributeExternalField($sClassRecallAttCode, array( $oClassRecall = new AttributeExternalField($sClassRecallAttCode, array(
"allowed_values" => null, "allowed_values" => null,
"extkey_attcode" => $sAttCode, "extkey_attcode" => $sAttCode,
"target_attcode" => "finalclass", "target_attcode" => "finalclass",
"is_null_allowed" => true, "is_null_allowed" => true,
"depends_on" => array() "depends_on" => array(),
)); ));
self::AddMagicAttribute($oClassRecall, $sClass, self::$m_aAttribOrigins[$sClass][$sAttCode]); self::AddMagicAttribute($oClassRecall, $sClass, self::$m_aAttribOrigins[$sClass][$sAttCode]);
@@ -3350,18 +3200,14 @@ abstract class MetaModel
} }
} }
if (self::IsArchivable($sRemoteClass)) if (self::IsArchivable($sRemoteClass)) {
{
$sCode = $sAttCode.'_archive_flag'; $sCode = $sAttCode.'_archive_flag';
if ($oAttDef->IsExternalField()) if ($oAttDef->IsExternalField()) {
{
// This is a key, but the value comes from elsewhere // This is a key, but the value comes from elsewhere
// Create an external field pointing to the remote attribute // Create an external field pointing to the remote attribute
$sKeyAttCode = $oAttDef->GetKeyAttCode(); $sKeyAttCode = $oAttDef->GetKeyAttCode();
$sRemoteAttCode = $oAttDef->GetExtAttCode().'_archive_flag'; $sRemoteAttCode = $oAttDef->GetExtAttCode().'_archive_flag';
} } else {
else
{
$sKeyAttCode = $sAttCode; $sKeyAttCode = $sAttCode;
$sRemoteAttCode = 'archive_flag'; $sRemoteAttCode = 'archive_flag';
} }
@@ -3369,18 +3215,14 @@ abstract class MetaModel
self::AddMagicAttribute($oMagic, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]); self::AddMagicAttribute($oMagic, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]);
} }
if (self::IsObsoletable($sRemoteClass)) if (self::IsObsoletable($sRemoteClass)) {
{
$sCode = $sAttCode.'_obsolescence_flag'; $sCode = $sAttCode.'_obsolescence_flag';
if ($oAttDef->IsExternalField()) if ($oAttDef->IsExternalField()) {
{
// This is a key, but the value comes from elsewhere // This is a key, but the value comes from elsewhere
// Create an external field pointing to the remote attribute // Create an external field pointing to the remote attribute
$sKeyAttCode = $oAttDef->GetKeyAttCode(); $sKeyAttCode = $oAttDef->GetKeyAttCode();
$sRemoteAttCode = $oAttDef->GetExtAttCode().'_obsolescence_flag'; $sRemoteAttCode = $oAttDef->GetExtAttCode().'_obsolescence_flag';
} } else {
else
{
$sKeyAttCode = $sAttCode; $sKeyAttCode = $sAttCode;
$sRemoteAttCode = 'obsolescence_flag'; $sRemoteAttCode = 'obsolescence_flag';
} }
@@ -3388,11 +3230,9 @@ abstract class MetaModel
self::AddMagicAttribute($oMagic, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]); self::AddMagicAttribute($oMagic, $sClass, self::$m_aAttribOrigins[$sClass][$sKeyAttCode]);
} }
} }
if ($oAttDef instanceof AttributeMetaEnum) if ($oAttDef instanceof AttributeMetaEnum) {
{
$aMappingData = $oAttDef->GetMapRule($sClass); $aMappingData = $oAttDef->GetMapRule($sClass);
if ($aMappingData != null) if ($aMappingData != null) {
{
$sEnumAttCode = $aMappingData['attcode']; $sEnumAttCode = $aMappingData['attcode'];
self::$m_aEnumToMeta[$sClass][$sEnumAttCode][$sAttCode] = $oAttDef; self::$m_aEnumToMeta[$sClass][$sEnumAttCode][$sAttCode] = $oAttDef;
} }
@@ -3401,17 +3241,10 @@ abstract class MetaModel
// Add a 'id' filter // Add a 'id' filter
// //
if (array_key_exists('id', self::$m_aAttribDefs[$sClass])) if (array_key_exists('id', self::$m_aAttribDefs[$sClass])) {
{
throw new CoreException("Class $sClass, 'id' is a reserved keyword, it cannot be used as an attribute code"); throw new CoreException("Class $sClass, 'id' is a reserved keyword, it cannot be used as an attribute code");
} }
if (array_key_exists('id', self::$m_aFilterDefs[$sClass])) self::$m_aFilterAttribList[$sClass]['id'] = 'id';
{
throw new CoreException("Class $sClass, 'id' is a reserved keyword, it cannot be used as a filter code");
}
$oFilter = new FilterPrivateKey('id', array('id_field' => self::DBGetKey($sClass)));
self::$m_aFilterDefs[$sClass]['id'] = $oFilter;
self::$m_aFilterOrigins[$sClass]['id'] = $sClass;
} }
} }
@@ -3571,8 +3404,7 @@ abstract class MetaModel
self::$m_aAttribDefs[$sClass] = array(); self::$m_aAttribDefs[$sClass] = array();
self::$m_aAttribOrigins[$sClass] = array(); self::$m_aAttribOrigins[$sClass] = array();
self::$m_aFilterDefs[$sClass] = array(); self::$m_aFilterAttribList[$sClass] = array();
self::$m_aFilterOrigins[$sClass] = array();
} }
/** /**
@@ -3602,25 +3434,20 @@ abstract class MetaModel
public static function Init_InheritAttributes($sSourceClass = null) public static function Init_InheritAttributes($sSourceClass = null)
{ {
$sTargetClass = self::GetCallersPHPClass("Init"); $sTargetClass = self::GetCallersPHPClass("Init");
if (empty($sSourceClass)) if (empty($sSourceClass)) {
{
// Default: inherit from parent class // Default: inherit from parent class
$sSourceClass = self::GetParentPersistentClass($sTargetClass); $sSourceClass = self::GetParentPersistentClass($sTargetClass);
if (empty($sSourceClass)) if (empty($sSourceClass)) {
{
return; return;
} // no attributes for the mother of all classes } // no attributes for the mother of all classes
} }
if (isset(self::$m_aAttribDefs[$sSourceClass])) if (isset(self::$m_aAttribDefs[$sSourceClass])) {
{ if (!isset(self::$m_aAttribDefs[$sTargetClass])) {
if (!isset(self::$m_aAttribDefs[$sTargetClass]))
{
self::$m_aAttribDefs[$sTargetClass] = array(); self::$m_aAttribDefs[$sTargetClass] = array();
self::$m_aAttribOrigins[$sTargetClass] = array(); self::$m_aAttribOrigins[$sTargetClass] = array();
} }
self::$m_aAttribDefs[$sTargetClass] = self::object_array_mergeclone(self::$m_aAttribDefs[$sTargetClass], self::$m_aAttribDefs[$sSourceClass]); self::$m_aAttribDefs[$sTargetClass] = self::object_array_mergeclone(self::$m_aAttribDefs[$sTargetClass], self::$m_aAttribDefs[$sSourceClass]);
foreach(self::$m_aAttribDefs[$sTargetClass] as $sAttCode => $oAttDef) foreach (self::$m_aAttribDefs[$sTargetClass] as $sAttCode => $oAttDef) {
{
$oAttDef->SetHostClass($sTargetClass); $oAttDef->SetHostClass($sTargetClass);
} }
self::$m_aAttribOrigins[$sTargetClass] = array_merge(self::$m_aAttribOrigins[$sTargetClass], self::$m_aAttribOrigins[$sSourceClass]); self::$m_aAttribOrigins[$sTargetClass] = array_merge(self::$m_aAttribOrigins[$sTargetClass], self::$m_aAttribOrigins[$sSourceClass]);
@@ -3675,22 +3502,18 @@ abstract class MetaModel
*/ */
public static function Init_AddAttribute(AttributeDefinition $oAtt, $sTargetClass = null) public static function Init_AddAttribute(AttributeDefinition $oAtt, $sTargetClass = null)
{ {
if (!$sTargetClass) if (!$sTargetClass) {
{
$sTargetClass = self::GetCallersPHPClass("Init"); $sTargetClass = self::GetCallersPHPClass("Init");
} }
$sAttCode = $oAtt->GetCode(); $sAttCode = $oAtt->GetCode();
if ($sAttCode == 'finalclass') if ($sAttCode == 'finalclass') {
{
throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration"); throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration");
} }
if ($sAttCode == 'friendlyname') if ($sAttCode == 'friendlyname') {
{
throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration"); throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration");
} }
if (array_key_exists($sAttCode, self::$m_aAttribDefs[$sTargetClass])) if (array_key_exists($sAttCode, self::$m_aAttribDefs[$sTargetClass])) {
{
throw new Exception("Declaration of $sTargetClass: attempting to redeclare the inherited attribute '$sAttCode', originally declared in ".self::$m_aAttribOrigins[$sTargetClass][$sAttCode]); throw new Exception("Declaration of $sTargetClass: attempting to redeclare the inherited attribute '$sAttCode', originally declared in ".self::$m_aAttribOrigins[$sTargetClass][$sAttCode]);
} }
@@ -3727,6 +3550,7 @@ abstract class MetaModel
{ {
// The corresponding external key has already been ignored // The corresponding external key has already been ignored
self::$m_aIgnoredAttributes[$sTargetClass][$oAtt->GetCode()] = self::$m_aIgnoredAttributes[$sTargetClass][$sExtKeyAttCode]; self::$m_aIgnoredAttributes[$sTargetClass][$oAtt->GetCode()] = self::$m_aIgnoredAttributes[$sTargetClass][$sExtKeyAttCode];
return; return;
} }
//TODO Check if the target attribute is still there //TODO Check if the target attribute is still there
@@ -4989,18 +4813,6 @@ abstract class MetaModel
} }
} }
} }
foreach(self::GetClassFilterDefs($sClass) as $sFltCode => $oFilterDef)
{
if (method_exists($oFilterDef, '__GetRefAttribute'))
{
$oAttDef = $oFilterDef->__GetRefAttribute();
if (!self::IsValidAttCode($sClass, $oAttDef->GetCode()))
{
$aErrors[$sClass][] = "Wrong attribute code '".$oAttDef->GetCode()."' (wrong class) for the \"basic\" filter $sFltCode";
$aSugFix[$sClass][] = "Expecting a value in {".implode(", ", self::GetAttributesList($sClass))."}";
}
}
}
// Lifecycle // Lifecycle
// //
@@ -6619,16 +6431,14 @@ abstract class MetaModel
// classes have to be derived from cmdbabstract (to be editable in the UI) // classes have to be derived from cmdbabstract (to be editable in the UI)
require_once(APPROOT.'/application/cmdbabstract.class.inc.php'); require_once(APPROOT.'/application/cmdbabstract.class.inc.php');
if (!defined('MODULESROOT')) if (!defined('MODULESROOT')) {
{
define('MODULESROOT', APPROOT.'env-'.self::$m_sEnvironment.'/'); define('MODULESROOT', APPROOT.'env-'.self::$m_sEnvironment.'/');
} }
require_once(APPROOT.'core/autoload.php'); require_once(APPROOT.'core/autoload.php');
require_once(APPROOT.'env-'.self::$m_sEnvironment.'/autoload.php'); require_once(APPROOT.'env-'.self::$m_sEnvironment.'/autoload.php');
foreach(self::$m_oConfig->GetAddons() as $sModule => $sToInclude) foreach (self::$m_oConfig->GetAddons() as $sModule => $sToInclude) {
{
self::IncludeModule($sToInclude, 'addons'); self::IncludeModule($sToInclude, 'addons');
} }
@@ -6636,16 +6446,14 @@ abstract class MetaModel
$sTablePrefix = self::$m_oConfig->Get('db_subname'); $sTablePrefix = self::$m_oConfig->Get('db_subname');
$oKPI->ComputeAndReport('Load config'); $oKPI->ComputeAndReport('Load config');
if (self::$m_bUseAPCCache) if (self::$m_bUseAPCCache) {
{
$oKPI = new ExecutionKPI(); $oKPI = new ExecutionKPI();
// Note: For versions of APC older than 3.0.17, fetch() accepts only one parameter // Note: For versions of APC older than 3.0.17, fetch() accepts only one parameter
// //
$sOqlAPCCacheId = 'itop-'.MetaModel::GetEnvironmentId().'-metamodel'; $sOqlAPCCacheId = 'itop-'.MetaModel::GetEnvironmentId().'-metamodel';
$result = apc_fetch($sOqlAPCCacheId); $result = apc_fetch($sOqlAPCCacheId);
if (is_array($result)) if (is_array($result)) {
{
// todo - verifier que toutes les classes mentionnees ici sont chargees dans InitClasses() // todo - verifier que toutes les classes mentionnees ici sont chargees dans InitClasses()
self::$m_aExtensionClassNames = $result['m_aExtensionClassNames']; self::$m_aExtensionClassNames = $result['m_aExtensionClassNames'];
self::$m_Category2Class = $result['m_Category2Class']; self::$m_Category2Class = $result['m_Category2Class'];
@@ -6656,8 +6464,7 @@ abstract class MetaModel
self::$m_aAttribDefs = $result['m_aAttribDefs']; self::$m_aAttribDefs = $result['m_aAttribDefs'];
self::$m_aAttribOrigins = $result['m_aAttribOrigins']; self::$m_aAttribOrigins = $result['m_aAttribOrigins'];
self::$m_aIgnoredAttributes = $result['m_aIgnoredAttributes']; self::$m_aIgnoredAttributes = $result['m_aIgnoredAttributes'];
self::$m_aFilterDefs = $result['m_aFilterDefs']; self::$m_aFilterAttribList = $result['m_aFilterList'];
self::$m_aFilterOrigins = $result['m_aFilterOrigins'];
self::$m_aListInfos = $result['m_aListInfos']; self::$m_aListInfos = $result['m_aListInfos'];
self::$m_aListData = $result['m_aListData']; self::$m_aListData = $result['m_aListData'];
self::$m_aRelationInfos = $result['m_aRelationInfos']; self::$m_aRelationInfos = $result['m_aRelationInfos'];
@@ -6693,8 +6500,7 @@ abstract class MetaModel
$aCache['m_aAttribDefs'] = self::$m_aAttribDefs; // array of ("classname" => array of attributes) $aCache['m_aAttribDefs'] = self::$m_aAttribDefs; // array of ("classname" => array of attributes)
$aCache['m_aAttribOrigins'] = self::$m_aAttribOrigins; // array of ("classname" => array of ("attcode"=>"sourceclass")) $aCache['m_aAttribOrigins'] = self::$m_aAttribOrigins; // array of ("classname" => array of ("attcode"=>"sourceclass"))
$aCache['m_aIgnoredAttributes'] = self::$m_aIgnoredAttributes; //array of ("classname" => array of ("attcode") $aCache['m_aIgnoredAttributes'] = self::$m_aIgnoredAttributes; //array of ("classname" => array of ("attcode")
$aCache['m_aFilterDefs'] = self::$m_aFilterDefs; // array of ("classname" => array filterdef) $aCache['m_aFilterList'] = self::$m_aFilterAttribList; // array of ("classname" => array filterdef)
$aCache['m_aFilterOrigins'] = self::$m_aFilterOrigins; // array of ("classname" => array of ("attcode"=>"sourceclass"))
$aCache['m_aListInfos'] = self::$m_aListInfos; // array of ("listcode" => various info on the list, common to every classes) $aCache['m_aListInfos'] = self::$m_aListInfos; // array of ("listcode" => various info on the list, common to every classes)
$aCache['m_aListData'] = self::$m_aListData; // array of ("classname" => array of "listcode" => list) $aCache['m_aListData'] = self::$m_aListData; // array of ("classname" => array of "listcode" => list)
$aCache['m_aRelationInfos'] = self::$m_aRelationInfos; // array of ("relcode" => various info on the list, common to every classes) $aCache['m_aRelationInfos'] = self::$m_aRelationInfos; // array of ("relcode" => various info on the list, common to every classes)

View File

@@ -369,7 +369,7 @@ abstract class WebServicesBase
{ {
if (!MetaModel::IsValidFilterCode($sKeyClass, $sForeignAttCode)) if (!MetaModel::IsValidFilterCode($sKeyClass, $sForeignAttCode))
{ {
$aCodes = array_keys(MetaModel::GetClassFilterDefs($sKeyClass)); $aCodes = MetaModel::GetFiltersList($sKeyClass);
$sMsg = "Parameter $sParamName: '$sForeignAttCode' is not a valid filter code for class '$sKeyClass', expecting a value in {".implode(', ', $aCodes)."}"; $sMsg = "Parameter $sParamName: '$sForeignAttCode' is not a valid filter code for class '$sKeyClass', expecting a value in {".implode(', ', $aCodes)."}";
$oRes->LogIssue($sMsg, $bIsMandatory); $oRes->LogIssue($sMsg, $bIsMandatory);
} }
@@ -445,11 +445,9 @@ abstract class WebServicesBase
} }
$oReconFilter = new DBObjectSearch($sTargetClass); $oReconFilter = new DBObjectSearch($sTargetClass);
$aCIStringDesc = array(); $aCIStringDesc = array();
foreach ($aItemData['search'] as $sAttCode => $value) foreach ($aItemData['search'] as $sAttCode => $value) {
{ if (!MetaModel::IsValidFilterCode($sTargetClass, $sAttCode)) {
if (!MetaModel::IsValidFilterCode($sTargetClass, $sAttCode)) $aCodes = MetaModel::GetFiltersList($sTargetClass);
{
$aCodes = array_keys(MetaModel::GetClassFilterDefs($sTargetClass));
$oRes->LogError("Parameter $sParamName: '$sAttCode' is not a valid filter code for class '$sTargetClass', expecting a value in {".implode(', ', $aCodes)."}"); $oRes->LogError("Parameter $sParamName: '$sAttCode' is not a valid filter code for class '$sTargetClass', expecting a value in {".implode(', ', $aCodes)."}");
continue 2; // skip the entire item continue 2; // skip the entire item
} }