door manager
This commit is contained in:
@@ -9,7 +9,6 @@ use backend\models\UserCreate;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use backend\models\UserUpdate;
|
||||
use common\models\Account;
|
||||
use common\models\UserAccountAssignment;
|
||||
@@ -20,7 +19,7 @@ use common\components\RoleDefinition;
|
||||
*/
|
||||
class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
@@ -45,8 +44,8 @@ class UserController extends \backend\controllers\BackendController
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all User models.
|
||||
* @return mixed
|
||||
@@ -55,8 +54,8 @@ class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
$searchModel = new UserSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
@@ -84,25 +83,25 @@ class UserController extends \backend\controllers\BackendController
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCreate();
|
||||
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
|
||||
|
||||
$this->updateAccountAssignments($model);
|
||||
|
||||
|
||||
return $this->redirect(['index' ]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function updateAccountAssignments($model){
|
||||
|
||||
|
||||
echo "saving accounts";
|
||||
UserAccountAssignment::deleteAll(['id_user' => $model->id]);
|
||||
foreach ( $model->selected_accounts as $id_account ){
|
||||
@@ -112,7 +111,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
$uaa->id_account = $id_account;
|
||||
$uaa->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +123,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = UserUpdate::findOne(['id' => $id]);
|
||||
|
||||
|
||||
if ( Yii::$app->authManager->checkAccess($model->id, 'admin')){
|
||||
$model->role = 'admin';
|
||||
} else if ( Yii::$app->authManager->checkAccess($model->id, 'employee')){
|
||||
@@ -132,16 +131,16 @@ class UserController extends \backend\controllers\BackendController
|
||||
}else if ( Yii::$app->authManager->checkAccess($model->id, 'reception')){
|
||||
$model->role = 'reception';
|
||||
}
|
||||
|
||||
|
||||
if ( $model == null ){
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
|
||||
|
||||
$this->applyAccounts($model);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
$this->updateAccountAssignments($model);
|
||||
@@ -153,7 +152,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function applyAccounts($model ){
|
||||
$assignedAccounts = $model->userAccountAssignments;
|
||||
foreach ($assignedAccounts as $acc ){
|
||||
@@ -171,12 +170,12 @@ class UserController extends \backend\controllers\BackendController
|
||||
{
|
||||
|
||||
$user = $this->findModel($id);
|
||||
|
||||
|
||||
$user->updateAttributes(['status' => User::STATUS_DELETED]);
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new User model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
@@ -185,17 +184,17 @@ class UserController extends \backend\controllers\BackendController
|
||||
public function actionRole()
|
||||
{
|
||||
$model = new \backend\models\RoleForm();
|
||||
|
||||
|
||||
$model->availablePermissions = [
|
||||
[
|
||||
'name' => "reception.transfers",
|
||||
'description' => 'Tranzakciók'
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) ) {
|
||||
if ( $model->validate() && $model->save()){
|
||||
Yii::$app->session->setFlash('success', 'Jogosultságok elmentve');
|
||||
@@ -209,7 +208,7 @@ class UserController extends \backend\controllers\BackendController
|
||||
$model->permissions[] = $child->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->render('role', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user