ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
Action Class Reference

Public Member Functions

 tableName ()
 rules ()
 relations ()
 attributeLabels ()
 search ()

Static Public Member Functions

static translateActions ($obj, $actions)
static model ($className=__CLASS__)

Static Protected Member Functions

static translateStringActions ($actions)
static processActionOperation ($posMinus, $posPlus, $actions)
static getAllStringActions ()

Detailed Description

Definition at line 22 of file Action.php.


Member Function Documentation

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

Definition at line 195 of file Action.php.

{
return array(
'id' => 'ID',
'name' => 'Name',
'created' => 'Created',
);
}
static getAllStringActions ( )
staticprotected

Fetches all actions from the database and returns them in an indexed array

Returns:
array[string] the actinos

Definition at line 136 of file Action.php.

{
$actions = Action::model()->findAll();
$sActions = array();
foreach($actions as $action){
$sActions[] = $action->name;
}
return $sActions;
}
static model (   $className = __CLASS__)
static

Returns the static model of the specified AR class.

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

Definition at line 151 of file Action.php.

{
return parent::model($className);
}
static processActionOperation (   $posMinus,
  $posPlus,
  $actions 
)
staticprotected

Processes the next operation on the actions and returns them

Parameters:
int$posMinuspos of the next minus-symbol in the string
int$posPluspos of the next plus-symbol in the string
string$actionsthe action-string
Returns:
array[string] the actions

Definition at line 107 of file Action.php.

{
$firstPos = NULL;
if($posMinus !== false && $posPlus !== false)
$firstPos = min($posMinus, $posPlus);
elseif($posMinus === false)
$firstPos = $posPlus;
else
$firstPos = $posMinus;
$operation = $firstPos == $posMinus ? '-' : '+';
$startStr = substr($actions, 0, $firstPos);
$endStr = substr($actions, $firstPos + 1);
$startActions = static::translateStringActions($startStr);
$endActions = static::translateStringActions($endStr);
if($operation == '+'){
return array_merge($startActions, $endActions);
}
else{
return array_diff($startActions, $endActions);
}
}
relations ( )
Returns:
array relational rules.

Definition at line 184 of file Action.php.

{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
rules ( )
Returns:
array validation rules for model attributes.

Definition at line 167 of file Action.php.

{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, created', 'required'),
array('created', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>15),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, name, created', 'safe', 'on'=>'search'),
);
}
search ( )

Retrieves a list of models based on the current search/filter conditions.

Returns:
CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

Definition at line 208 of file Action.php.

{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('created',$this->created);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
tableName ( )
Returns:
string the associated database table name

Definition at line 159 of file Action.php.

{
return '{{action}}';
}
static translateActions (   $obj,
  $actions 
)
static

Translates the gibven actions into valid actions

Parameters:
AclObject$objthe object to perform the permissions on
mixed$actionsmay be a string or an array

Definition at line 30 of file Action.php.

{
if(is_string($actions))
$actions = static::translateStringActions($actions);
//Now, check if the object restricts the actions
$class = NULL;
if($obj instanceof CActiveRecord)
$class = get_class($class);
elseif($obj->model !== NULL){
$class = $obj->model;
}
if($class === NULL)
return array();
if(isset($class::$possibleActions)){
$newActions = array();
foreach($actions as $action){
if(in_array($action, $class::$possibleActions))
$newActions[] = $action;
}
$actions = $newActions;
}
return $actions;
}
static translateStringActions (   $actions)
staticprotected

Processes the given actions

Parameters:
mixed$actionsstring or array of actions

Definition at line 65 of file Action.php.

{
//Nothing more to do
if(is_array($actions))
return $actions;
//Now, it is a string
//Search the first occurence of a modificator (+ or -)
$posMinus = strpos($actions, '-');
$posPlus = strpos($actions, '+');
//If none is found, we can split it up into the actions
if($posMinus === false && $posPlus === false){
$actions = str_replace(",", " ",$actions);
$actions = explode(" ", $actions);
$completedActions = array();
foreach($actions as $action){
$action = trim($action);
if(strlen($action) > 0){
if($action == '*')
$completedActions = array_merge($completedActions, static::getAllStringActions());
else
$completedActions[] = $action;
}
}
return $completedActions;
}
else{
return static::processActionOperation($posMinus, $posPlus, $actions);
}
}

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