[Vtigercrm-developers] Oups ! Delete instead of Unlink

Asha asha at vtiger.com
Thu Jan 27 18:07:12 PST 2011


David,

We haven't created a trac ticket yet. You can go ahead and report the issue
on trac.

On Thu, Jan 27, 2011 at 9:13 PM, David V. <davidv.net at gmail.com> wrote:

> Asha,
>
> Should I open a ticket on Trac or have you done it already ?
>
> David V.
>
>
> 2011/1/27 Asha <asha at vtiger.com>
>
>> Hi David,
>>
>>
>> Thanks for pointing out to the loop hole in the code base. We shall think
>> and come up with a better solution to it.
>>
>> 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.
>>
>> But I understand the special case when module is related to itself through
>> mxn relationship, needs to be handled here.
>>
>> On Thu, Jan 27, 2011 at 5:49 PM, David V. <davidv.net at gmail.com> wrote:
>>
>>> Hi !
>>>
>>> I have a crm installation where the module Accounts is related to itself
>>> by a related list.
>>>
>>> It works very well and it's easy to manage a list of accounts related to
>>> any specific account.
>>>
>>> The problem is when we want to remove an account Z from the RelatedList
>>> of account A.
>>>
>>> Instead of just unlinking the account Z, Vtiger sends it to trash
>>> (deletes it).
>>>
>>> This is caused by the function DeleteEntity in /include/utils/Utils.php
>>>
>>>
>>> function DeleteEntity($module,$return_module,$focus,$record,$return_id) {
>>> global $log;
>>>  $log->debug("Entering DeleteEntity method ($module, $return_module,
>>> $record, $return_id)");
>>>  if ($module != $return_module && !empty($return_module) &&
>>> !empty($return_id)) {
>>> $focus->unlinkRelationship($record, $return_module, $return_id);
>>>  } else {
>>> $focus->trash($module, $record);
>>> }
>>>  $log->debug("Exiting DeleteEntity method ...");
>>> }
>>>
>>> It is a smart function but since $module == $return_module in our case,
>>> this function does not "unlinkRelationship" but Trashes the $record.
>>>
>>> So far I'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'll have to do it every time a new version of Vtiger is released.
>>>
>>> My question :
>>> Is there any specific reason to have this test here ( $module !=
>>> $return_module ) ?
>>>
>>> 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)
>>>
>>> I have another suggestion :
>>> We could test instead $_REQUEST['return_action'], if it contains
>>> "CallRelatedList" then we are in a RelatedList and we can unlink instead of
>>> sending to trash.
>>>
>>> Here is my modified function :
>>>
>>> function DeleteEntity($module,$return_module,$focus,$record,$return_id) {
>>> global $log;
>>>  $log->debug("Entering DeleteEntity method ($module, $return_module,
>>> $record, $return_id)");
>>>  if (isset($_REQUEST['return_action']){
>>> $return_action = $_REQUEST['return_action'];
>>>  } else {
>>> $return_action = "";
>>> }
>>>
>>> if ($return_action == "CallRelatedList" && !empty($return_module) &&
>>> !empty($return_id)) {
>>> $focus->unlinkRelationship($record, $return_module, $return_id);
>>>  } else {
>>> $focus->trash($module, $record);
>>> }
>>>  $log->debug("Exiting DeleteEntity method ...");
>>> }
>>>
>>> What do you guys think ?
>>>
>>> David V.
>>>
>>> _______________________________________________
>>> http://www.vtiger.com/
>>>
>>
>>
>>
>> --
>> Regards,
>> Asha
>> vtiger Team
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 
Regards,
Asha
vtiger Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20110128/84e02851/attachment-0002.html 


More information about the vtigercrm-developers mailing list