update phân quyền chi tiết

This commit is contained in:
2020-11-02 14:35:22 +07:00
parent c4bb81e55c
commit e4a665dd2e
29 changed files with 1188 additions and 343 deletions

29
helpers/AuthItemGrid.php Normal file
View 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])
]
];
};
}
}

View File

@@ -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;",