From fa73b8d929e46d115b962f2ab9f34297ea595cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Sat, 22 Feb 2020 21:12:26 +0100 Subject: [PATCH 1/3] opravy chyb pro elixir --- .../Presenters/MaturityPresenter.php | 34 ---- .../Forms/EditUserSeminarFormFactory.php | 192 +++++++++--------- app/AdminModule/Presenters/UsersPresenter.php | 2 +- .../Presenters/templates/Users/detail.latte | 104 +++++----- .../templates/Schedule/default.latte | 2 +- .../Presenters/templates/Page/default.latte | 2 +- 6 files changed, 154 insertions(+), 182 deletions(-) diff --git a/app/ActionModule/Presenters/MaturityPresenter.php b/app/ActionModule/Presenters/MaturityPresenter.php index a5f60ec35..adb717ab4 100644 --- a/app/ActionModule/Presenters/MaturityPresenter.php +++ b/app/ActionModule/Presenters/MaturityPresenter.php @@ -9,16 +9,11 @@ use App\Model\Enums\ApplicationState; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; -use App\Model\Program\ProgramRepository; use App\Model\Settings\Settings; use App\Model\Settings\SettingsException; -use App\Model\User\ApplicationRepository; -use App\Model\User\RolesApplicationRepository; -use App\Model\User\SubeventsApplicationRepository; use App\Model\User\UserRepository; use App\Services\ApplicationService; use App\Services\MailService; -use App\Services\ProgramService; use App\Services\SettingsService; use App\Utils\Helpers; use DateTimeImmutable; @@ -41,18 +36,6 @@ class MaturityPresenter extends ActionBasePresenter */ public $em; - /** - * @var ApplicationRepository - * @inject - */ - public $applicationRepository; - - /** - * @var ProgramRepository - * @inject - */ - public $programRepository; - /** * @var UserRepository * @inject @@ -71,35 +54,18 @@ class MaturityPresenter extends ActionBasePresenter */ public $mailService; - /** - * @var ProgramService - * @inject - */ - public $programService; - /** * @var ApplicationService * @inject */ public $applicationService; - /** - * @var RolesApplicationRepository - * @inject - */ - public $rolesApplicationRepository; - /** * @var SettingsService * @inject */ public $settingsService; - /** - * @var SubeventsApplicationRepository - * @inject - */ - public $subeventsApplicationRepository; /** * Zruší přihlášky po splatnosti. diff --git a/app/AdminModule/Forms/EditUserSeminarFormFactory.php b/app/AdminModule/Forms/EditUserSeminarFormFactory.php index fea834e64..45514b4f3 100644 --- a/app/AdminModule/Forms/EditUserSeminarFormFactory.php +++ b/app/AdminModule/Forms/EditUserSeminarFormFactory.php @@ -133,50 +133,52 @@ public function create(int $id) : Form $form->addHidden('id'); - $form->addMultiSelect( - 'roles', - 'admin.users.users_roles', - $this->aclService->getRolesWithoutRolesOptionsWithCapacity([Role::GUEST, Role::UNAPPROVED]) - ) - ->addRule(Form::FILLED, 'admin.users.users_edit_roles_empty') - ->addRule([$this, 'validateRolesNonregistered'], 'admin.users.users_edit_roles_nonregistered') - ->addRule([$this, 'validateRolesCapacities'], 'admin.users.users_edit_roles_occupied'); - - $form->addCheckbox('approved', 'admin.users.users_approved_form'); - - $form->addCheckbox('attended', 'admin.users.users_attended_form'); - - if ($this->user->hasDisplayArrivalDepartureRole()) { - $arrivalDateTime = new DateTimeControl('admin.users.users_arrival'); - $form->addComponent($arrivalDateTime, 'arrival'); - $departureDateTime = new DateTimeControl('admin.users.users_departure'); - $form->addComponent($departureDateTime, 'departure'); - } + if (! $this->user->isExternalLector()) { + $form->addMultiSelect( + 'roles', + 'admin.users.users_roles', + $this->aclService->getRolesWithoutRolesOptionsWithCapacity([Role::GUEST, Role::UNAPPROVED]) + ) + ->addRule(Form::FILLED, 'admin.users.users_edit_roles_empty') + ->addRule([$this, 'validateRolesNonregistered'], 'admin.users.users_edit_roles_nonregistered') + ->addRule([$this, 'validateRolesCapacities'], 'admin.users.users_edit_roles_occupied'); + + $form->addCheckbox('approved', 'admin.users.users_approved_form'); + + $form->addCheckbox('attended', 'admin.users.users_attended_form'); + + if ($this->user->hasDisplayArrivalDepartureRole()) { + $arrivalDateTime = new DateTimeControl('admin.users.users_arrival'); + $form->addComponent($arrivalDateTime, 'arrival'); + $departureDateTime = new DateTimeControl('admin.users.users_departure'); + $form->addComponent($departureDateTime, 'departure'); + } - foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) { - if ($customInput instanceof CustomText) { - $custom = $form->addText('custom' . $customInput->getId(), $customInput->getName()); - /** @var ?CustomTextValue $customInputValue */ - $customInputValue = $this->user->getCustomInputValue($customInput); - if ($customInputValue) { - $custom->setDefaultValue($customInputValue->getValue()); - } - } elseif ($customInput instanceof CustomCheckbox) { - $custom = $form->addCheckbox('custom' . $customInput->getId(), $customInput->getName()); - /** @var ?CustomCheckboxValue $customInputValue */ - $customInputValue = $this->user->getCustomInputValue($customInput); - if ($customInputValue) { - $custom->setDefaultValue($customInputValue->getValue()); - } - } elseif ($customInput instanceof CustomSelect) { - $custom = $form->addSelect('custom' . $customInput->getId(), $customInput->getName(), $customInput->getSelectOptions()); - /** @var ?CustomSelectValue $customInputValue */ - $customInputValue = $this->user->getCustomInputValue($customInput); - if ($customInputValue) { - $custom->setDefaultValue($customInputValue->getValue()); + foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) { + if ($customInput instanceof CustomText) { + $custom = $form->addText('custom' . $customInput->getId(), $customInput->getName()); + /** @var ?CustomTextValue $customInputValue */ + $customInputValue = $this->user->getCustomInputValue($customInput); + if ($customInputValue) { + $custom->setDefaultValue($customInputValue->getValue()); + } + } elseif ($customInput instanceof CustomCheckbox) { + $custom = $form->addCheckbox('custom' . $customInput->getId(), $customInput->getName()); + /** @var ?CustomCheckboxValue $customInputValue */ + $customInputValue = $this->user->getCustomInputValue($customInput); + if ($customInputValue) { + $custom->setDefaultValue($customInputValue->getValue()); + } + } elseif ($customInput instanceof CustomSelect) { + $custom = $form->addSelect('custom' . $customInput->getId(), $customInput->getName(), $customInput->getSelectOptions()); + /** @var ?CustomSelectValue $customInputValue */ + $customInputValue = $this->user->getCustomInputValue($customInput); + if ($customInputValue) { + $custom->setDefaultValue($customInputValue->getValue()); + } + } elseif ($customInput instanceof CustomFile) { + $form->addUpload('custom' . $customInput->getId(), $customInput->getName()); } - } elseif ($customInput instanceof CustomFile) { - $form->addUpload('custom' . $customInput->getId(), $customInput->getName()); } } @@ -220,66 +222,68 @@ public function processForm(Form $form, stdClass $values) : void $loggedUser = $this->userRepository->findById($form->getPresenter()->user->id); $this->em->transactional(function () use ($values, $loggedUser) : void { - $selectedRoles = $this->roleRepository->findRolesByIds($values->roles); - $this->applicationService->updateRoles($this->user, $selectedRoles, $loggedUser); - - $this->user->setApproved($values->approved); - $this->user->setAttended($values->attended); - $customInputValueChanged = false; - foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) { - $customInputValue = $this->user->getCustomInputValue($customInput); - $customInputName = 'custom' . $customInput->getId(); - $oldValue = null; - $newValue = null; - - if ($customInput instanceof CustomText) { - /** @var CustomTextValue $customInputValue */ - $customInputValue = $customInputValue ?: new CustomTextValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; - $customInputValue->setValue($newValue); - } elseif ($customInput instanceof CustomCheckbox) { - /** @var CustomCheckboxValue $customInputValue */ - $customInputValue = $customInputValue ?: new CustomCheckboxValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; - $customInputValue->setValue($newValue); - } elseif ($customInput instanceof CustomSelect) { - /** @var CustomSelectValue $customInputValue */ - $customInputValue = $customInputValue ?: new CustomSelectValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; - $customInputValue->setValue($newValue); - } elseif ($customInput instanceof CustomFile) { - /** @var CustomFileValue $customInputValue */ - $customInputValue = $customInputValue ?: new CustomFileValue(); - $oldValue = $customInputValue->getValue(); - /** @var FileUpload $newValue */ - $newValue = $values->$customInputName; - if ($newValue->getError() == UPLOAD_ERR_OK) { - $path = $this->generatePath($newValue); - $this->filesService->save($newValue, $path); - $customInputValue->setValue($path); + if (! $this->user->isExternalLector()) { + $selectedRoles = $this->roleRepository->findRolesByIds($values->roles); + $this->applicationService->updateRoles($this->user, $selectedRoles, $loggedUser); + + $this->user->setApproved($values->approved); + $this->user->setAttended($values->attended); + + foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) { + $customInputValue = $this->user->getCustomInputValue($customInput); + $customInputName = 'custom' . $customInput->getId(); + $oldValue = null; + $newValue = null; + + if ($customInput instanceof CustomText) { + /** @var CustomTextValue $customInputValue */ + $customInputValue = $customInputValue ?: new CustomTextValue(); + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; + $customInputValue->setValue($newValue); + } elseif ($customInput instanceof CustomCheckbox) { + /** @var CustomCheckboxValue $customInputValue */ + $customInputValue = $customInputValue ?: new CustomCheckboxValue(); + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; + $customInputValue->setValue($newValue); + } elseif ($customInput instanceof CustomSelect) { + /** @var CustomSelectValue $customInputValue */ + $customInputValue = $customInputValue ?: new CustomSelectValue(); + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; + $customInputValue->setValue($newValue); + } elseif ($customInput instanceof CustomFile) { + /** @var CustomFileValue $customInputValue */ + $customInputValue = $customInputValue ?: new CustomFileValue(); + $oldValue = $customInputValue->getValue(); + /** @var FileUpload $newValue */ + $newValue = $values->$customInputName; + if ($newValue->getError() == UPLOAD_ERR_OK) { + $path = $this->generatePath($newValue); + $this->filesService->save($newValue, $path); + $customInputValue->setValue($path); + } } - } - $customInputValue->setUser($this->user); - $customInputValue->setInput($customInput); - $this->customInputValueRepository->save($customInputValue); + $customInputValue->setUser($this->user); + $customInputValue->setInput($customInput); + $this->customInputValueRepository->save($customInputValue); - if ($oldValue !== $newValue) { - $customInputValueChanged = true; + if ($oldValue !== $newValue) { + $customInputValueChanged = true; + } } - } - if (property_exists($values, 'arrival')) { - $this->user->setArrival($values->arrival); - } + if (property_exists($values, 'arrival')) { + $this->user->setArrival($values->arrival); + } - if (property_exists($values, 'departure')) { - $this->user->setDeparture($values->departure); + if (property_exists($values, 'departure')) { + $this->user->setDeparture($values->departure); + } } $this->user->setAbout($values->about); diff --git a/app/AdminModule/Presenters/UsersPresenter.php b/app/AdminModule/Presenters/UsersPresenter.php index 72f96d5f6..30ac82290 100644 --- a/app/AdminModule/Presenters/UsersPresenter.php +++ b/app/AdminModule/Presenters/UsersPresenter.php @@ -124,7 +124,7 @@ public function renderDetail(int $id) : void $this->template->paymentMethodCash = PaymentType::CASH; $this->template->paymentMethodBank = PaymentType::BANK; - $this->template->registered = ! $user->isInRole($this->roleRepository->findBySystemName(Role::NONREGISTERED)); + $this->template->registered = ! $user->isInRole($this->roleRepository->findBySystemName(Role::NONREGISTERED)) && ! $user->isExternalLector(); } /** diff --git a/app/AdminModule/Presenters/templates/Users/detail.latte b/app/AdminModule/Presenters/templates/Users/detail.latte index d140d91c5..1ea46d3ef 100644 --- a/app/AdminModule/Presenters/templates/Users/detail.latte +++ b/app/AdminModule/Presenters/templates/Users/detail.latte @@ -83,64 +83,66 @@
{$detailUser->getRolesText()}
-
-
{_admin.users.users_approved_detail}
-
- {if $detailUser->isApproved()} - {_admin.common.yes} - {else} - {_admin.common.no} - {/if} -
-
- -
-
{_admin.users.users_attended_detail}
-
- {if $detailUser->isAttended()} - {_admin.common.yes} - {else} - {_admin.common.no} - {/if} -
-
- - {if $detailUser->hasDisplayArrivalDepartureRole()} + {if !$detailUser->isExternalLector()}
-
{_admin.users.users_arrival}
-
{$detailUser->getArrival()|date:'j. n. Y H:i'}
+
{_admin.users.users_approved_detail}
+
+ {if $detailUser->isApproved()} + {_admin.common.yes} + {else} + {_admin.common.no} + {/if} +
-
{_admin.users.users_departure}
-
{$detailUser->getDeparture()|date:'j. n. Y H:i'}
+
{_admin.users.users_attended_detail}
+
+ {if $detailUser->isAttended()} + {_admin.common.yes} + {else} + {_admin.common.no} + {/if} +
- {/if} -
-
{$customInput->getName()}
-
- {var $customInputValue = $detailUser->getCustomInputValue($customInput)} - {if $customInputValue} - {switch $customInput->getType()} - {case $customInputTypeText} - {$customInputValue->getValue()} - {case $customInputTypeCheckbox} - {if $customInputValue->getValue()} - {_admin.common.yes} - {else} - {_admin.common.no} - {/if} - {case $customInputTypeSelect} - {$customInputValue->getValueOption()} - {case $customInputTypeFile} - - {array_values(array_slice(explode('/', $customInputValue->getValue()), -1))[0]} - - {/switch} - {/if} + {if $detailUser->hasDisplayArrivalDepartureRole()} +
+
{_admin.users.users_arrival}
+
{$detailUser->getArrival()|date:'j. n. Y H:i'}
+
+ +
+
{_admin.users.users_departure}
+
{$detailUser->getDeparture()|date:'j. n. Y H:i'}
+
+ {/if} + +
+
{$customInput->getName()}
+
+ {var $customInputValue = $detailUser->getCustomInputValue($customInput)} + {if $customInputValue} + {switch $customInput->getType()} + {case $customInputTypeText} + {$customInputValue->getValue()} + {case $customInputTypeCheckbox} + {if $customInputValue->getValue()} + {_admin.common.yes} + {else} + {_admin.common.no} + {/if} + {case $customInputTypeSelect} + {$customInputValue->getValueOption()} + {case $customInputTypeFile} + + {array_values(array_slice(explode('/', $customInputValue->getValue()), -1))[0]} + + {/switch} + {/if} +
-
+ {/if}
{_admin.users.users_about_me}
diff --git a/app/AdminModule/ProgramModule/Presenters/templates/Schedule/default.latte b/app/AdminModule/ProgramModule/Presenters/templates/Schedule/default.latte index ba8a5fc46..2ceb3e2a4 100644 --- a/app/AdminModule/ProgramModule/Presenters/templates/Schedule/default.latte +++ b/app/AdminModule/ProgramModule/Presenters/templates/Schedule/default.latte @@ -124,7 +124,7 @@ - + diff --git a/app/WebModule/Presenters/templates/Page/default.latte b/app/WebModule/Presenters/templates/Page/default.latte index eabe391f8..07024c06b 100644 --- a/app/WebModule/Presenters/templates/Page/default.latte +++ b/app/WebModule/Presenters/templates/Page/default.latte @@ -1,7 +1,7 @@ {block body-class}{$bodyClass}{/block} {block main} -
+

{$page->getName()}

From 70eb1a35aa535712193c2a53099210e38160e01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Sat, 22 Feb 2020 21:32:10 +0100 Subject: [PATCH 2/3] oprava coding standard --- .../Presenters/MaturityPresenter.php | 1 - .../Forms/EditUserSeminarFormFactory.php | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/ActionModule/Presenters/MaturityPresenter.php b/app/ActionModule/Presenters/MaturityPresenter.php index adb717ab4..1070898a3 100644 --- a/app/ActionModule/Presenters/MaturityPresenter.php +++ b/app/ActionModule/Presenters/MaturityPresenter.php @@ -66,7 +66,6 @@ class MaturityPresenter extends ActionBasePresenter */ public $settingsService; - /** * Zruší přihlášky po splatnosti. * diff --git a/app/AdminModule/Forms/EditUserSeminarFormFactory.php b/app/AdminModule/Forms/EditUserSeminarFormFactory.php index 45514b4f3..028b97324 100644 --- a/app/AdminModule/Forms/EditUserSeminarFormFactory.php +++ b/app/AdminModule/Forms/EditUserSeminarFormFactory.php @@ -233,32 +233,32 @@ public function processForm(Form $form, stdClass $values) : void foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) { $customInputValue = $this->user->getCustomInputValue($customInput); - $customInputName = 'custom' . $customInput->getId(); - $oldValue = null; - $newValue = null; + $customInputName = 'custom' . $customInput->getId(); + $oldValue = null; + $newValue = null; if ($customInput instanceof CustomText) { /** @var CustomTextValue $customInputValue */ $customInputValue = $customInputValue ?: new CustomTextValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; $customInputValue->setValue($newValue); } elseif ($customInput instanceof CustomCheckbox) { /** @var CustomCheckboxValue $customInputValue */ $customInputValue = $customInputValue ?: new CustomCheckboxValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; $customInputValue->setValue($newValue); } elseif ($customInput instanceof CustomSelect) { /** @var CustomSelectValue $customInputValue */ $customInputValue = $customInputValue ?: new CustomSelectValue(); - $oldValue = $customInputValue->getValue(); - $newValue = $values->$customInputName; + $oldValue = $customInputValue->getValue(); + $newValue = $values->$customInputName; $customInputValue->setValue($newValue); } elseif ($customInput instanceof CustomFile) { /** @var CustomFileValue $customInputValue */ $customInputValue = $customInputValue ?: new CustomFileValue(); - $oldValue = $customInputValue->getValue(); + $oldValue = $customInputValue->getValue(); /** @var FileUpload $newValue */ $newValue = $values->$customInputName; if ($newValue->getError() == UPLOAD_ERR_OK) { From e760a165a14c0522333d81f04a523eb83af5d913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Sat, 22 Feb 2020 21:38:50 +0100 Subject: [PATCH 3/3] oprava mobilniho zobrazeni --- app/AdminModule/Presenters/templates/@layout.latte | 2 +- app/InstallModule/Presenters/templates/@layout.latte | 2 +- app/WebModule/Presenters/templates/@layout.latte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/AdminModule/Presenters/templates/@layout.latte b/app/AdminModule/Presenters/templates/@layout.latte index d1a0aa33a..2e2f72804 100644 --- a/app/AdminModule/Presenters/templates/@layout.latte +++ b/app/AdminModule/Presenters/templates/@layout.latte @@ -2,7 +2,7 @@ - + {_admin.common.title, [seminar_name => $seminarName]} diff --git a/app/InstallModule/Presenters/templates/@layout.latte b/app/InstallModule/Presenters/templates/@layout.latte index a3f561f54..1eb8e2c17 100644 --- a/app/InstallModule/Presenters/templates/@layout.latte +++ b/app/InstallModule/Presenters/templates/@layout.latte @@ -2,7 +2,7 @@ - + {_install.common.title} diff --git a/app/WebModule/Presenters/templates/@layout.latte b/app/WebModule/Presenters/templates/@layout.latte index a64c58d79..7f2a011fb 100644 --- a/app/WebModule/Presenters/templates/@layout.latte +++ b/app/WebModule/Presenters/templates/@layout.latte @@ -14,7 +14,7 @@ {/if} - + {_web.common.title, [page => $pageName, seminar_name => $seminarName]}
{_admin.program.schedule.category}{_admin.program.schedule.category} {{ block.category }}