From a8c834b1e968cd4b30501fa96bcb13d785909c6c Mon Sep 17 00:00:00 2001 From: vdumas Date: Fri, 12 Feb 2021 11:05:39 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03495=20WorkOrder:=20on=20closure=20set?= =?UTF-8?q?=20end=5Fdate=20only=20if=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/datamodel.application.xml | 16 +++++++++++++ core/dbobject.class.php | 24 +++++++++++++++++++ .../itop-tickets/datamodel.itop-tickets.xml | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/application/datamodel.application.xml b/application/datamodel.application.xml index 2858b3c1e..8095c6368 100644 --- a/application/datamodel.application.xml +++ b/application/datamodel.application.xml @@ -253,6 +253,22 @@ + + + + attcode + true + + allow + + + + + + + + + diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 481bd0bc7..1127b5910 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -3982,6 +3982,30 @@ abstract class DBObject implements iDisplay return true; } + /** + * Helper to set a value only if it is currently undefined + * + * Call SetCurrentDate() only of the internal representation of the attribute is null. + * + * @api + * @see SetCurrentDate() + * + * @param string $sAttCode + * + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @since 3.0.0 + */ + public function SetCurrentDateIfNull($sAttCode) + { + $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode); + $oCurrentValue = $this->Get($sAttCode); + if ($oAttDef->IsNull($oCurrentValue)) + { + $this->SetCurrentDate($sAttCode); + } + } + /** * Helper to set the current logged in user for the given attribute * Suitable for use as a lifecycle action diff --git a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml index ad7ad68f8..9b8dd7c5d 100755 --- a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml +++ b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml @@ -604,7 +604,7 @@ closed - SetCurrentDate + SetCurrentDateIfNull end_date