diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index d3e5b1273..9331a78c2 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -1263,6 +1263,10 @@ class AttributeBoolean extends AttributeInteger { return $sValue ? '1' : '0'; } + public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true) + { + return $sValue ? '1' : '0'; + } } /** diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index 1c27895bb..8dd79b478 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/core/cmdbchangeop.class.inc.php @@ -735,13 +735,26 @@ class CMDBChangeOpSetAttributeLinksTune extends CMDBChangeOpSetAttributeLinks $sAttName = $oAttDef->GetLabel(); $sLinkClass = $oAttDef->GetLinkedClass(); + $aLinkClasses = MetaModel::EnumChildClasses($sLinkClass, ENUM_CHILD_CLASSES_ALL); // Search for changes on the corresponding link // $oSearch = new DBObjectSearch('CMDBChangeOpSetAttribute'); $oSearch->AddCondition('change', $this->Get('change'), '='); - $oSearch->AddCondition('objclass', $sLinkClass, '='); $oSearch->AddCondition('objkey', $this->Get('link_id'), '='); + if (count($aLinkClasses) == 1) + { + // Faster than the whole building of the expression below for just one value ?? + $oSearch->AddCondition('objclass', $sLinkClass, '='); + } + else + { + $oField = new FieldExpression('objclass', $oSearch->GetClassAlias()); + $sListExpr = '('.implode(', ', CMDBSource::Quote($aLinkClasses)).')'; + $sOQLCondition = $oField->Render()." IN $sListExpr"; + $oNewCondition = Expression::FromOQL($sOQLCondition); + $oSearch->AddConditionExpression($oNewCondition); + } $oSet = new DBObjectSet($oSearch); $aChanges = array(); while ($oChangeOp = $oSet->Fetch()) diff --git a/core/cmdbobject.class.inc.php b/core/cmdbobject.class.inc.php index aacc39eff..27b0a900b 100644 --- a/core/cmdbobject.class.inc.php +++ b/core/cmdbobject.class.inc.php @@ -297,6 +297,16 @@ abstract class CMDBObject extends DBObject $oMyChangeOp->Set("prevdata", $original); $iId = $oMyChangeOp->DBInsertNoReload(); } + elseif ($oAttDef instanceOf AttributeBoolean) + { + $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeScalar"); + $oMyChangeOp->Set("objclass", get_class($this)); + $oMyChangeOp->Set("objkey", $this->GetKey()); + $oMyChangeOp->Set("attcode", $sAttCode); + $oMyChangeOp->Set("oldvalue", $original ? 1 : 0); + $oMyChangeOp->Set("newvalue", $value ? 1 : 0); + $iId = $oMyChangeOp->DBInsertNoReload(); + } else { // Scalars diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 97d44e6fe..f3d0eff24 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -896,7 +896,7 @@ abstract class MetaModel foreach (MetaModel::ListAttributeDefs($sRemoteClass) as $sRemoteAttCode => $oRemoteAttDef) { if (!$oRemoteAttDef->IsLinkSet()) continue; - if ($oRemoteAttDef->GetLinkedClass() != $sClass) continue; + if (!is_subclass_of($sClass, $oRemoteAttDef->GetLinkedClass()) && $oRemoteAttDef->GetLinkedClass() != $sClass) continue; if ($oRemoteAttDef->GetExtKeyToMe() != $sAttCode) continue; $aRes[$sAttCode] = $oRemoteAttDef; } diff --git a/pages/UI.php b/pages/UI.php index 81dbb06bd..f030e2db7 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -1063,7 +1063,18 @@ EOF { if (preg_match('/attr_(.+)/', $sKey, $aMatches)) { - $oP->add("\n"); + // Beware: some values (like durations) are passed as arrays + if (is_array($value)) + { + foreach($value as $vKey => $vValue) + { + $oP->add("\n"); + } + } + else + { + $oP->add("\n"); + } } } $oP->add("\n"); diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index c4e472ec3..dd77c281d 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -76,7 +76,7 @@ class SynchroDataSource extends cmdbAbstractObject // Format: seconds (unsigned int) MetaModel::Init_AddAttribute(new AttributeDuration("delete_policy_retention", array("allowed_values"=>null, "sql"=>"delete_policy_retention", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeLinkedSet("attribute_list", array("linked_class"=>"SynchroAttribute", "ext_key_to_me"=>"sync_source_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeLinkedSet("attribute_list", array("linked_class"=>"SynchroAttribute", "ext_key_to_me"=>"sync_source_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array(), 'tracking_level' => LINKSET_TRACKING_DETAILS))); // Not used yet ! MetaModel::Init_AddAttribute(new AttributeEnum("user_delete_policy", array("allowed_values"=>new ValueSetEnum('everybody,administrators,nobody'), "sql"=>"user_delete_policy", "default_value"=>"nobody", "is_null_allowed"=>true, "depends_on"=>array()))); @@ -1171,7 +1171,7 @@ class SynchroAttribute extends cmdbAbstractObject ( "category" => "core/cmdb,view_in_gui", "key_type" => "autoincrement", - "name_attcode" => "", + "name_attcode" => "attcode", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_sync_att", @@ -1205,7 +1205,7 @@ class SynchroAttExtKey extends SynchroAttribute ( "category" => "core/cmdb,view_in_gui", "key_type" => "autoincrement", - "name_attcode" => "", + "name_attcode" => "attcode", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_sync_att_extkey", @@ -1253,7 +1253,7 @@ class SynchroAttLinkSet extends SynchroAttribute ( "category" => "core/cmdb,view_in_gui", "key_type" => "autoincrement", - "name_attcode" => "", + "name_attcode" => "attcode", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_sync_att_linkset",