Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RightsFilter Class Reference

Public Member Functions

 setAllowedActions ($allowedActions)

Protected Member Functions

 preFilter ($filterChain)

Protected Attributes

 $_allowedActions = array()

Detailed Description

Rights filter class file.

Author
Christoffer Niska cnisk.nosp@m.a@li.nosp@m.ve.co.nosp@m.m
Since
0.7

Definition at line 9 of file RightsFilter.php.

Member Function Documentation

RightsFilter::preFilter (   $filterChain)
protected

Performs the pre-action filtering.

Parameters
CFilterChain$filterChainthe filter chain that the filter is on.
Returns
boolean whether the filtering process should continue and the action should be executed.

Definition at line 19 of file RightsFilter.php.

{
// By default we assume that the user is allowed access
$allow = true;
$user = Yii::app()->getUser();
$controller = $filterChain->controller;
$action = $filterChain->action;
// Check if the action should be allowed
if( $this->_allowedActions!=='*' && in_array($action->id, $this->_allowedActions)===false )
{
// Initialize the authorization item as an empty string
$authItem = '';
// Append the module id to the authorization item name
// in case the controller called belongs to a module
if( ($module = $controller->getModule())!==null )
$authItem .= ucfirst($module->id).'.';
// Append the controller id to the authorization item name
$authItem .= ucfirst($controller->id);
// Check if user has access to the controller
if( $user->checkAccess($authItem.'.*')!==true )
{
// Append the action id to the authorization item name
$authItem .= '.'.ucfirst($action->id);
// Check if the user has access to the controller action
if( $user->checkAccess($authItem)!==true )
$allow = false;
}
}
// User is not allowed access, deny access
if( $allow===false )
{
$controller->accessDenied();
return false;
}
// Authorization item did not exist or the user had access, allow access
return true;
}
RightsFilter::setAllowedActions (   $allowedActions)

Sets the allowed actions.

Parameters
string$allowedActionsthe actions that are always allowed separated by commas, you may also use star (*) to represent all actions.

Definition at line 70 of file RightsFilter.php.

{
if( $allowedActions==='*' )
$this->_allowedActions = $allowedActions;
else
$this->_allowedActions = preg_split('/[\s,]+/', $allowedActions, -1, PREG_SPLIT_NO_EMPTY);
}

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