Yii Access Control Lists  0.8
Advanced and convenient Access Control
Public Member Functions | Protected Member Functions | Protected Attributes
Tree Class Reference

List of all members.

Public Member Functions

 __construct ($table, $type, $relatedTable= '{{aco_aro}}')
 synchronizeDenormalization ()
 moveItem ($item, $parent)
 deleteItem ($item)
 addItem ($item)

Protected Member Functions

 updatePosition ($type, $direction, $scalar, $startRgt)
 getParentRight ($parent=NULL)
 getParentLeft ($parent=NULL)
 getParentValue ($value, $parent=NULL)

Protected Attributes

 $table = NULL
 $relatedTable = NULL
 $type = NULL

Member Function Documentation

Tree::addItem ( item)

Increase all lft and rgt which are greater than the old parent rgt by 2*childrenCount + 2

Todo:
This can be done faster... do it ^^
Tree::getParentLeft ( parent = NULL) [protected]

Just a Wrapper for getParentValue getParentValue

Parameters:
int$parentthe ID of the parent to use
Returns:
boolean the left position of the given parent
Tree::getParentRight ( parent = NULL) [protected]

Just a Wrapper for getParentValue getParentValue

Parameters:
int$parentthe ID of the parent to use
Returns:
boolean the right position of the given parent
Tree::getParentValue ( value,
parent = NULL 
) [protected]

This position gathers the given value of the given parent

Parameters:
string$valuethe value to look up
int$parentthe ID of the parent. If no parent is existent, usees 0 as default value
Returns:
mixed the requested value
Tree::moveItem ( item,
parent 
)

If we don't have a parent, we have to incrase the parentRgt manually, because we don't want this parent The method getParentRight can't do this as it always returns a valid ID - we need a new one!

The new lft is the rgt of the left neighbor + 1 The rgt of the new parent - 2 * childrenCount - 2 equals this

Update the nodes right from the newly inserted node As we take newLft from the rgt-value of the parent, we can use it now

Now move the positions of all child-nodes They need to be moved by the size of the occupied area

As the last step, we move everything to the opposite direction, as there's space left ^^ As usual, do this independently

Tree::synchronizeDenormalization ( )

For the sake of performance the normal tenets have been broken. Thereupon lft and rgt-values are available in both {{aco/aro}} and {{aco_aro}} Whenever we do something complex and we don't bother to update the values on-the-fly (the tree only operates on the single table and not on the MANY-TO-MANY-relations) we just updated the hole thing

Todo:

: Keep the eyes peeled for a better solution. Though I doubt there is any.

: remove keys, process update and restore them later

Tree::updatePosition ( type,
direction,
scalar,
startRgt 
) [protected]

Updates the position of the nodes having a $type greater or equal than $startRgt in direction $direction by $scalar

Parameters:
string$typeThe type (lft or rgt or both)
int$directionthe direciton (+ or -)
int$scalarthe amount to move by
type$startRgtthe starting rgt value (note: the value is also moved)

The documentation for this class was generated from the following file:
 All Classes Functions