[Vtigercrm-developers] Record restriction based on reports_to field.

Adam Heinz amh at metricwise.net
Tue Apr 30 16:08:58 UTC 2013


Users always find a way to get bad data into the system.  ;)  I have added
a ton of referential integrity to our fork of vtiger and crap still makes
it in periodically.

Check out this tutorial [3] on tail recursion and accumulators.  Basically
you'll just accumulate an array of userids and use in_array to make sure
that you don't process the same userid twice.  PHP doesn't optimize for
tail recursion, so I would recommend writing it as a loop inside a function.

[3] http://siddhi.blogspot.com/2006/04/recursion-part-2-tail-recursion.html


On Tue, Apr 30, 2013 at 11:40 AM, salim <salimcmd at gmail.com> wrote:

> Adam,
>     You saying that make two users to report to each other, like  *UserA *--->
> *UserB* , *UserB ---> UserA*. Will it happen in real scenario?
> If so this will happen http://pastebin.com/jrFmBnxS. It dropped in a
> infinite loop.  :P
>
> How you proposing accumulator in Recursive function.
>
> Thanks
> --
> Salim
>
>
> On 30 April 2013 20:14, Adam Heinz <amh at metricwise.net> wrote:
>
>> Ooooooh, reverse that again, it could be cyclic, even though that would
>> make so sense, the system does not enforce it.  Definitely need the
>> accumulator to avoid an infinite loop.  Set two users to report to each
>> other and see if it explodes.  ;)
>>
>>
>> On Tue, Apr 30, 2013 at 10:14 AM, Adam Heinz <amh at metricwise.net> wrote:
>>
>>> On Tue, Apr 30, 2013 at 10:12 AM, Adam Heinz <amh at metricwise.net> wrote:
>>>
>>>> You should add some sort of accumulator to getReportingUsers so that
>>>> you don't recur for userids you have already checked.
>>>>
>>>
>>> Scratch this comment, we're walking a directed acyclic graph; redundancy
>>> is impossible.
>>>
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
>
> --
> Muhammed Abdul Salim
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20130430/02057e82/attachment.html>


More information about the vtigercrm-developers mailing list