update phân quyền chi tiết
This commit is contained in:
@@ -62,6 +62,12 @@ class DeviceController extends Controller {
|
||||
public function actionCreate() {
|
||||
$model = new Device();
|
||||
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 = Device::findOne(['ip_address' => $data['Ip']]);
|
||||
@@ -119,6 +125,12 @@ class DeviceController 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();
|
||||
$model->name = $data["Name"];
|
||||
@@ -142,6 +154,12 @@ class DeviceController 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) {
|
||||
@@ -166,6 +184,9 @@ class DeviceController 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[] = ["Tên thiết bị", "Serial", "Địa chỉ IP", "Loại thiết bị", "Khu vực"];
|
||||
@@ -239,6 +260,12 @@ class DeviceController extends Controller {
|
||||
public function actionChangeIp($id) {
|
||||
$model = $this->findModel($id);
|
||||
Yii::$app->response->format = "json";
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "ChangeIP"))
|
||||
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();
|
||||
$OldIpAddress = $model->ip_address;
|
||||
@@ -275,6 +302,9 @@ class DeviceController extends Controller {
|
||||
}
|
||||
|
||||
public function actionSearch() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Search"))
|
||||
throw new \yii\web\HttpException(403, 'Bạn không có quyền truy cập nội dung này');
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$data = Yii::$app->request->post();
|
||||
|
||||
Reference in New Issue
Block a user