update phân quyền chi tiết
This commit is contained in:
29
helpers/AuthItemGrid.php
Normal file
29
helpers/AuthItemGrid.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\helpers;
|
||||
|
||||
use yii\helpers\Url;
|
||||
|
||||
class AuthItemGrid extends CommonGrid {
|
||||
|
||||
public static function checkbox($type, $haveRoot = true) {
|
||||
return function($model) use ($type, $haveRoot) {
|
||||
if ($model->name == "administrator" && $haveRoot)
|
||||
return "";
|
||||
return "<input type='checkbox' value='{$model->name}' name='checkbox-{$type}' class='checkbox-{$type}'>";
|
||||
};
|
||||
}
|
||||
|
||||
public static function rows($type, $bigSize = false) {
|
||||
return function($model, $index, $widget, $grid) use ($type, $bigSize) {
|
||||
return [
|
||||
"ondblclick" => "common.form(this, '{$type}', {$bigSize});",
|
||||
"style" => "cursor: pointer;",
|
||||
"data" => [
|
||||
"href" => Url::to(["update", "name" => $model->name])
|
||||
]
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,8 @@ class CommonGrid {
|
||||
|
||||
public static function rows($type, $bigSize = false) {
|
||||
return function($model, $index, $widget, $grid) use ($type, $bigSize) {
|
||||
if (!\Yii::$app->user->can($type . "Update"))
|
||||
return [];
|
||||
return [
|
||||
"ondblclick" => "common.form(this, '{$type}', {$bigSize});",
|
||||
"style" => "cursor: pointer;",
|
||||
|
||||
Reference in New Issue
Block a user