mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8807 - Error saving when a DoCheckToWrite check of the linkset fails
This commit is contained in:
@@ -40,12 +40,16 @@ class CoreCannotSaveObjectException extends CoreException
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 3.2.3 add param $bWithHeader
|
||||
*/
|
||||
public function getHtmlMessage()
|
||||
public function getHtmlMessage($bWithHeader = false)
|
||||
{
|
||||
$sTitle = Dict::S('UI:Error:SaveFailed');
|
||||
$sContent = "<span><strong>".utils::HtmlEntities($sTitle)."</strong></span>";
|
||||
|
||||
if ($bWithHeader) {
|
||||
$oObject = MetaModel::GetObject($this->sObjectClass, $this->iObjectId, true, true);
|
||||
$sContent .= " <span>".$oObject->Get('friendlyname')."</span>";
|
||||
}
|
||||
if (count($this->aIssues) == 1) {
|
||||
$sIssue = reset($this->aIssues);
|
||||
$sContent .= " <span>".utils::HtmlEntities($sIssue)."</span>";
|
||||
|
||||
@@ -859,6 +859,15 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
return $oLinkSet;
|
||||
}
|
||||
|
||||
public function RemoveRemoved()
|
||||
{
|
||||
$this->aRemoved = [];
|
||||
}
|
||||
public function GetRemoved()
|
||||
{
|
||||
return $this->aRemoved ;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetValues.
|
||||
*
|
||||
|
||||
@@ -968,6 +968,7 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'UI:SystemIntrusion' => 'Access denied. You have requested an operation that is not allowed for you.',
|
||||
'UI:FatalErrorMessage' => 'Fatal error, '.ITOP_APPLICATION_SHORT.' cannot continue.',
|
||||
'UI:Error_Details' => 'Error: %1$s.',
|
||||
'UI:LinkedSet:RemovedObjectsDuringRefresh' => 'Warning: removed object(s) in <b>%1$s</b> are there again : <br>%2$s',
|
||||
|
||||
'UI:PageTitle:ProfileProjections' => ITOP_APPLICATION_SHORT.' user management - profile projections',
|
||||
'UI:UserManagement:Class' => 'Class',
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
namespace Combodo\iTop\Controller\Base\Layout;
|
||||
|
||||
use AttributeLinkedSet;
|
||||
use Combodo\iTop\Application\WebPage\AjaxPage;
|
||||
use ApplicationContext;
|
||||
use ApplicationException;
|
||||
@@ -661,13 +662,35 @@ JS;
|
||||
// Found issues, explain and give the user a second chance
|
||||
//
|
||||
$bDisplayDetails = false;
|
||||
$aIssues = $e->getIssues();
|
||||
if ($this->IsHandlingXmlHttpRequest()) {
|
||||
$aResult['data'] = ['error_message' => $e->getHtmlMessage()];
|
||||
} else {
|
||||
$oPage->AddHeaderMessage($e->getHtmlMessage(), 'message_error');
|
||||
$oObj->DisplayModifyForm($oPage,
|
||||
array('wizard_container' => true)); // wizard_container: display the wizard border and the title
|
||||
//8807 - displayModifyForm fail if a linkset is removed -> remove removed linkset and display a specific message
|
||||
$bWithLinkedSetRemoved = false;
|
||||
foreach ($oObj->ListChanges() as $sAttCode => $aChange) {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
if ($oAttDef instanceof AttributeLinkedSet) {
|
||||
$aRemoved = $aChange->GetRemoved();
|
||||
if (count($aRemoved) > 0) {
|
||||
$bWithLinkedSetRemoved = true;
|
||||
$sLinkedClass = $oAttDef->GetLinkedClass();
|
||||
$aRemovedObjectFriendlyName = [];
|
||||
foreach ($aRemoved as $key=>$value) {
|
||||
$oLinkedObject = MetaModel::GetObject($sLinkedClass, $key, true, true);
|
||||
$aRemovedObjectFriendlyName[] = $oLinkedObject->Get('friendlyname');
|
||||
}
|
||||
$aChange->RemoveRemoved();
|
||||
$sRemovedMessage = Dict::Format('UI:LinkedSet:RemovedObjectsDuringRefresh', $oAttDef->GetLabel(), implode('<br> ', $aRemovedObjectFriendlyName));
|
||||
$oPage->AddHeaderMessage($sRemovedMessage, 'message_info');
|
||||
}
|
||||
}
|
||||
}
|
||||
if($bWithLinkedSetRemoved) {
|
||||
$oPage->AddHeaderMessage($e->getHtmlMessage(true), 'message_error');
|
||||
} else {
|
||||
$oPage->AddHeaderMessage($e->getHtmlMessage(), 'message_error');
|
||||
}
|
||||
$oObj->DisplayModifyForm($oPage, array('wizard_container' => true)); // wizard_container: display the wizard border and the title
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user