David,<br><br>We haven&#39;t created a trac ticket yet. You can go ahead and report the issue on trac.<br><br><div class="gmail_quote">On Thu, Jan 27, 2011 at 9:13 PM, David V. <span dir="ltr">&lt;<a href="http://davidv.net">davidv.net</a>@<a href="http://gmail.com">gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Asha,<div><br></div><div>Should I open a ticket on Trac or have you done it already ?</div><div>
<br clear="all">David V.<br>
<br><br><div class="gmail_quote"><div class="im">2011/1/27 Asha <span dir="ltr">&lt;<a href="mailto:asha@vtiger.com" target="_blank">asha@vtiger.com</a>&gt;</span><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Hi David,<div><div></div><div class="h5"><br><br>Thanks for pointing out to the loop hole in the code base. We shall think and come up with a better solution to it.<br><br>With respect to the changes suggested by you, it will not be the correct one as the return_action will not be CallRelatedList, when Single Pane View is enabled. That is the reason to use the comparison between module and return_module. <br>



<br>But I understand the special case when module is related to itself through mxn relationship, needs to be handled here.<br><br><div class="gmail_quote"><div><div></div><div>On Thu, Jan 27, 2011 at 5:49 PM, David V. <span dir="ltr">&lt;<a href="http://davidv.net" target="_blank">davidv.net</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div><div>Hi !</div><div><br></div>I have a crm installation where the module Accounts is related to itself by a related list.<div>



<br></div><div>It works very well and it&#39;s easy to manage a list of accounts related to any specific account.</div>

<div><br></div><div>The problem is when we want to remove an account Z from the RelatedList of account A.</div><div><br></div><div>Instead of just unlinking the account Z, Vtiger sends it to trash (deletes it).</div><div>





<br></div><div>This is caused by the function DeleteEntity in /include/utils/Utils.php</div><div><br></div><div><br></div><div><div>function DeleteEntity($module,$return_module,$focus,$record,$return_id) {</div><div><span style="white-space: pre-wrap;">        </span>global $log;<span style="white-space: pre-wrap;">        </span></div>





<div><span style="white-space: pre-wrap;">        </span>$log-&gt;debug(&quot;Entering DeleteEntity method ($module, $return_module, $record, $return_id)&quot;);</div><div><span style="white-space: pre-wrap;">        </span></div>

<div><span style="white-space: pre-wrap;">        </span>if ($module != $return_module &amp;&amp; !empty($return_module) &amp;&amp; !empty($return_id)) {</div><div><span style="white-space: pre-wrap;">                </span>$focus-&gt;unlinkRelationship($record, $return_module, $return_id);</div>





<div><span style="white-space: pre-wrap;">        </span>} else {</div><div><span style="white-space: pre-wrap;">                </span>$focus-&gt;trash($module, $record);</div><div><span style="white-space: pre-wrap;">        </span>}</div>

<div><span style="white-space: pre-wrap;">        </span>$log-&gt;debug(&quot;Exiting DeleteEntity method ...&quot;);</div><div>}</div></div><div><br></div><div>It is a smart function but since $module == $return_module in our case, this function does not &quot;unlinkRelationship&quot; but Trashes the $record.</div>





<div><br></div><div><div>So far I&#39;ve found no workaround since there is no trigger available to use an event when deleting an entity. So I ended up modifiying the function. But this is of course not a future proof (I mean update proof) solution as I&#39;ll have to do it every time a new version of Vtiger is released.</div>





</div><div><br></div><div>My question :</div><div>Is there any specific reason to have this test here ( $module != $return_module ) ?</div><div><br></div><div>I think it was added to test if the deletion is occuring within a RelatedList (in most cases in a related list $module != $return_module)</div>





<div><br></div><div>I have another suggestion :</div><div>We could test instead $_REQUEST[&#39;return_action&#39;], if it contains &quot;CallRelatedList&quot; then we are in a RelatedList and we can unlink instead of sending to trash.</div>





<div><br></div><div>Here is my modified function :</div><div><br></div><div><div>function DeleteEntity($module,$return_module,$focus,$record,$return_id) {</div><div><span style="white-space: pre-wrap;">        </span>global $log;<span style="white-space: pre-wrap;">        </span></div>





<div><span style="white-space: pre-wrap;">        </span>$log-&gt;debug(&quot;Entering DeleteEntity method ($module, $return_module, $record, $return_id)&quot;);</div><div><span style="white-space: pre-wrap;">        </span></div>

<div><span style="white-space: pre-wrap;">        </span>if (isset($_REQUEST[&#39;return_action&#39;]){</div><div><span style="white-space: pre-wrap;">                </span>$return_action = $_REQUEST[&#39;return_action&#39;];</div>

<div><span style="white-space: pre-wrap;">        </span>} else {</div><div><span style="white-space: pre-wrap;">                </span>$return_action = &quot;&quot;;</div><div><span style="white-space: pre-wrap;">        </span>}</div>

<div><br></div><div><span style="white-space: pre-wrap;">        </span>if ($return_action == &quot;CallRelatedList&quot; &amp;&amp; !empty($return_module) &amp;&amp; !empty($return_id)) {</div><div><span style="white-space: pre-wrap;">                </span>$focus-&gt;unlinkRelationship($record, $return_module, $return_id);</div>





<div><span style="white-space: pre-wrap;">        </span>} else {</div><div><span style="white-space: pre-wrap;">                </span>$focus-&gt;trash($module, $record);</div><div><span style="white-space: pre-wrap;">        </span>}</div>

<div><span style="white-space: pre-wrap;">        </span>$log-&gt;debug(&quot;Exiting DeleteEntity method ...&quot;);</div><div>}</div></div><div><br></div><div>What do you guys think ?</div><div><br></div><font color="#888888"><div>





David V.<br>
</div>
</font><br></div></div>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>Regards,<br>Asha<br>vtiger Team<br>
</font><br></div></div>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Asha<br>vtiger Team<br>