[ 'class' => VerbFilter::className(), 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return User::hasAccessBackend(); } ], ], ], ]; } /** * Liste les points de vente. * * @return mixed */ public function actionIndex() { $searchModel = new UserGroupSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } /** * Crée un groupe d'utilisateur. * * @return mixed */ public function actionCreate() { $model = new UserGroup(); $model->id_producer = GlobalParam::getCurrentProducerId() ; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', "Groupe d'utilisateur ajouté."); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } /** * Modifie un groupe d'utilisateur. * * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', "Groupe d'utilisateur modifié."); return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Supprime un groupe d'utilisateur. * * @param integer $id * @return mixed */ public function actionDelete($id) { $userGroup = $this->findModel($id); $userGroup->delete(); UserUserGroup::deleteAll(['id_user_group' => $id]); Yii::$app->getSession()->setFlash('success', 'Groupe d\'utilisateur ' . Html::encode($userGroup->name) . ' supprimé.'); return $this->redirect(['index']); } /** * Recherche un groupe d'utilisateur en fonction de son ID. * * @param integer $id * @return UserGroup * @throws NotFoundHttpException si le modèle n'est pas trouvé */ protected function findModel($id) { if (($model = UserGroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }