ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
AclNode.php
Go to the documentation of this file.
1 <?php
2 
11 abstract class AclNode extends CActiveRecord{
16  public function afterSave(){
18  if($this->isNewRecord){
19  //First, find a random node of the same object
20  $node = $this::model()->find('collection_id = :col_id AND id != :id',
21  array(':col_id' => $this->collection_id, ':id' => $this->id));
22 
23  //If there exists a node... otherwise we don't have to overtake anything
24  if($node !== NULL){
25  //Take over permissions of the the node
26  $this->takeOverPermissions($node);
27  $this->takeOverSubTree($node);
28  }
29  }
30  }
31 
35  public function afterDelete(){
37 
38  //First of all: delete all child-nodes and permissions
39  $this->removeFullRecursively();
40  }
41 
46  abstract protected function removeFullRecursively();
47 
53  abstract protected function takeOverPermissions($node);
54 
60  protected function takeOverSubTree(PmAclNode $node){
61  $this->branchNodeSubTree($node, $this);
62  }
63 
81  abstract public function branchNodeSubTree( $source, $destination);
82 
87  abstract protected function generateDirectChildrenCondition();
88 
93  abstract protected function generateDirectParentCondition();
94 
101  public function getDirectChildren(){
102  list($condition, $params) = $this->generateDirectChildrenCondition();
103  return $this->findAll($condition, $params);
104  }
105 
113  public function getDirectParents(){
114  list($condition, $params) = $this->generateDirectParentCondition();
115  return $this->findAll($condition, $params);
116  }
117 
118  abstract public function __clone();
119 }
120 
121 ?>