mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Fix AttributeSet wrong error on number of tags in creation
This commit is contained in:
@@ -3370,7 +3370,7 @@ EOF
|
|||||||
$oSet = $this->Get($sAttCode);
|
$oSet = $this->Get($sAttCode);
|
||||||
if (is_null($oSet))
|
if (is_null($oSet))
|
||||||
{
|
{
|
||||||
$oSet = new ormSet(get_class($this), $sAttCode);
|
$oSet = new ormSet(get_class($this), $sAttCode, $oAttDef->GetMaxItems());
|
||||||
}
|
}
|
||||||
$oSet->ApplyDelta($value);
|
$oSet->ApplyDelta($value);
|
||||||
$this->Set($sAttCode, $oSet);
|
$this->Set($sAttCode, $oSet);
|
||||||
@@ -3427,7 +3427,14 @@ EOF
|
|||||||
{
|
{
|
||||||
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
|
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
|
||||||
}
|
}
|
||||||
$this->UpdateObjectFromArray($aFinalValues);
|
try
|
||||||
|
{
|
||||||
|
$this->UpdateObjectFromArray($aFinalValues);
|
||||||
|
}
|
||||||
|
catch (CoreException $e)
|
||||||
|
{
|
||||||
|
$aErrors[] = $e->getMessage();
|
||||||
|
}
|
||||||
if (!$this->IsNew()) // for new objects this is performed in DBInsertNoReload()
|
if (!$this->IsNew()) // for new objects this is performed in DBInsertNoReload()
|
||||||
{
|
{
|
||||||
InlineImage::FinalizeInlineImages($this);
|
InlineImage::FinalizeInlineImages($this);
|
||||||
@@ -3660,8 +3667,14 @@ EOF
|
|||||||
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
|
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->UpdateObjectFromArray($aFinalValues);
|
try
|
||||||
|
{
|
||||||
|
$this->UpdateObjectFromArray($aFinalValues);
|
||||||
|
}
|
||||||
|
catch (CoreException $e)
|
||||||
|
{
|
||||||
|
$aErrors[] = $e->getMessage();
|
||||||
|
}
|
||||||
return $aErrors;
|
return $aErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class WizardHelper
|
|||||||
else if ($oAttDef instanceof AttributeSet) // AttributeDate is derived from AttributeDateTime
|
else if ($oAttDef instanceof AttributeSet) // AttributeDate is derived from AttributeDateTime
|
||||||
{
|
{
|
||||||
$value = json_decode($value, true);
|
$value = json_decode($value, true);
|
||||||
$oTagSet = new ormSet(get_class($oObj), $sAttCode);
|
$oTagSet = new ormSet(get_class($oObj), $sAttCode, $oAttDef->GetMaxItems());
|
||||||
$oTagSet->SetValues($value['orig_value']);
|
$oTagSet->SetValues($value['orig_value']);
|
||||||
$oTagSet->ApplyDelta($value);
|
$oTagSet->ApplyDelta($value);
|
||||||
$oObj->Set($sAttCode, $oTagSet);
|
$oObj->Set($sAttCode, $oTagSet);
|
||||||
|
|||||||
@@ -1357,7 +1357,7 @@ abstract class DBObject implements iDisplay
|
|||||||
{
|
{
|
||||||
if (is_string($toCheck))
|
if (is_string($toCheck))
|
||||||
{
|
{
|
||||||
$oTag = new ormSet(get_class($this), $sAttCode);
|
$oTag = new ormSet(get_class($this), $sAttCode, $oAtt->GetMaxItems());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$aValues = array();
|
$aValues = array();
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class ormSet
|
|||||||
*/
|
*/
|
||||||
public function GetDelta(ormSet $oOtherSet)
|
public function GetDelta(ormSet $oOtherSet)
|
||||||
{
|
{
|
||||||
$oSet = new ormSet($this->sClass, $this->sAttCode);
|
$oSet = new ormSet($this->sClass, $this->sAttCode, $this->iLimit);
|
||||||
// Set the initial value
|
// Set the initial value
|
||||||
$aOrigItems = $this->GetValues();
|
$aOrigItems = $this->GetValues();
|
||||||
$oSet->SetValues($aOrigItems);
|
$oSet->SetValues($aOrigItems);
|
||||||
|
|||||||
@@ -1071,6 +1071,7 @@ EOF
|
|||||||
$sClass = utils::ReadPostedParam('class', '', 'class');
|
$sClass = utils::ReadPostedParam('class', '', 'class');
|
||||||
$sClassLabel = MetaModel::GetName($sClass);
|
$sClassLabel = MetaModel::GetName($sClass);
|
||||||
$sTransactionId = utils::ReadPostedParam('transaction_id', '');
|
$sTransactionId = utils::ReadPostedParam('transaction_id', '');
|
||||||
|
$aErrors = array();
|
||||||
if ( empty($sClass) ) // TO DO: check that the class name is valid !
|
if ( empty($sClass) ) // TO DO: check that the class name is valid !
|
||||||
{
|
{
|
||||||
throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'class'));
|
throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'class'));
|
||||||
@@ -1091,7 +1092,7 @@ EOF
|
|||||||
$oObj->Set($sStateAttCode, $sTargetState);
|
$oObj->Set($sStateAttCode, $sTargetState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oObj->UpdateObjectFromPostedForm();
|
$aErrors = $oObj->UpdateObjectFromPostedForm();
|
||||||
}
|
}
|
||||||
if (isset($oObj) && is_object($oObj))
|
if (isset($oObj) && is_object($oObj))
|
||||||
{
|
{
|
||||||
@@ -1100,6 +1101,11 @@ EOF
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!empty($aErrors))
|
||||||
|
{
|
||||||
|
throw new CoreCannotSaveObjectException(array('id' => $oObj->GetKey(), 'class' => $sClass, 'issues' => $aErrors));
|
||||||
|
}
|
||||||
|
|
||||||
$oObj->DBInsertNoReload();// No need to reload
|
$oObj->DBInsertNoReload();// No need to reload
|
||||||
|
|
||||||
utils::RemoveTransaction($sTransactionId);
|
utils::RemoveTransaction($sTransactionId);
|
||||||
|
|||||||
Reference in New Issue
Block a user