add role checking to controllers

This commit is contained in:
2015-11-05 17:24:09 +01:00
parent 43d5598f23
commit cc83ccf761
39 changed files with 362 additions and 78 deletions

View File

@@ -214,6 +214,7 @@ class User extends ActiveRecord implements IdentityInterface
'email' => Yii::t('backend/user', 'E-Mail'),
'created_at' => Yii::t('backend/user', 'Created at'),
'role' => Yii::t('backend/user', 'Role'),
'statusHuman' => Yii::t('backend/user', 'Status'),
];
}
@@ -239,15 +240,20 @@ class User extends ActiveRecord implements IdentityInterface
* $param int $forceIncludeAccount id warehouse, that should be included in list, even if it is inactive
* */
public static function read($forceIncludeObjectWithId = null){
$warehouses = null;
$users = null;
$query = User::find();
if ( RoleDefinition::isReception()){
$query->andWhere(['id' => Yii::$app->user->id ]);
}
if ( $forceIncludeObjectWithId == null){
$warehouses = User::find()->andWhere(['status' => User::STATUS_ACTIVE])->all();
$users = $query->andWhere(['status' => User::STATUS_ACTIVE])->all();
}else{
$warehouses = User::find()->andWhere( ['or', ['status' => User::STATUS_ACTIVE], ['id' => $forceIncludeObjectWithId ] ])->all();
$users = $query->andWhere( ['or', ['status' => User::STATUS_ACTIVE], ['id' => $forceIncludeObjectWithId ] ])->all();
}
return $warehouses;
return $users;
}
}