Skip to content

Commit

Permalink
Merge pull request #236 from skaut/odhlasovani-prihlasovani-programu
Browse files Browse the repository at this point in the history
oprava prihlasovani/odhlasovani programu
  • Loading branch information
Jan Staněk authored Mar 12, 2017
2 parents 3ae122f + ed0cb02 commit c44847e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/AdminModule/forms/EditRoleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Model\CMS\PageRepository;


use App\Model\Program\ProgramRepository;
use Nette;
use Nette\Application\UI\Form;

Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/model/Program/ProgramRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c44847e

Please sign in to comment.