From 18f9f14dcde58bd610861c2d8516d7c87d431e32 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Thu, 12 Jun 2025 17:36:00 +0200 Subject: [PATCH 1/6] =?UTF-8?q?N=C2=B07577=20-=20Issue=20with=20GetAttribu?= =?UTF-8?q?teFlags=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 db70affe93..59f961d397 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -176,6 +176,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 @@ -3884,7 +3886,36 @@ public function GetWriteableAttList($aAttList, &$aErrors, $aAttFlags = array()) 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) @@ -4110,6 +4141,7 @@ public function UpdateObjectFromPostedForm($sFormPrefix = '', $aAttList = null, $aErrors = array(); $aFinalValues = array(); + $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]; From f08350a72c9d81d7f96fc3903aca986f19067406 Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:45:28 +0200 Subject: [PATCH 2/6] Update application/cmdbabstract.class.inc.php Co-authored-by: Thomas Casteleyn --- application/cmdbabstract.class.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 59f961d397..ae9785fac7 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -176,7 +176,9 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay */ protected $sDisplayMode; protected $aFieldsMap; - /*store posted values in order to be used in GetAttributeFlag*/ + /** + * @var array Store posted values in order to be used in GetAttributeFlag + */ protected $aPostedValues = []; /** From a8ac86fca6151c7e6e8e6d135e390b4d83d569be Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 16 Jun 2025 11:46:47 +0200 Subject: [PATCH 3/6] fix php doc --- application/cmdbabstract.class.inc.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index ae9785fac7..d4154b944e 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3892,27 +3892,24 @@ public function GetWriteableAttList($aAttList, &$aErrors, $aAttFlags = array()) * 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) + public function GetCurrentValue($sAttCode) { - if (array_key_exists($sAttr, $this->aPostedValues)) { - return $this->aPostedValues[$sAttr]; + if (array_key_exists($sAttCode, $this->aPostedValues)) { + return $this->aPostedValues[$sAttCode]; } - return $this->Get($sAttr); + return $this->Get($sAttCode); } /* * 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) + * @param $sAttr */ - public function IsModifiedValue($sAttr) + public function IsModifiedValue($sAttCode) { - if (array_key_exists($sAttr, $this->aPostedValues)) { - return $this->aPostedValues[$sAttr] == $this->Get($sAttr); + if (array_key_exists($sAttCode, $this->aPostedValues)) { + return $this->aPostedValues[$sAttCode] == $this->Get($sAttCode); } return false; } From 000748228faab196b54d4103d8b5026f7432bb95 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 17 Jun 2025 08:43:08 +0200 Subject: [PATCH 4/6] Fix test --- application/cmdbabstract.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index d4154b944e..3d8e7c28de 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3909,7 +3909,7 @@ public function GetCurrentValue($sAttCode) public function IsModifiedValue($sAttCode) { if (array_key_exists($sAttCode, $this->aPostedValues)) { - return $this->aPostedValues[$sAttCode] == $this->Get($sAttCode); + return $this->aPostedValues[$sAttCode] != $this->Get($sAttCode); } return false; } From ea863255662ed6a3af2bec836ef9575f8bb75b97 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 16 Sep 2025 23:34:59 +0200 Subject: [PATCH 5/6] WIP --- application/cmdbabstract.class.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 3d8e7c28de..3282e27b60 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3889,11 +3889,11 @@ public function GetWriteableAttList($aAttList, &$aErrors, $aAttFlags = array()) } /** - * function to test if the posted value or fi not exists the existing value matches the expected value + * function to test if the posted value or if 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 $sAttCode */ - public function GetCurrentValue($sAttCode) + public function GetCurrentValueInScreen($sAttCode) { if (array_key_exists($sAttCode, $this->aPostedValues)) { return $this->aPostedValues[$sAttCode]; @@ -3903,10 +3903,10 @@ public function GetCurrentValue($sAttCode) /* * 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) - * @param $sAttr + * this is used to check if field has been modified in GetAttributeFlag function (useful to manage dynamic readonly attributes) + * @param $sAttCode */ - public function IsModifiedValue($sAttCode) + public function IsModifiedValueInScreen($sAttCode) { if (array_key_exists($sAttCode, $this->aPostedValues)) { return $this->aPostedValues[$sAttCode] != $this->Get($sAttCode); From 88c19e66244296b9cbabf1292ea3f27c04a6a337 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 30 Sep 2025 10:40:31 +0200 Subject: [PATCH 6/6] =?UTF-8?q?N=C2=B02364=20-=20API=20:=20remove=20old=20?= =?UTF-8?q?linkedset=20persistance=20(#733)=20-=20deprecated=20message=20o?= =?UTF-8?q?nly=20on=20console=20and=20portal=20context.=20Avoid=20messages?= =?UTF-8?q?=20during=20tests,=20setup=20and=20other=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/ormlinkset.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ormlinkset.class.inc.php b/core/ormlinkset.class.inc.php index 872b6e3bfa..ded7907613 100644 --- a/core/ormlinkset.class.inc.php +++ b/core/ormlinkset.class.inc.php @@ -521,7 +521,7 @@ public function UpdateFromCompleteList(iDBObjectSetIterator $oFellow) * $oCISet->RemoveItem(123456); * $oTicket->Set(‘functionalcis_list’, $oCISet); */ - if (!ContextTag::Check(ContextTag::TAG_SETUP)) { + if (ContextTag::Check(ContextTag::TAG_PORTAL) || ContextTag::Check(ContextTag::TAG_CONSOLE) ) { DeprecatedCallsLog::NotifyDeprecatedPhpMethod('old pattern - please get previous value of the linked set, modify it and set it back to the host object'); } }