我的角色视图代码是
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'template'=>'{items}',
'emptyText'=>Rights::t('core', 'No roles found.'),
'htmlOptions'=>array('class'=>'grid-view role-table'),
'itemsCssClass'=>'table table-striped',
'columns'=>array(
array(
'name'=>'name',
'header'=>Rights::t('core', 'Name'),
'type'=>'raw',
'htmlOptions'=>array('class'=>'name-column'),
'value'=>'$data->getGridNameLink()',
),
array(
'name'=>'description',
'header'=>Rights::t('core', 'Description'),
'type'=>'raw',
'htmlOptions'=>array('class'=>'description-column'),
),
/*
array(
'name'=>'bizRule',
'header'=>Rights::t('core', 'Business rule'),
'type'=>'raw',
'htmlOptions'=>array('class'=>'bizrule-column'),
'visible'=>Rights::module()->enableBizRule===true,
),
array(
'name'=>'data',
'header'=>Rights::t('core', 'Data'),
'type'=>'raw',
'htmlOptions'=>array('class'=>'data-column'),
'visible'=>Rights::module()->enableBizRuleData===true,
),
*/
array(
'header'=>' ',
'type'=>'raw',
'htmlOptions'=>array('class'=>'actions-column'),
'value'=>'$data->getDeleteRoleLink()',
),
)
)); ?>
权/控制器/ authItemController
/**
* Deletes an operation.
*/
public function actionDelete()
{
// We only allow deletion via POST request
if( Yii::app()->request->isPostRequest===true )
{
$itemName = $this->getItemName();
// Load the item and save the name for later use
$item = $this->_authorizer->authManager->getAuthItem($itemName);
$item = $this->_authorizer->attachAuthItemBehavior($item);
// Delete the item
$this->_authorizer->authManager->removeAuthItem($itemName);
// Delete the from Custom Table Start //
AnuRights::removeUserRole($itemName);
// Delete the from Custom Table Start //
// Set a flash message for deleting the item
Yii::app()->user->setFlash($this->module->flashSuccessKey,
Rights::t('core', ':name deleted.', array(':name'=>$item->getNameText()))
);
// If AJAX request, we should not redirect the browser
if( isset($_POST['ajax'])===false )
$this->redirect(Yii::app()->user->getRightsReturnUrl(array('authItem/permissions')));
}
else
{
throw new CHttpException(400, Rights::t('core', 'Invalid request. Please do not repeat this request again.'));
}
}
右/组件/行为/ Rauthitembehaviour
/**
* Returns the markup for the delete role link.
* @return string the markup.
*/
public function getDeleteRoleLink()
{
// We do not want to show the delete link for the superuser role.
if( $this->owner->name!==Rights::module()->superuserName )
{
return CHtml::linkButton(Rights::t('core', 'Delete'), array(
'submit'=>array('authItem/delete', 'name'=>urlencode($this->owner->name)),
'confirm'=>Rights::t('core', 'Are you sure you want to delete this role?'),
'class'=>'delete-link',
'csrf'=>Yii::app()->request->enableCsrfValidation,
));
}
}
即时通讯使用此yii版权模块https://github.com/schmunk42/yii-rights
如果我点击删除按钮则显示错误
TypeError: jQuery.yii is undefined
...nt to delete this role?')) {jQuery.yii.submitForm(this,'/index.php/rights/authIt...