ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
PmAro Class Reference
Inheritance diagram for PmAro:
PmAclObject AclObject

Public Member Functions

 grant ($obj, $actions)
 deny ($obj, $actions)
 may ($obj, $actions)
 tableName ()
 rules ()
 relations ()
 attributeLabels ()
- Public Member Functions inherited from PmAclObject
 getFreeNodes ()
 getPaths ()
 fetchComprisedPositions ()
 addPositionCheck ($positions, $type, $table= 't')
 getDirectChildNodes (AclObject $child=NULL)
 getDirectParentNodes (AclObject $parent=NULL)
 beforeDelete ()
 join ($obj)
 leave ($obj)
 is ($obj)
- Public Member Functions inherited from AclObject
 getChildObjects ()
 getParentObjects ()
 loadObject ($identifier, $model=NULL)
 loadObjects ($identifier, $model=NULL, $onlyFirst=true)
 getNodes ()
 afterSave ()
 getAssociatedObject ()

Static Public Member Functions

static model ($className=__CLASS__)
- Static Public Member Functions inherited from PmAclObject
static buildTreeQueryCondition ($source, $destination, $disableInheritance=false)
- Static Public Member Functions inherited from AclObject
static loadObjectStatic ($identifier, $model)
static loadObjectsStatic ($identifier, $model=NULL, $onlyFirst=true)

Additional Inherited Members

- Protected Member Functions inherited from PmAclObject
 createNode ($parent=NULL)
- Protected Member Functions inherited from AclObject
 beforeJoin (&$obj)
 beforeLeave (&$obj)
 beforeIs (&$obj)
 assureSaved ()
 assureSafety (&$obj)

Detailed Description

Definition at line 17 of file PmAro.php.


Member Function Documentation

attributeLabels ( )
Returns:
array customized attribute labels (name=>label)

Definition at line 182 of file PmAro.php.

{
return array(
'id' => 'ID',
'alias' => 'Alias',
'model' => 'Model',
'foreign_key' => 'Foreign Key',
'created' => 'Created'
);
}
deny (   $obj,
  $actions 
)

Denies the given actions to the given object

Parameters:
mixed$objany valid identifier
mixed$actionsthe actions to deny
Returns:
type

Definition at line 74 of file PmAro.php.

{
$obj = $this->loadObject($obj, 'Aco');
$actions = Action::translateActions($obj, $actions);
$aroNodes = $this->getNodes();
$acoNodes = $obj->getNodes();
foreach($actions as $action){
$action = Action::model()->find('name = :name', array(':name' => $action));
if($action === NULL)
throw new RuntimeException('Invalid action');
//Now, delete all the rows
$suc = Permission::model()->deleteAll('aco_id '.$acoIn.' AND aro_id '.$aroIn.' AND action_id = :action_id',
array(':action_id' => $action->id));
if($suc === false)
throw new RuntimeException('Unabel to deny permission '.$action->id.' of '.$this->id.' to '.$obj->id);
}
}
grant (   $obj,
  $actions 
)

Grants the given actions to the given object

Parameters:
mixed$objany valid identifier
mixed$actionsthe actions to grant
Returns:
type

Definition at line 26 of file PmAro.php.

{
$obj = $this->loadObject($obj, 'Aco');
$actions = Action::translateActions($obj, $actions);
$aroNodes = $this->getNodes();
$acoNodes = $obj->getNodes();
foreach($actions as $action){
//First check: does that already exist?
$action = Action::model()->find('name = :name', array(':name' => $action));
if($action === NULL)
throw new RuntimeException('Invalid action');
$permission = Permission::model()->find('action_id = :action_id AND aco_id '.$acoIn.' AND aro_id '.$aroIn,
array(':action_id' => $action->id));
//Only grant if it's not yet granted
if($permission === NULL){
foreach($aroNodes as $aroNode){
foreach($acoNodes as $acoNode){
$perm = new Permission();
$perm->aro_id = $aroNode->id;
$perm->aro_path = $aroNode->getOwnPath();
$perm->aco_id = $acoNode->id;
$perm->aco_path = $acoNode->getOwnPath();
$perm->action_id = $action->id;
if(!$perm->save())
throw new RuntimeException('Unable to grant permission of '.$action->name.' from '
.$aroNode->id.' to '.$acoNode->id);
}
}
}
}
}
may (   $obj,
  $actions 
)

Checks whether the this object may perform all of the given actions on the given object

Parameters:
mixed$obj
mixed$actions
booleantrue if it may, otherwise false

Definition at line 107 of file PmAro.php.

{
$obj = $this->loadObject($obj, 'Aco');
$actions = Action::translateActions($obj, $actions);
$aroPaths = $this->getPaths();
$aroCondition = $this->addPositionCheck($aroPaths, 'aro');
$acoPaths = $obj->getPaths();
$acoCondition = $this->addPositionCheck($acoPaths, 'aco');
foreach($actions as $action){
//First fetch the action
$action = Action::model()->find('name = :name', array(':name' => $action));
if($action === NULL)
throw new RuntimeException('Invalid action');
//An action which is not possible is never allowed
if(isset($obj::$possibleActions) && !in_array($action, $possibleActions))
return false;
$perm = Permission::model()->find('action_id = :action_id AND '.$aroCondition.' AND '.$acoCondition,
array(':action_id' => $action->id));
if($perm === NULL)
return false;
}
return true;
}
static model (   $className = __CLASS__)
static

Returns the static model of the specified AR class.

Parameters:
string$classNameactive record class name.
Returns:
PM_Aco the static model class

Definition at line 142 of file PmAro.php.

{
return parent::model($className);
}
relations ( )
Returns:
array relational rules.

Definition at line 169 of file PmAro.php.

{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'aroNodes' => array(static::HAS_MANY, 'PmAroNode', 'collection_id'),
'permissions' => array(static::HAS_MANY, 'Permission', 'aro_id')
);
}
rules ( )
Returns:
array validation rules for model attributes.

Definition at line 158 of file PmAro.php.

{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
);
}
tableName ( )
Returns:
string the associated database table name

Definition at line 150 of file PmAro.php.

{
return '{{aro_collection}}';
}

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