Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions application/exceptions/CoreCannotSaveObjectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ public function __construct($aContextData, $oPrevious = null)

/**
* @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 .= "&nbsp;<span>".$oObject->Get('friendlyname')."</span>";
}
if (count($this->aIssues) == 1) {
$sIssue = reset($this->aIssues);
$sContent .= "&nbsp;<span>".utils::HtmlEntities($sIssue)."</span>";
Expand Down
9 changes: 9 additions & 0 deletions core/ormlinkset.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,15 @@ public function ToDBObjectSet($bShowObsolete = true)
return $oLinkSet;
}

public function RemoveRemoved()
{
$this->aRemoved = [];
}
public function GetRemoved()
{
return $this->aRemoved ;
}

/**
* GetValues.
*
Expand Down
1 change: 1 addition & 0 deletions dictionaries/en.dictionary.itop.ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@
'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',
Expand Down
31 changes: 27 additions & 4 deletions sources/Controller/Base/Layout/ObjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Combodo\iTop\Controller\Base\Layout;

use AttributeLinkedSet;
use Combodo\iTop\Application\WebPage\AjaxPage;
use ApplicationContext;
use ApplicationException;
Expand Down Expand Up @@ -661,13 +662,35 @@ public function OperationApplyModify(){
// 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
}

}
Expand Down