|
@@ -1445,24 +1445,39 @@ EOF
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $oObj->UpdateObjectFromPostedForm('', array_keys($aExpectedAttributes), $sTargetState);
|
|
|
+ $oObj->UpdateObjectFromPostedForm('', array_keys($aExpectedAttributes), $sTargetState);
|
|
|
|
|
|
if (count($aErrors) == 0)
|
|
|
{
|
|
|
$sIssues = '';
|
|
|
- try
|
|
|
+ $bApplyStimulus = true;
|
|
|
+ list($bRes, $aIssues) = $oObj->CheckToWrite(); // Check before trying to write the object
|
|
|
+ if ($bRes)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $bApplyStimulus = $oObj->ApplyStimulus($sStimulus); // will write the object in the DB
|
|
|
+ }
|
|
|
+ catch(CoreException $e)
|
|
|
+ {
|
|
|
+ // Rollback to the previous state... by reloading the object from the database and applying the modifications again
|
|
|
+ $oObj = MetaModel::GetObject(get_class($oObj), $oObj->GetKey());
|
|
|
+ $oObj->UpdateObjectFromPostedForm('', array_keys($aExpectedAttributes), $sTargetState);
|
|
|
+ $aData = $e->getContextData();
|
|
|
+ $sIssues = (array_key_exists('issues', $aData)) ? $aData['issues'] : 'Unknown error...';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- $sPreviousState = $oObj->GetState();
|
|
|
- $bApplyStimulus = $oObj->ApplyStimulus($sStimulus); // will write the object in the DB
|
|
|
+ $sIssues = implode(' ', $aIssues);
|
|
|
}
|
|
|
- catch(CoreException $e)
|
|
|
+
|
|
|
+ if (!$bApplyStimulus)
|
|
|
{
|
|
|
- // Rollback to the previous state...
|
|
|
- $oObj->Set(MetaModel::GetStateAttributeCode(get_class($oObj)), $sPreviousState);
|
|
|
- $aData = $e->getContextData();
|
|
|
- $sIssues = (array_key_exists('issues', $aData)) ? $aData['issues'] : 'Unknown error...';
|
|
|
+ $sMessage = Dict::S('UI:FailedToApplyStimuli');
|
|
|
+ $sSeverity = 'error';
|
|
|
}
|
|
|
- if ($sIssues != '')
|
|
|
+ else if ($sIssues != '')
|
|
|
{
|
|
|
$bDisplayDetails = false;
|
|
|
// Found issues, explain and give the user a second chance
|