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

@@ -6,6 +6,7 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Account;
use common\components\RoleDefinition;
/**
* AccountSearch represents the model behind the search form about `common\models\Account`.
@@ -43,6 +44,12 @@ class AccountSearch extends Account
{
$query = Account::find();
if ( !RoleDefinition::isAdmin() ){
$query->innerJoin("user_account_assignment",'account.id_account = user_account_assignment.id_account' );
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);