mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°7070 - remove _delta attribute from datamodel and avoid _delta attributes under a node having _delta in [define, define_if_not_exist, redefine, force] in deltas
This commit is contained in:
@@ -77,7 +77,7 @@
|
|||||||
<default_value/>
|
<default_value/>
|
||||||
<is_null_allowed>true</is_null_allowed>
|
<is_null_allowed>true</is_null_allowed>
|
||||||
</field>
|
</field>
|
||||||
<field id="contacts_list" xsi:type="AttributeLinkedSetIndirect" _delta="define">
|
<field id="contacts_list" xsi:type="AttributeLinkedSetIndirect">
|
||||||
<linked_class>lnkContactToFunctionalCI</linked_class>
|
<linked_class>lnkContactToFunctionalCI</linked_class>
|
||||||
<ext_key_to_me>functionalci_id</ext_key_to_me>
|
<ext_key_to_me>functionalci_id</ext_key_to_me>
|
||||||
<count_min>0</count_min>
|
<count_min>0</count_min>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</allowed_portals>
|
</allowed_portals>
|
||||||
</properties>
|
</properties>
|
||||||
<classes>
|
<classes>
|
||||||
<class id="User" _delta="define">
|
<class id="User">
|
||||||
<!-- Allow <allowed_profile>s to apply the <transition>s below. Flags on <field>s will be merged with those from datamodel -->
|
<!-- Allow <allowed_profile>s to apply the <transition>s below. Flags on <field>s will be merged with those from datamodel -->
|
||||||
<!-- See example in UserRequest class -->
|
<!-- See example in UserRequest class -->
|
||||||
<!--<lifecycle/>-->
|
<!--<lifecycle/>-->
|
||||||
@@ -56,21 +56,21 @@
|
|||||||
</scope>
|
</scope>
|
||||||
</scopes>
|
</scopes>
|
||||||
</class>
|
</class>
|
||||||
<class id="Organization" _delta="define">
|
<class id="Organization">
|
||||||
<scopes>
|
<scopes>
|
||||||
<scope id="all">
|
<scope id="all">
|
||||||
<oql_view><![CDATA[SELECT Organization WHERE id = :current_contact->org_id]]></oql_view>
|
<oql_view><![CDATA[SELECT Organization WHERE id = :current_contact->org_id]]></oql_view>
|
||||||
</scope>
|
</scope>
|
||||||
</scopes>
|
</scopes>
|
||||||
</class>
|
</class>
|
||||||
<class id="Location" _delta="define">
|
<class id="Location">
|
||||||
<scopes>
|
<scopes>
|
||||||
<scope id="all">
|
<scope id="all">
|
||||||
<oql_view><![CDATA[SELECT Location WHERE org_id = :current_contact->org_id]]></oql_view>
|
<oql_view><![CDATA[SELECT Location WHERE org_id = :current_contact->org_id]]></oql_view>
|
||||||
</scope>
|
</scope>
|
||||||
</scopes>
|
</scopes>
|
||||||
</class>
|
</class>
|
||||||
<class id="Contact" _delta="define">
|
<class id="Contact">
|
||||||
<scopes>
|
<scopes>
|
||||||
<scope id="all">
|
<scope id="all">
|
||||||
<oql_view><![CDATA[SELECT Contact WHERE org_id = :current_contact->org_id]]></oql_view>
|
<oql_view><![CDATA[SELECT Contact WHERE org_id = :current_contact->org_id]]></oql_view>
|
||||||
@@ -145,9 +145,9 @@
|
|||||||
</bricks>
|
</bricks>
|
||||||
<navigation_rules>
|
<navigation_rules>
|
||||||
<!-- Close form (either the modal or the whole page) -->
|
<!-- Close form (either the modal or the whole page) -->
|
||||||
<navigation_rule id="close-form" xsi:type="close" _delta="define"/>
|
<navigation_rule id="close-form" xsi:type="close"/>
|
||||||
<!-- Go to the homepage -->
|
<!-- Go to the homepage -->
|
||||||
<navigation_rule id="go-to-homepage" xsi:type="go-to-homepage" _delta="define"/>
|
<navigation_rule id="go-to-homepage" xsi:type="go-to-homepage"/>
|
||||||
</navigation_rules>
|
</navigation_rules>
|
||||||
</module_design>
|
</module_design>
|
||||||
</module_designs>
|
</module_designs>
|
||||||
|
|||||||
@@ -277,7 +277,7 @@
|
|||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</method>
|
</method>
|
||||||
<method id="AddCurrentUserToContacts" _revision_id="294" _delta="define">
|
<method id="AddCurrentUserToContacts" _revision_id="294">
|
||||||
<comment>/**
|
<comment>/**
|
||||||
*
|
*
|
||||||
* Add the current contact associated Person to the contacts_list of this Ticket
|
* Add the current contact associated Person to the contacts_list of this Ticket
|
||||||
@@ -305,7 +305,7 @@
|
|||||||
}]]></code>
|
}]]></code>
|
||||||
<arguments/>
|
<arguments/>
|
||||||
</method>
|
</method>
|
||||||
<method id="RemoveCurrentUserFromContacts" _revision_id="296" _delta="define">
|
<method id="RemoveCurrentUserFromContacts" _revision_id="296">
|
||||||
<comment>/**
|
<comment>/**
|
||||||
*
|
*
|
||||||
* Remove the current user associated Person from the contacts_list of this Ticket
|
* Remove the current user associated Person from the contacts_list of this Ticket
|
||||||
|
|||||||
@@ -2357,29 +2357,24 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
public function ApplyChanges()
|
public function ApplyChanges()
|
||||||
{
|
{
|
||||||
$oNodes = $this->ListChanges();
|
// Note: omitting the dot will make the query be global to the whole document!!!
|
||||||
foreach ($oNodes as $oNode)
|
$oNodes = $this->ownerDocument->GetNodes('.//*[@_alteration or @_old_id or @_delta]', $this, false);;
|
||||||
{
|
foreach ($oNodes as $oNode) {
|
||||||
$sOperation = $oNode->GetAttribute('_alteration');
|
// _delta must not exist after applying changes
|
||||||
switch ($sOperation)
|
if ($oNode->hasAttribute('_delta')) {
|
||||||
{
|
$oNode->removeAttribute('_delta');
|
||||||
case 'added':
|
|
||||||
case 'replaced':
|
|
||||||
case 'needed':
|
|
||||||
case 'forced':
|
|
||||||
// marked as added or modified, just reset the flag
|
|
||||||
$oNode->removeAttribute('_alteration');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'removed':
|
|
||||||
// marked as deleted, let's remove the node from the tree
|
|
||||||
$oNode->parentNode->removeChild($oNode);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if ($oNode->hasAttribute('_old_id'))
|
if ($oNode->hasAttribute('_old_id')) {
|
||||||
{
|
|
||||||
$oNode->removeAttribute('_old_id');
|
$oNode->removeAttribute('_old_id');
|
||||||
}
|
}
|
||||||
|
if ($oNode->hasAttribute('_alteration')) {
|
||||||
|
if ('removed' === $oNode->GetAttribute('_alteration')) {
|
||||||
|
$oNode->parentNode->removeChild($oNode);
|
||||||
|
} else {
|
||||||
|
// marked as added or modified, just reset the flag
|
||||||
|
$oNode->removeAttribute('_alteration');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -727,7 +727,33 @@ XML
|
|||||||
<nodeB id="Banner">
|
<nodeB id="Banner">
|
||||||
<nodeE/>
|
<nodeE/>
|
||||||
<nodeC>
|
<nodeC>
|
||||||
<nodeD id="Bruce" _delta="define"/>
|
<nodeD id="Bruce"/>
|
||||||
|
</nodeC>
|
||||||
|
</nodeB>
|
||||||
|
</nodeA>
|
||||||
|
XML
|
||||||
|
];
|
||||||
|
$aDeltas['nested _delta should be cleaned'] = [
|
||||||
|
'sInitialXML' => <<<XML
|
||||||
|
<nodeA>
|
||||||
|
</nodeA>
|
||||||
|
XML
|
||||||
|
,
|
||||||
|
'sDeltaXML' => <<<XML
|
||||||
|
<nodeA>
|
||||||
|
<nodeB id="Banner" _delta="define">
|
||||||
|
<nodeC>
|
||||||
|
<nodeD id="Bruce" _delta="define"/>
|
||||||
|
</nodeC>
|
||||||
|
</nodeB>
|
||||||
|
</nodeA>
|
||||||
|
XML
|
||||||
|
,
|
||||||
|
'sExpectedXML' => <<<XML
|
||||||
|
<nodeA>
|
||||||
|
<nodeB id="Banner">
|
||||||
|
<nodeC>
|
||||||
|
<nodeD id="Bruce"/>
|
||||||
</nodeC>
|
</nodeC>
|
||||||
</nodeB>
|
</nodeB>
|
||||||
</nodeA>
|
</nodeA>
|
||||||
|
|||||||
Reference in New Issue
Block a user