mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
🌐 Improve DBObject::CheckValue and CheckConsistency error messages (#288)
Now contains attribute code and value
This commit is contained in:
@@ -3957,7 +3957,7 @@ HTML;
|
||||
}
|
||||
elseif ($iFlags & OPT_ATT_SLAVE)
|
||||
{
|
||||
$aErrors[$sAttCode] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel());
|
||||
$aErrors[$sAttCode] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel(), $sAttCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2022 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -2249,8 +2249,9 @@ abstract class DBObject implements iDisplay
|
||||
foreach($aChanges as $sAttCode => $value) {
|
||||
$res = $this->CheckValue($sAttCode);
|
||||
if ($res !== true) {
|
||||
$sAttLabel = $this->GetLabel($sAttCode);
|
||||
// $res contains the error description
|
||||
$this->m_aCheckIssues[] = "Unexpected value for attribute '$sAttCode': $res";
|
||||
$this->m_aCheckIssues[] = Dict::Format('Core:CheckValueError', $sAttLabel, $sAttCode, $res);
|
||||
}
|
||||
|
||||
$this->DoCheckLinkedSetDuplicates($sAttCode, $value);
|
||||
@@ -2265,7 +2266,7 @@ abstract class DBObject implements iDisplay
|
||||
if ($res !== true)
|
||||
{
|
||||
// $res contains the error description
|
||||
$this->m_aCheckIssues[] = "Consistency rules not followed: $res";
|
||||
$this->m_aCheckIssues[] = Dict::Format('Core:CheckConsistencyError', $res);
|
||||
}
|
||||
|
||||
// Synchronization: are we attempting to modify an attribute for which an external source is master?
|
||||
@@ -2278,12 +2279,10 @@ abstract class DBObject implements iDisplay
|
||||
if ($iFlags & OPT_ATT_SLAVE)
|
||||
{
|
||||
// Note: $aReasonInfo['name'] could be reported (the task owning the attribute)
|
||||
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
||||
$sAttLabel = $oAttDef->GetLabel();
|
||||
if (!empty($aReasons))
|
||||
{
|
||||
// Todo: associate the attribute code with the error
|
||||
$this->m_aCheckIssues[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $sAttLabel);
|
||||
$sAttLabel = $this->GetLabel($sAttCode);
|
||||
$this->m_aCheckIssues[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $sAttLabel, $sAttCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Localized data
|
||||
*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2022 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*
|
||||
* This file is part of iTop.
|
||||
@@ -29,6 +29,8 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'Core:UnknownObjectTip' => 'The object could not be found. It may have been deleted some time ago and the log has been purged since.',
|
||||
|
||||
'Core:UniquenessDefaultError' => 'Uniqueness rule \'%1$s\' in error',
|
||||
'Core:CheckConsistencyError' => 'Consistency rules not followed: %1$s',
|
||||
'Core:CheckValueError' => 'Unexpected value for attribute \'%1$s\' (%2$s) : %3$s',
|
||||
|
||||
'Core:AttributeLinkedSet' => 'Array of objects',
|
||||
'Core:AttributeLinkedSet+' => 'Any kind of objects of the same class or subclass',
|
||||
|
||||
@@ -1162,7 +1162,7 @@ When associated with a trigger, each action is given an "order" number, specifyi
|
||||
'UI:CaseLogTypeYourTextHere' => 'Type your text here...',
|
||||
'UI:CaseLog:Header_Date_UserName' => '%1$s - %2$s:',
|
||||
'UI:CaseLog:InitialValue' => 'Initial value:',
|
||||
'UI:AttemptingToSetASlaveAttribute_Name' => 'The field %1$s is not writable because it is mastered by the data synchronization. Value not set.',
|
||||
'UI:AttemptingToSetASlaveAttribute_Name' => 'The field %1$s (%2$s) is not writable because it is mastered by the data synchronization. Value not set.',
|
||||
'UI:ActionNotAllowed' => 'You are not allowed to perform this action on these objects.',
|
||||
'UI:BulkAction:NoObjectSelected' => 'Please select at least one object to perform this operation',
|
||||
'UI:AttemptingToChangeASlaveAttribute_Name' => 'The field %1$s is not writable because it is mastered by the data synchronization. Value remains unchanged.',
|
||||
|
||||
@@ -1455,7 +1455,7 @@ EOF
|
||||
if ( ($iFlags & OPT_ATT_SLAVE) && ($paramValue != $oObj->Get($sAttCode)) )
|
||||
{
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
$aErrors[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel());
|
||||
$aErrors[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $oAttDef->GetLabel(), $sAttCode);
|
||||
unset($aExpectedAttributes[$sAttCode]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user