add role checking to controllers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user