Hi abing and all,

I heard on the grapevine that the acl code is currently being
refactored, so some of what I write below may be obsolete before too
long.

On Jan 3, 4:09 am, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote:
<snip>

I have tried using a stack-based algorithm instead of recursion, but
surprisingly(?!?) it eats up more memory than the recursive version.
Probably because I'm storing objects (which is needed) into the stack.
I'm interested in hearing about others' experience with MPTT
implementations using both the stack-based and recursive approach.

Unless I misunderstand and you are not talking about deleting a single
(group of) nodes, moving a single (group of) nodes or creating a single
(1) node; updating MPTT tables recursively is unnecessary.

For deleting a node or group of nodes, the acl_node class already takes
care of this with a minimum of sql and affected rows.

To clarify what I mean for moving (groups of) nodes, and ignoring that
a person has 2 parents :), consider I accidentally put Uncle bob under
the wrong grandparent whilst building my family tree.
The sql that puts Bob and all of his children, grandchildren etc. in
the right place should action everthing under Uncle bob as a whole -
not each of his family members individually in a recursive manner.
Irrespective of the size of Bobs family the following sql would be
executed:

1) change the lft and rght fields for Bob and all children such that
the branch is moved out of the tree leaving a hole.
2) change the lft and rght fields of everything inbetween where Bob was
to where he needs to be such that the hole is under Bobs Parent.
3) change the lft and rght fields for Bob and all children such that
the branch is in the right place and Bob has the right parent.

There are never more than 6 sql statements to move a node or group of
nodes; and rows that don't need to change are unafected (only the rows
inbetween where Bob and his family now are and were they where are
afected).

I added to the following ticket a while ago
https://trac.cakephp.org/ticket/1234 regarding this.

The online acl admin demo allows you to move things around to test this
change if you are curious.
See
http://www.noswad.me.uk/AclAdminDemo/aros (use the Load from user table
link if no aros present) or
http://www.noswad.me.uk/AclAdminDemo/acos (create something if no acos
present and go to the data view)
and use the Move this -> form to reparent something(s).

The exact code in use for the demo, incase there are any differences
with the ticket code can be seen here:
http://www.noswad.me.uk/AclAdminDemo/acl_node (set parent method)

I have a partially finished MPTT behaviour, which was based upon the
acl_node class and has some additional functionality namely reordering
without reparenting  using the above logic (so for example, you could
if you really wanted use it to design your multi-level menu. and move
option 1.1.1.15 to position 1.1.1.7 by reordering up 8 steps). If there
are any other MPTT functions that are of interest (I can't think of
any) I'd be glad to hear of them.

Dr. Tarique Sani: I wonder if that book mentions leaving data holes
between tree nodes (akin to numbering lines as 10,20,30 in BASIC such
that you can create line 15 if you find you need to add something
without renumbering the whole file). Means that some functionality is
lost ( you can't know how many children a parent has without
specifically searching), but I can't think of any other way of handling
frequent inserts.

HTH,

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :) You may get your answer quicker by asking on
the IRC Channel (you can access it with just a browser
here:http://irc.cakephp.org).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to