|
|
@@ -75,25 +75,28 @@ class AccessController extends BackendController |
|
|
|
/** |
|
|
|
* 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() |
|
|
|
{ |
|
|
|
$userManager = $this->getUserManager(); |
|
|
|
$producer = $this->getProducerCurrent(); |
|
|
|
$userSearch = new UserSearch(); |
|
|
|
$usersArray = $userSearch->search()->query->all(); |
|
|
|
|
|
|
|
$modelAccessUserProducerForm = new AccessUserProducerForm; |
|
|
|
if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->save()) { |
|
|
|
$this->setFlash('success', 'Droits ajoutés à l\'utilisateur'); |
|
|
|
if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->validate()) { |
|
|
|
$user = $userManager->findOneUserById($modelAccessUserProducerForm->id_user); |
|
|
|
if($user && $userManager->grantAccess($user)) { |
|
|
|
$this->setFlash('success', 'Droits ajoutés à l\'utilisateur'); |
|
|
|
} |
|
|
|
else { |
|
|
|
$this->addFlash('error', "Une erreur est survenue."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$producer = $this->getProducerCurrent(); |
|
|
|
$usersAccessArray = $this->getUserManager()->findUsersByProducer($producer); |
|
|
|
|
|
|
|
return $this->render('index', [ |
|
|
|
'usersArray' => $usersArray, |
|
|
|
'usersAccessArray' => $usersAccessArray, |
|
|
|
'usersAccessArray' => $userManager->findUsersByProducer($producer), |
|
|
|
'producer' => $producer, |
|
|
|
'modelAccessUserProducerForm' => $modelAccessUserProducerForm, |
|
|
|
]); |
|
|
@@ -104,9 +107,11 @@ class AccessController extends BackendController |
|
|
|
$userManager = $this->getUserManager(); |
|
|
|
$user = $userManager->findOneUserById($idUser); |
|
|
|
|
|
|
|
if ($user) { |
|
|
|
$userManager->deleteAccess($user); |
|
|
|
$this->setFlash('success', 'Droits de l\'utilisateur supprimé.'); |
|
|
|
if ($user && $userManager->deleteAccess($user)) { |
|
|
|
$this->addFlash('success', 'Droits de l\'utilisateur supprimé.'); |
|
|
|
} |
|
|
|
else { |
|
|
|
$this->addFlash('error', "Une erreur est survenue."); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->redirect(['index']); |