|
@@ -778,18 +778,35 @@ EOF
|
|
list($bRes, $aIssues) = $oObj->CheckToWrite();
|
|
list($bRes, $aIssues) = $oObj->CheckToWrite();
|
|
if ($bRes)
|
|
if ($bRes)
|
|
{
|
|
{
|
|
- $oObj->DBUpdate();
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ CMDBSource::Query('START TRANSACTION');
|
|
|
|
+ $oObj->DBUpdate();
|
|
|
|
+ CMDBSource::Query('COMMIT');
|
|
|
|
+ $sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
|
|
|
+ $sSeverity = 'ok';
|
|
|
|
+ }
|
|
|
|
+ catch(DeleteException $e)
|
|
|
|
+ {
|
|
|
|
+ CMDBSource::Query('ROLLBACK');
|
|
|
|
+ // Say two things: 1) Don't be afraid nothing was modified
|
|
|
|
+ $sMessage = Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
|
|
|
+ $sSeverity = 'info';
|
|
|
|
+ cmdbAbstractObject::SetSessionMessage(get_class($oObj), $oObj->GetKey(), 'UI:Class_Object_NotUpdated', $sMessage, $sSeverity, 0, true /* must not exist */);
|
|
|
|
+ // 2) Ok, there was some trouble indeed
|
|
|
|
+ $sMessage = $e->getMessage();
|
|
|
|
+ $sSeverity = 'error';
|
|
|
|
+ $bDisplayDetails = true;
|
|
|
|
+ }
|
|
utils::RemoveTransaction($sTransactionId);
|
|
utils::RemoveTransaction($sTransactionId);
|
|
|
|
|
|
- $sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
|
|
|
- $sSeverity = 'ok';
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
$bDisplayDetails = false;
|
|
$bDisplayDetails = false;
|
|
// Found issues, explain and give the user a second chance
|
|
// Found issues, explain and give the user a second chance
|
|
//
|
|
//
|
|
- $oObj->DisplayModifyForm($oP, array('wizard_container' => true), $sToken); // wizard_container: display the wizard border and the title
|
|
|
|
|
|
+ $oObj->DisplayModifyForm($oP, array('wizard_container' => true)); // wizard_container: display the wizard border and the title
|
|
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
|
|
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
|
|
$oP->add_ready_script("alert('".addslashes($sIssueDesc)."');");
|
|
$oP->add_ready_script("alert('".addslashes($sIssueDesc)."');");
|
|
}
|
|
}
|