|
@@ -209,6 +209,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
|
$oPage->add($this->GetBareProperties($oPage, $bEditMode));
|
|
$oPage->add($this->GetBareProperties($oPage, $bEditMode));
|
|
|
|
|
|
// Special case to display the case log, if any...
|
|
// Special case to display the case log, if any...
|
|
|
|
+ // WARNING: if you modify the loop below, also check the corresponding code in UpdateObject and DisplayModifyForm
|
|
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
|
|
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
|
|
{
|
|
{
|
|
if ($oAttDef instanceof AttributeCaseLog)
|
|
if ($oAttDef instanceof AttributeCaseLog)
|
|
@@ -1717,6 +1718,7 @@ EOF
|
|
}
|
|
}
|
|
|
|
|
|
// Special case to display the case log, if any...
|
|
// Special case to display the case log, if any...
|
|
|
|
+ // WARNING: if you modify the loop below, also check the corresponding code in UpdateObject and DisplayDetails
|
|
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
|
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
|
{
|
|
{
|
|
if ($oAttDef instanceof AttributeCaseLog)
|
|
if ($oAttDef instanceof AttributeCaseLog)
|
|
@@ -2157,57 +2159,28 @@ EOF
|
|
if (!is_array($aAttList))
|
|
if (!is_array($aAttList))
|
|
{
|
|
{
|
|
$aAttList = $this->FlattenZList(MetaModel::GetZListItems(get_class($this), 'details'));
|
|
$aAttList = $this->FlattenZList(MetaModel::GetZListItems(get_class($this), 'details'));
|
|
- }
|
|
|
|
- foreach($aAttList as $sAttCode)
|
|
|
|
- {
|
|
|
|
- $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
|
|
|
-
|
|
|
|
- if ($oAttDef->IsLinkSet() && $oAttDef->IsIndirect())
|
|
|
|
- {
|
|
|
|
- $aLinks = utils::ReadPostedParam("attr_{$sFormPrefix}{$sAttCode}", null);
|
|
|
|
- $sLinkedClass = $oAttDef->GetLinkedClass();
|
|
|
|
- $sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
|
|
|
|
- $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
|
|
|
|
- $oLinkedSet = DBObjectSet::FromScratch($sLinkedClass);
|
|
|
|
- if (is_array($aLinks))
|
|
|
|
|
|
+ // Special case to process the case log, if any...
|
|
|
|
+ // WARNING: if you change this also check the functions DisplayModifyForm and DisplayCaseLog
|
|
|
|
+ foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
|
|
|
|
+ {
|
|
|
|
+ $iFlags = $this->GetAttributeFlags($sAttCode);
|
|
|
|
+ if ($oAttDef instanceof AttributeCaseLog)
|
|
{
|
|
{
|
|
- foreach($aLinks as $id => $aData)
|
|
|
|
|
|
+ if (!($iFlags & (OPT_ATT_HIDDEN|OPT_ATT_SLAVE|OPT_ATT_READONLY)))
|
|
{
|
|
{
|
|
- if (is_numeric($id))
|
|
|
|
- {
|
|
|
|
- if ($id < 0)
|
|
|
|
- {
|
|
|
|
- // New link to be created, the opposite of the id (-$id) is the ID of the remote object
|
|
|
|
- $oLink = MetaModel::NewObject($sLinkedClass);
|
|
|
|
- $oLink->Set($sExtKeyToRemote, -$id);
|
|
|
|
- $oLink->Set($sExtKeyToMe, $this->GetKey());
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // Existing link, potentially to be updated...
|
|
|
|
- $oLink = MetaModel::GetObject($sLinkedClass, $id);
|
|
|
|
- }
|
|
|
|
- // Now populate the attributes
|
|
|
|
- foreach($aData as $sName => $value)
|
|
|
|
- {
|
|
|
|
- if (MetaModel::IsValidAttCode($sLinkedClass, $sName))
|
|
|
|
- {
|
|
|
|
- $oLinkAttDef = MetaModel::GetAttributeDef($sLinkedClass, $sName);
|
|
|
|
- if ($oLinkAttDef->IsWritable())
|
|
|
|
- {
|
|
|
|
- $oLink->Set($sName, $value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $oLinkedSet->AddObject($oLink);
|
|
|
|
- }
|
|
|
|
|
|
+ // The case log is editable, append it to the list of fields to retrieve
|
|
|
|
+ $aAttList[] = $sAttCode;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $this->Set($sAttCode, $oLinkedSet);
|
|
|
|
}
|
|
}
|
|
- else if ($oAttDef->IsWritable())
|
|
|
|
|
|
+ }
|
|
|
|
+ foreach($aAttList as $sAttCode)
|
|
|
|
+ {
|
|
|
|
+ $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
|
|
|
+
|
|
|
|
+ $iFlags = $this->GetAttributeFlags($sAttCode);
|
|
|
|
+ if ($oAttDef->IsWritable())
|
|
{
|
|
{
|
|
- $iFlags = $this->GetAttributeFlags($sAttCode);
|
|
|
|
if ( $iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY))
|
|
if ( $iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY))
|
|
{
|
|
{
|
|
// Non-visible, or read-only attribute, do nothing
|
|
// Non-visible, or read-only attribute, do nothing
|
|
@@ -2220,6 +2193,49 @@ EOF
|
|
$aErrors[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel());
|
|
$aErrors[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ elseif ($oAttDef->IsLinkSet() && $oAttDef->IsIndirect())
|
|
|
|
+ {
|
|
|
|
+ $aLinks = utils::ReadPostedParam("attr_{$sFormPrefix}{$sAttCode}", null);
|
|
|
|
+ $sLinkedClass = $oAttDef->GetLinkedClass();
|
|
|
|
+ $sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
|
|
|
|
+ $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
|
|
|
|
+ $oLinkedSet = DBObjectSet::FromScratch($sLinkedClass);
|
|
|
|
+ if (is_array($aLinks))
|
|
|
|
+ {
|
|
|
|
+ foreach($aLinks as $id => $aData)
|
|
|
|
+ {
|
|
|
|
+ if (is_numeric($id))
|
|
|
|
+ {
|
|
|
|
+ if ($id < 0)
|
|
|
|
+ {
|
|
|
|
+ // New link to be created, the opposite of the id (-$id) is the ID of the remote object
|
|
|
|
+ $oLink = MetaModel::NewObject($sLinkedClass);
|
|
|
|
+ $oLink->Set($sExtKeyToRemote, -$id);
|
|
|
|
+ $oLink->Set($sExtKeyToMe, $this->GetKey());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // Existing link, potentially to be updated...
|
|
|
|
+ $oLink = MetaModel::GetObject($sLinkedClass, $id);
|
|
|
|
+ }
|
|
|
|
+ // Now populate the attributes
|
|
|
|
+ foreach($aData as $sName => $value)
|
|
|
|
+ {
|
|
|
|
+ if (MetaModel::IsValidAttCode($sLinkedClass, $sName))
|
|
|
|
+ {
|
|
|
|
+ $oLinkAttDef = MetaModel::GetAttributeDef($sLinkedClass, $sName);
|
|
|
|
+ if ($oLinkAttDef->IsWritable())
|
|
|
|
+ {
|
|
|
|
+ $oLink->Set($sName, $value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $oLinkedSet->AddObject($oLink);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $this->Set($sAttCode, $oLinkedSet);
|
|
|
|
+ }
|
|
elseif ($oAttDef->GetEditClass() == 'Document')
|
|
elseif ($oAttDef->GetEditClass() == 'Document')
|
|
{
|
|
{
|
|
// There should be an uploaded file with the named attr_<attCode>
|
|
// There should be an uploaded file with the named attr_<attCode>
|