Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
AssignmentController Class Reference
Inheritance diagram for AssignmentController:
RController

Public Member Functions

 init ()
 filters ()
 accessRules ()
 actionView ()
 actionUser ()
 actionRevoke ()
 getItemName ()
- Public Member Functions inherited from RController
 filterAccessControl ($filterChain)
 filterRights ($filterChain)
 allowedActions ()
 accessDenied ($message=null)

Public Attributes

 $invoker
- Public Attributes inherited from RController
 $layout = '//layouts/column1'
 $menu = array()
 $breadcrumbs = array()

Detailed Description

Rights assignment controller class file.

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

Definition at line 9 of file AssignmentController.php.

Member Function Documentation

AssignmentController::accessRules ( )

Specifies the access control rules. This method is used by the 'accessControl' filter.

Returns
array access control rules

Definition at line 49 of file AssignmentController.php.

{
return array(
array('allow', // Allow superusers to access Rights
'actions'=>array(
'view',
'user',
'revoke',
),
'users'=>$this->_authorizer->getSuperusers(),
),
array('deny', // Deny all users
'users'=>array('*'),
),
);
}
AssignmentController::actionRevoke ( )

Revokes an assignment from an user.

Definition at line 148 of file AssignmentController.php.

References getItemName(), and Rights\t().

{
// We only allow deletion via POST request
if( Yii::app()->request->isPostRequest===true )
{
$itemName = $this->getItemName();
// Revoke the item from the user and load it
$this->_authorizer->authManager->revoke($itemName, $_GET['id']);
$item = $this->_authorizer->authManager->getAuthItem($itemName);
$item = $this->_authorizer->attachAuthItemBehavior($item);
// Set flash message for revoking the item
Yii::app()->user->setFlash($this->module->flashSuccessKey,
Rights::t('core', 'Permission :name revoked.', array(':name'=>$item->getNameText()))
);
// if AJAX request, we should not redirect the browser
if( isset($_POST['ajax'])===false )
$this->redirect(array(!$this->invoker ? 'assignment/user' : "/{$this->invoker->module->id}/assignment/user", 'id'=>$_GET['id']));
}
else
{
throw new CHttpException(400, Rights::t('core', 'Invalid request. Please do not repeat this request again.'));
}
}
AssignmentController::actionUser ( )

Displays the authorization assignments for an user.

Definition at line 87 of file AssignmentController.php.

References Rights\getAuthItemSelectOptions(), and Rights\t().

{
// Create the user model and attach the required behavior
$userClass = $this->module->userClass;
$model = CActiveRecord::model($userClass)->findByPk($_GET['id']);
$this->_authorizer->attachUserBehavior($model);
$assignedItems = $this->_authorizer->getAuthItems(null, $model->getId());
$assignments = array_keys($assignedItems);
// Make sure we have items to be selected
$assignSelectOptions = Rights::getAuthItemSelectOptions(null, $assignments);
if( $assignSelectOptions!==array() )
{
$formModel = new AssignmentForm();
// Form is submitted and data is valid, redirect the user
if( isset($_POST['AssignmentForm'])===true )
{
$formModel->attributes = $_POST['AssignmentForm'];
if( $formModel->validate()===true )
{
// Update and redirect
$this->_authorizer->authManager->assign($formModel->itemname, $model->getId());
$item = $this->_authorizer->authManager->getAuthItem($formModel->itemname);
$item = $this->_authorizer->attachAuthItemBehavior($item);
Yii::app()->user->setFlash($this->module->flashSuccessKey,
Rights::t('core', 'Permission :name assigned.', array(':name'=>$item->getNameText()))
);
$this->redirect(
array( !$this->invoker ? 'assignment/user' : "/{$this->invoker->module->id}/assignment/user", 'id'=>$model->getId())
);
}
}
}
// No items available
else
{
$formModel = null;
}
// Create a data provider for listing the assignments
$dataProvider = new RAuthItemDataProvider('assignments', array(
'userId'=>$model->getId(),
));
// Render the view
$this->render('user', array(
'model'=>$model,
'dataProvider'=>$dataProvider,
'formModel'=>$formModel,
'assignSelectOptions'=>$assignSelectOptions,
));
}
AssignmentController::actionView ( )

Displays an overview of the users and their assignments.

Definition at line 69 of file AssignmentController.php.

{
// Create a data provider for listing the users
$dataProvider = new RAssignmentDataProvider(array(
'pagination'=>array(
'pageSize'=>10,
),
));
// Render the view
$this->render('view', array(
'dataProvider'=>$dataProvider,
));
}
AssignmentController::filters ( )
Returns
array action filters

Definition at line 39 of file AssignmentController.php.

{
return array('accessControl');
}
AssignmentController::getItemName ( )
Returns
string the item name or null if not set.

Definition at line 178 of file AssignmentController.php.

Referenced by actionRevoke().

{
return isset($_GET['name'])===true ? urldecode($_GET['name']) : null;
}
AssignmentController::init ( )

Initializes the controller.

Definition at line 26 of file AssignmentController.php.

{
$this->_authorizer = $this->module->getAuthorizer();
$this->layout = $this->module->layout;
$this->defaultAction = 'view';
// Register the scripts
$this->module->registerScripts();
}

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