Add BackendController/AccesControl
Add the BackendController for all the backend controllers. Add AccesControl
This commit is contained in:
parent
1ee0a6bbe9
commit
ed1e0b6c2a
@ -29,43 +29,42 @@ class AdminMenuStructure{
|
||||
|
||||
$userMainMenu = null;
|
||||
$items = [];
|
||||
|
||||
//$today = \Yii::$app->formatter->asDate( time() );
|
||||
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
|
||||
$tomorrow = \Yii::$app->formatter->asDate( ( 60 *60 *24 + time()));
|
||||
|
||||
// if ( $this->can('backend.user.index')){
|
||||
$items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']];
|
||||
// }
|
||||
|
||||
$items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']];
|
||||
$items[] = ['label' => 'Kasszák', 'url' =>['/account/index']];
|
||||
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
||||
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
||||
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
|
||||
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
||||
$items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
|
||||
|
||||
|
||||
|
||||
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ];
|
||||
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
||||
|
||||
if ( count($items) > 0 ){
|
||||
$userMainMenu = ['label' => 'Beállítások', 'url' => null,
|
||||
'items' => $items
|
||||
];
|
||||
//$today = \Yii::$app->formatter->asDate( time() );
|
||||
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
|
||||
$tomorrow = \Yii::$app->formatter->asDate( ( 60 *60 *24 + time()));
|
||||
|
||||
// if ( $this->can('backend.user.index')){
|
||||
$items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']];
|
||||
// }
|
||||
|
||||
$items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']];
|
||||
$items[] = ['label' => 'Kasszák', 'url' =>['/account/index']];
|
||||
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
||||
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
||||
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
|
||||
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
||||
$items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
|
||||
|
||||
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ];
|
||||
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
||||
|
||||
if ( count($items) > 0 ){
|
||||
$userMainMenu = ['label' => 'Beállítások', 'url' => null,
|
||||
'items' => $items
|
||||
];
|
||||
}
|
||||
|
||||
if ( isset($userMainMenu)){
|
||||
$this->menuItems[] = $userMainMenu;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($userMainMenu)){
|
||||
$this->menuItems[] = $userMainMenu;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -12,31 +12,8 @@ use yii\filters\VerbFilter;
|
||||
/**
|
||||
* AccountController implements the CRUD actions for Account model.
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
class AccountController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Account models.
|
||||
@ -102,18 +79,6 @@ class AccountController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Account model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
// public function actionDelete($id)
|
||||
// {
|
||||
// $this->findModel($id)->delete();
|
||||
|
||||
// return $this->redirect(['index']);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Finds the Account model based on its primary key value.
|
||||
|
||||
@ -14,19 +14,8 @@ use common\models\User;
|
||||
/**
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
*/
|
||||
class AccountStateController extends Controller
|
||||
class AccountStateController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all AccountState models.
|
||||
@ -104,13 +93,13 @@ class AccountStateController extends Controller
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Finds the AccountState model based on its primary key value.
|
||||
|
||||
40
backend/controllers/BackendController.php
Normal file
40
backend/controllers/BackendController.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\City;
|
||||
use backend\models\CitySearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\helpers\Json;
|
||||
|
||||
/**
|
||||
* CityController implements the CRUD actions for City model.
|
||||
*/
|
||||
class BackendController extends Controller
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => ['create','index','view','update'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -16,19 +16,26 @@ use yii\helpers\Json;
|
||||
/**
|
||||
* CardController implements the CRUD actions for Card model.
|
||||
*/
|
||||
class CardController extends Controller
|
||||
class CardController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => ['create','index','view','update','list'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Card models.
|
||||
|
||||
@ -15,19 +15,26 @@ use yii\helpers\Json;
|
||||
/**
|
||||
* CityController implements the CRUD actions for City model.
|
||||
*/
|
||||
class CityController extends Controller
|
||||
class CityController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => [ 'create','index','view','update','name-list','zip-list'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all City models.
|
||||
|
||||
@ -12,19 +12,8 @@ use yii\filters\VerbFilter;
|
||||
/**
|
||||
* CurrencyController implements the CRUD actions for Currency model.
|
||||
*/
|
||||
class CurrencyController extends Controller
|
||||
class CurrencyController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Currency models.
|
||||
|
||||
@ -15,19 +15,8 @@ use backend\models\CustomerUpdate;
|
||||
/**
|
||||
* CustomerController implements the CRUD actions for Customer model.
|
||||
*/
|
||||
class CustomerController extends Controller
|
||||
class CustomerController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Customer models.
|
||||
@ -105,7 +94,6 @@ class CustomerController extends Controller
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
@ -113,6 +101,7 @@ class CustomerController extends Controller
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Finds the Customer model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
|
||||
@ -12,31 +12,8 @@ use yii\filters\VerbFilter;
|
||||
/**
|
||||
* DiscountController implements the CRUD actions for Discount model.
|
||||
*/
|
||||
class DiscountController extends Controller
|
||||
class DiscountController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Discount models.
|
||||
|
||||
@ -15,32 +15,29 @@ use common\models\User;
|
||||
/**
|
||||
* ProcurementController implements the CRUD actions for Procurement model.
|
||||
*/
|
||||
class ProcurementController extends Controller
|
||||
class ProcurementController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => ['create','index','view', 'create-product'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Procurement models.
|
||||
* @return mixed
|
||||
|
||||
@ -12,32 +12,8 @@ use yii\filters\VerbFilter;
|
||||
/**
|
||||
* ProductCategoryController implements the CRUD actions for ProductCategory model.
|
||||
*/
|
||||
class ProductCategoryController extends Controller
|
||||
class ProductCategoryController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all ProductCategory models.
|
||||
|
||||
@ -14,31 +14,8 @@ use common\models\ProductCategory;
|
||||
/**
|
||||
* ProductController implements the CRUD actions for Product model.
|
||||
*/
|
||||
class ProductController extends Controller
|
||||
class ProductController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -15,19 +15,8 @@ use common\models\Account;
|
||||
/**
|
||||
* TicketController implements the CRUD actions for Ticket model.
|
||||
*/
|
||||
class TicketController extends Controller
|
||||
class TicketController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Ticket models.
|
||||
|
||||
@ -13,31 +13,8 @@ use common\models\Account;
|
||||
/**
|
||||
* TicketTypeController implements the CRUD actions for TicketType model.
|
||||
*/
|
||||
class TicketTypeController extends Controller
|
||||
class TicketTypeController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index','view','create','update'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all TicketType models.
|
||||
|
||||
@ -14,19 +14,26 @@ use common\models\User;
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
*/
|
||||
class TransferController extends Controller
|
||||
class TransferController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => [ 'index','view' ],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
@ -71,7 +78,6 @@ class TransferController extends Controller
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
@ -85,6 +91,7 @@ class TransferController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Finds the Transfer model based on its primary key value.
|
||||
|
||||
@ -17,32 +17,9 @@ use common\models\UserAccountAssignment;
|
||||
/**
|
||||
* UserController implements the CRUD actions for User model.
|
||||
*/
|
||||
class UserController extends Controller
|
||||
class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'index', 'create','update','view'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all User models.
|
||||
|
||||
@ -13,31 +13,8 @@ use yii\base\Object;
|
||||
/**
|
||||
* WarehouseController implements the CRUD actions for Warehouse model.
|
||||
*/
|
||||
class WarehouseController extends Controller
|
||||
class WarehouseController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'create','update','view','index'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Warehouse models.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user