[ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserModule() ->getAuthorizationChecker() ->isGrantedAsAdministrator($this->getUserCurrent()); } ] ], ], ]; } /** * Liste les utilisateurs. */ public function actionIndex() { $searchModel = new UserSearch(); $dataProvider = $searchModel->search([ 'UserSearch' => isset(\Yii::$app->request->queryParams['UserSearch']) ? Yii::$app->request->queryParams['UserSearch'] : [] ]); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider ]); } public function actionEmailDeliverability() { $searchModel = new UserSearch(); $searchModel->problem_receiving_emails = true; $dataProvider = $searchModel->search([ 'UserSearch' => isset(\Yii::$app->request->queryParams['UserSearch']) ? Yii::$app->request->queryParams['UserSearch'] : [] ]); return $this->render('email_deliverability', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider ]); } public function actionReportProblemReceivingEmails(int $id) { $user = $this->findModel($id); if($this->getUserModule()->getManager()->reportProblemReceivingEmails($user)) { $this->setFlash('success', "L'utilisateur ".$this->getUserModule()->getSolver()->getUsername($user)." a bien été signalé comme ayant des problèmes dans la réception de vos emails. L'administrateur débloquera la situation dès que possible et préviendra l'utilisateur."); } else { $this->setFlash('error', "Une erreur est survenue."); } return $this->redirect('index'); } public function actionRedirectUpdate(int $idUserProducer) { $userCurrent = $this->getUserCurrent(); $userProducer = $this->getUserProducerModule()->getRepository()->findOneUserProducerById($idUserProducer); if($userProducer) { $user = $userProducer->user; $producer = $userProducer->producer; $this->getUserModule()->getBuilder()->switchProducer($userCurrent, $producer); return $this->redirect(['user/update', 'id' => $user->id]); } else { $this->addFlash('error', "L'utilisateur n'a pas été trouvé."); return $this->redirectReferer(); } } protected function findModel($id) { if (($user = $this->getUserModule()->findOneUserById($id)) !== null) { return $user; } else { throw new NotFoundHttpException("Utilisateur introuvable"); } } }