update phân quyền chi tiết
This commit is contained in:
@@ -55,6 +55,12 @@ class AreaController extends Controller {
|
||||
public function actionCreate() {
|
||||
$model = new Area();
|
||||
Yii::$app->response->format = "json";
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Create"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$check = Area::findOne(['code' => $data['Code']]);
|
||||
@@ -81,6 +87,12 @@ class AreaController extends Controller {
|
||||
public function actionUpdate($id) {
|
||||
$model = $this->findModel($id);
|
||||
Yii::$app->response->format = "json";
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Update"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$check = Area::findOne(['code' => $data['Code']]);
|
||||
@@ -112,6 +124,12 @@ class AreaController extends Controller {
|
||||
}
|
||||
|
||||
public function actionDelete() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Delete"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$lists = Yii::$app->request->post("lists");
|
||||
foreach ($lists as $key => $value) {
|
||||
@@ -129,6 +147,9 @@ class AreaController extends Controller {
|
||||
}
|
||||
|
||||
public function actionExport() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Export"))
|
||||
throw new \yii\web\HttpException(403, 'Bạn không có quyền truy cập nội dung này');
|
||||
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$toExcelFile[] = ["Mã khu vực", "Tên khu vực", "khu vực cha", "Chú thích"];
|
||||
|
||||
Reference in New Issue
Block a user