ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
RestrictedTreeActiveRecord Class Reference
Inheritance diagram for RestrictedTreeActiveRecord:
RestrictedActiveRecord

Public Member Functions

 afterFind ()
 afterSave ()
- Public Member Functions inherited from RestrictedActiveRecord
 find ($conditions= '', $params=array())
 findByAttributes ($attributes, $conditions= '', $params=array())
 findByPk ($pk, $conditions= '', $params=array())
 findBySQL ($sql, $params=array())
 findAll ($conditions= '', $params=array())
 findAllByAttributes ($attributes, $conditions= '', $params=array())
 findAllByPk ($pk, $conditions= '', $params=array())
 findAllBySQL ($sql, $params=array())
 getDirectlyPermitted ($actions= '*')
 beforeSave ()
 beforeDelete ()
 grants ($permission)

Protected Attributes

 $oldParentId = NULL

Additional Inherited Members

- Static Public Member Functions inherited from RestrictedActiveRecord
static getUser ()
- Static Public Attributes inherited from RestrictedActiveRecord
static $byPassCheck = false
static $inAttendance = NULL
static $model = 'User'
static $possibleActions = NULL
static $defaultOptions
- Protected Member Functions inherited from RestrictedActiveRecord
 generateAccessCheck ($conditions= '', $params=array(), $options=array())

Detailed Description

Definition at line 12 of file RestrictedTreeActiveRecord.php.


Member Function Documentation

afterFind ( )

Definition at line 20 of file RestrictedTreeActiveRecord.php.

{
$this->oldParentId = $this->parent_id;
return true;
}
afterSave ( )

If the parent has changed, adjust the permissions

Exceptions:
RuntimeException

Reimplemented from RestrictedActiveRecord.

Definition at line 31 of file RestrictedTreeActiveRecord.php.

{
//If the Owner has changed - quit old parent in permission system and move to new!
if ($this->oldParentId != $this->parent_id) {
$acoClass = new CGroup();
//First: find the aco-Object of yourself
$aco = $acoClass->loadObject($this);
if($aco === NULL)
throw new RuntimeException('Aco-object does not exist');
//If we moved to another parent and we had an old one
if($this->oldParentId !== NULL){
if (!$aco->leave(array('model' => get_class($this), 'foreign_key' => $this->oldParentId)))
throw new RuntimeException('Unable to leave old parent-aco-object');
}
//Only choose a new parent if we have a new one - we don't necessarily have one :)
if($this->parent_id !== NULL){
$aco2 = $acoClass->loadObject(
array('model' => get_class($this), 'foreign_key' => $this->parent_id));
if (!$aco->join($aco2))
throw new RuntimeException('Unable to choose new parent-aco');
}
//In the end, save the change
$this->oldParentId = $this->parent_id;
}
return true;
}

Field Documentation

$oldParentId = NULL
protected

Definition at line 18 of file RestrictedTreeActiveRecord.php.


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