From ed0cb02a88bde2c083cbfdd002e2f3f7b557a985 Mon Sep 17 00:00:00 2001 From: jan-stanek Date: Sun, 12 Mar 2017 00:58:45 +0100 Subject: [PATCH] oprava chyb --- app/AdminModule/forms/EditRoleForm.php | 11 ++++++++++- app/model/Program/ProgramRepository.php | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/AdminModule/forms/EditRoleForm.php b/app/AdminModule/forms/EditRoleForm.php index 87c6897dd..7702e3b48 100644 --- a/app/AdminModule/forms/EditRoleForm.php +++ b/app/AdminModule/forms/EditRoleForm.php @@ -11,6 +11,7 @@ use App\Model\CMS\PageRepository; +use App\Model\Program\ProgramRepository; use Nette; use Nette\Application\UI\Form; @@ -31,13 +32,18 @@ class EditRoleForm extends Nette\Object /** @var PermissionRepository */ private $permissionRepository; + /** @var ProgramRepository */ + private $programRepository; + public function __construct(BaseForm $baseFormFactory, RoleRepository $roleRepository, - PageRepository $pageRepository, PermissionRepository $permissionRepository) + PageRepository $pageRepository, PermissionRepository $permissionRepository, + ProgramRepository $programRepository) { $this->baseFormFactory = $baseFormFactory; $this->roleRepository = $roleRepository; $this->pageRepository = $pageRepository; $this->permissionRepository = $permissionRepository; + $this->programRepository = $programRepository; } public function create($id) @@ -163,6 +169,9 @@ public function processForm(Form $form, \stdClass $values) { $this->role->setRequiredRoles($this->roleRepository->findRolesByIds($values['requiredRoles'])); $this->roleRepository->save($this->role); + + $this->programRepository->updateUsersPrograms($this->role->getUsers()); + $this->roleRepository->save($this->role); } } diff --git a/app/model/Program/ProgramRepository.php b/app/model/Program/ProgramRepository.php index ae63f7d6b..9dd5afe35 100644 --- a/app/model/Program/ProgramRepository.php +++ b/app/model/Program/ProgramRepository.php @@ -185,9 +185,9 @@ public function updateUserPrograms(User $user) { } /** - * @param User[] $users + * @param $users */ - public function updateUsersPrograms(array $users) { + public function updateUsersPrograms($users) { foreach ($users as $user) { $oldUsersPrograms = $user->getPrograms(); $userAllowedPrograms = $this->findUserAllowed($user);