From cc8c3d3bf13b07db58aaff02f65f9fd85250a32f Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Thu, 12 Jun 2025 17:36:00 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B07577=20-=20Issue=20with=20GetAttributeFl?= =?UTF-8?q?ags=20when=20Attributes=20are=20set=20to=20HIDDEN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 08354b1878..36c6001788 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -175,6 +175,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay */ protected $sDisplayMode; protected $aFieldsMap; + /*store posted values in order to be used in GetAttributeFlag*/ + protected $aPostedValues = []; /** * If true, bypass IsActionAllowedOnAttribute when writing this object @@ -3794,7 +3796,36 @@ HTML; return $aWriteableAttList; } - /** + /** + * function to test if the posted value or fi not exists the existing value matches the expected value + * this is used to check the current value in GetAttributeFlag function (useful to manage dynamic readonly attributes) + * @param $sAttr + * @param $sValue + * @return bool + * @throws ArchivedObjectException + * @throws CoreException + */ + public function GetCurrentValue($sAttr) + { + if (array_key_exists($sAttr, $this->aPostedValues)) { + return $this->aPostedValues[$sAttr]; + } + return $this->Get($sAttr); + } + + /* + * This function checks if the value of the attribute has been modified in screen + * this is used to check if field has been modifed in GetAttributeFlag function (useful to manage dynamic readonly attributes) + */ + public function IsModifiedValue($sAttr) + { + if (array_key_exists($sAttr, $this->aPostedValues)) { + return $this->aPostedValues[$sAttr] == $this->Get($sAttr); + } + return false; + } + + /** * Compute the attribute flags depending on the object state */ public function GetFormAttributeFlags($sAttCode) @@ -3986,6 +4017,7 @@ HTML; $aErrors = []; $aFinalValues = []; + $this->aPostedValues = $aValues; // Store the values for later use (e.g. in getAttributeFlag) foreach ($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef) { $aFinalValues[$sAttCode] = $aValues[$sAttCode]; }