[ 'class' => VerbFilter::className(), 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return User::hasAccessBackend(); } ] ], ], ]; } /** * Affiche les utilisateurs ayant accès à l'administration de ce producteur. * Gestion du formulaire permettant d'en ajouter de nouveaux. * * @return string */ public function actionIndex() { $userSearch = new UserSearch ; $usersArray = $userSearch->search()->query->all() ; $modelAccessUserProducerForm = new AccessUserProducerForm ; if($modelAccessUserProducerForm->load(Yii::$app->request->post()) && $modelAccessUserProducerForm->save()) { Yii::$app->getSession()->setFlash('success', 'Droits ajoutés à l\'utilisateur'); } $usersAccessArray = User::find() ->where([ 'id_producer' => GlobalParam::getCurrentProducerId(), 'status' => User::STATUS_PRODUCER ]) ->all() ; $producer = Producer::searchOne() ; return $this->render('index', [ 'usersArray' => $usersArray, 'usersAccessArray' => $usersAccessArray, 'producer' => $producer, 'modelAccessUserProducerForm' => $modelAccessUserProducerForm, ]); } /** * */ public function actionDelete($idUser) { $user = User::searchOne([ 'id' => $idUser ]) ; if($user) { $user->id_producer = 0 ; $user->status = User::STATUS_ACTIVE ; $user->save() ; Yii::$app->getSession()->setFlash('success', 'Droits de l\'utilisateur supprimé.'); } return $this->redirect(['index']) ; } }