N°1703 The dates are no longer reset when inserting a Ticket

Could cause problems when importing using REST API or using form prefill
This commit is contained in:
Pierre Goiffon
2018-10-23 14:15:39 +02:00
parent d61a8ba160
commit 34552214bf
8 changed files with 56 additions and 12 deletions

View File

@@ -448,6 +448,25 @@ abstract class DBObject implements iDisplay
return true;
}
/**
* @param string $sAttCode
* @param mixed $value
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \Exception
* @since 2.6
*/
public function SetIfNull($sAttCode, $value)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$oCurrentValue = $this->Get($sAttCode);
if ($oAttDef->IsNull($oCurrentValue))
{
$this->Set($sAttCode, $value);
}
}
public function SetTrim($sAttCode, $sValue)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);

View File

@@ -935,8 +935,8 @@
{
parent::OnInsert();
$this->UpdateImpactedItems();
$this->Set('creation_date', time());
$this->Set('last_update', time());
$this->SetIfNull('creation_date', time());
$this->SetIfNull('last_update', time());
}]]>
</code>
</method>

View File

@@ -503,8 +503,8 @@
{
parent::OnInsert();
$this->UpdateImpactedItems();
$this->Set('creation_date', time());
$this->Set('last_update', time());
$this->SetIfNull('creation_date', time());
$this->SetIfNull('last_update', time());
}]]></code>
</method>
<method id="OnUpdate">

View File

@@ -1344,8 +1344,8 @@
{
parent::OnInsert();
$this->ComputeImpactedItems();
$this->Set('last_update', time());
$this->Set('start_date', time());
$this->SetIfNull('last_update', time());
$this->SetIfNull('start_date', time());
}]]></code>
</method>
<method id="OnUpdate">

View File

@@ -459,8 +459,8 @@
<type>Overload-DBObject</type>
<code><![CDATA[ protected function OnInsert()
{
$this->Set('start_date', time());
$this->Set('last_update', time());
$this->SetIfNull('start_date', time());
$this->SetIfNull('last_update', time());
}]]></code>
</method>
<method id="OnUpdate">

View File

@@ -1397,8 +1397,8 @@
protected function OnInsert()
{
$this->ComputeImpactedItems();
$this->Set('last_update', time());
$this->Set('start_date', time());
$this->SetIfNull('last_update', time());
$this->SetIfNull('start_date', time());
}]]></code>
</method>
<method id="OnUpdate">

View File

@@ -1421,8 +1421,9 @@
{
parent::OnInsert();
$this->ComputeImpactedItems();
$this->Set('last_update', time());
$this->Set('start_date', time());
$this->SetIfNull('last_update', time());
$this->SetIfNull('start_date', time());
}]]></code>
</method>
<method id="OnUpdate">

View File

@@ -851,6 +851,30 @@
</argument>
</arguments>
</method>
<method id="SetIfNull">
<arguments>
<argument id="1">
<type>attcode</type>
<mandatory>true</mandatory>
<type_restrictions>
<operation>deny</operation>
<types>
<type id="AttributeStopWatch"/>
<type id="AttributeSubItem"/>
<type id="AttributeExternalField"/>
<type id="AttributeLinkedSetIndirect"/>
<type id="AttributeLinkedSet"/>
<type id="AttributeImage"/>
<type id="AttributeBlob"/>
</types>
</type_restrictions>
</argument>
<argument id="2">
<type>string</type>
<mandatory>true</mandatory>
</argument>
</arguments>
</method>
<method id="SetCurrentDate">
<arguments>
<argument id="1">