本文整理汇总了PHP中common\models\User::isAllowed方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isAllowed方法的具体用法?PHP User::isAllowed怎么用?PHP User::isAllowed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::isAllowed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
/**
* Deletes an existing Gruppo model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
if (!User::isAllowed($model)) {
return $this->render('/site/error', ['name' => 'Access Denied', 'message' => "You don't have request privileges to delete this group."]);
}
$model->delete();
return $this->redirect(['index']);
}
示例2: beforeAction
public function beforeAction($action)
{
$parentAllowed = parent::beforeAction($action);
if ($action->id == 'update' || $action->id == 'delete') {
$model = $this->findModel($_GET['id']);
if (!User::isAllowed($model)) {
throw new HttpException(403, "You don't have request privileges to {$action->id} this contact.");
}
}
return $parentAllowed;
}