From d4c44a139b613bbc945f4ef63793d69c759b5425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Sun, 24 Dec 2017 12:56:52 +0100 Subject: [PATCH 01/11] =?UTF-8?q?refactoring,=20vytvo=C5=99en=C3=AD=20e-ma?= =?UTF-8?q?ilu=20p=C5=99i=20zm=C4=9Bn=C4=9B=20vlastn=C3=ADch=20pol=C3=AD?= =?UTF-8?q?=20(#445),=20logika=20do=20ProgramService=20(#421),=20mo=C5=BEn?= =?UTF-8?q?ost=20ur=C4=8Dit=20komu=20se=20pos=C3=ADlaj=C3=AD=20automatick?= =?UTF-8?q?=C3=A9=20e-maily?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenters/MailingPresenter.php | 10 +- .../presenters/MaturityPresenter.php | 23 ++-- .../components/DocumentTagsGridControl.php | 4 + .../components/DocumentsGridControl.php | 4 + .../CMSModule/components/FaqGridControl.php | 6 + .../CMSModule/components/NewsGridControl.php | 4 + .../CMSModule/components/PagesGridControl.php | 16 ++- app/AdminModule/CMSModule/forms/FaqForm.php | 1 + app/AdminModule/CMSModule/forms/PageForm.php | 11 +- .../components/CustomInputsGridControl.php | 9 +- .../components/DiscountsGridControl.php | 6 +- .../components/PlacePointsGridControl.php | 2 + .../components/SubeventsGridControl.php | 5 +- .../forms/ApplicationForm.php | 2 + .../forms/CustomInputForm.php | 1 + .../forms/DiscountForm.php | 4 +- .../ConfigurationModule/forms/MailingForm.php | 8 +- .../ConfigurationModule/forms/PaymentForm.php | 10 +- .../forms/PaymentProofForm.php | 2 + .../forms/PlaceDescriptionForm.php | 2 + .../ConfigurationModule/forms/ProgramForm.php | 2 + .../ConfigurationModule/forms/SeminarForm.php | 2 + .../forms/SkautIsEventForm.php | 11 +- .../forms/SubeventForm.php | 9 +- .../forms/SubeventsForm.php | 2 + .../ConfigurationModule/forms/WebForm.php | 3 + .../forms/templates/discount_form.latte | 9 +- .../presenters/ApplicationPresenter.php | 1 + .../presenters/ConfigurationBasePresenter.php | 4 +- .../presenters/DiscountsPresenter.php | 1 - .../presenters/MailingPresenter.php | 3 +- .../presenters/PaymentPresenter.php | 1 - .../components/MailHistoryGridControl.php | 1 - .../components/MailTemplatesGridControl.php | 38 ++++++- .../MailingModule/forms/EditTemplateForm.php | 22 +++- .../MailingModule/forms/SendForm.php | 4 + .../presenters/templates/Templates/edit.latte | 4 +- .../ProgramAttendeesGridControl.php | 16 ++- .../components/ProgramBlocksGridControl.php | 6 + .../ProgramCategoriesGridControl.php | 23 +++- .../components/RoomScheduleGridControl.php | 5 +- .../components/RoomsGridControl.php | 5 + .../ProgramModule/forms/BlockForm.php | 14 ++- .../presenters/BlocksPresenter.php | 5 + .../components/ApplicationsGridControl.php | 65 ++++++----- .../components/RolesGridControl.php | 18 ++- .../components/UsersGridControl.php | 58 ++++++---- app/AdminModule/forms/AddLectorForm.php | 1 + app/AdminModule/forms/EditRoleForm.php | 21 +++- .../forms/EditUserPersonalDetailsForm.php | 10 +- app/AdminModule/forms/EditUserSeminarForm.php | 17 ++- app/AdminModule/presenters/AclPresenter.php | 10 +- .../presenters/AdminBasePresenter.php | 1 + app/AdminModule/presenters/UsersPresenter.php | 15 ++- .../templates/Dashboard/default.latte | 42 ++++--- .../presenters/templates/Users/detail.latte | 4 +- .../templates/includes/main_menu.latte | 3 +- .../presenters/SchedulePresenter.php | 8 ++ app/ApiModule/services/ScheduleService.php | 7 +- .../presenters/InstallPresenter.php | 7 ++ .../components/ApplicationContentControl.php | 4 + .../components/ApplicationsGridControl.php | 93 ++++++++-------- .../components/PlaceContentControl.php | 1 + .../components/ProgramsContentControl.php | 1 + .../templates/application_content.latte | 4 +- .../templates/lectors_content.latte | 2 +- .../forms/AdditionalInformationForm.php | 5 +- app/WebModule/forms/ApplicationForm.php | 28 +++-- app/WebModule/forms/FaqForm.php | 1 + app/WebModule/presenters/ProfilePresenter.php | 12 +- app/WebModule/presenters/WebBasePresenter.php | 2 +- app/config/config.neon | 2 - app/lang/admin.cs_CZ.neon | 9 +- app/lang/common.cs_CZ.neon | 3 + app/model/ACL/PermissionRepository.php | 2 + app/model/ACL/RoleRepository.php | 43 +++++--- app/model/CMS/Content/Content.php | 16 +-- app/model/CMS/Content/ImageContent.php | 14 +-- app/model/CMS/FaqRepository.php | 3 + app/model/CMS/NewsRepository.php | 1 + app/model/CMS/PageRepository.php | 3 + app/model/Mailing/Template.php | 91 ++++++++++++++- app/model/Mailing/TemplateVariable.php | 1 - app/model/Program/BlockRepository.php | 39 ++----- app/model/Program/ProgramRepository.php | 86 +++------------ .../CustomInput/CustomInputRepository.php | 6 +- .../Settings/CustomInput/CustomSelect.php | 2 +- app/model/Settings/SettingsRepository.php | 32 +++--- app/model/Structure/SubeventRepository.php | 22 +++- app/model/User/ApplicationRepository.php | 1 - app/model/User/User.php | 30 ++--- app/presenters/AuthPresenter.php | 10 +- app/services/ApplicationService.php | 22 ++-- app/services/Authenticator.php | 11 +- app/services/DatabaseService.php | 12 +- app/services/DiscountService.php | 51 +++++---- app/services/ExcelExportService.php | 56 ++++++---- app/services/ExcelResponse.php | 1 + app/services/FilesService.php | 6 +- app/services/MailService.php | 20 +++- app/services/PdfExportService.php | 10 +- app/services/ProgramService.php | 104 +++++++++++++++++- app/services/SkautIsEventService.php | 11 +- app/services/SkautIsService.php | 3 +- app/services/UserService.php | 75 ++++++++++++- migrations/Version20171223230501.php | 30 +++++ migrations/Version20171223233147.php | 23 ++++ migrations/Version20171224074439.php | 24 ++++ 108 files changed, 1115 insertions(+), 521 deletions(-) create mode 100644 migrations/Version20171223230501.php create mode 100644 migrations/Version20171223233147.php create mode 100644 migrations/Version20171224074439.php diff --git a/app/ActionModule/presenters/MailingPresenter.php b/app/ActionModule/presenters/MailingPresenter.php index 8fd79553f..c66451689 100644 --- a/app/ActionModule/presenters/MailingPresenter.php +++ b/app/ActionModule/presenters/MailingPresenter.php @@ -6,8 +6,6 @@ use App\Model\ACL\Resource; use App\Model\Settings\Settings; use App\Model\Settings\SettingsRepository; -use App\Model\Structure\SubeventRepository; -use Nette\Application\Responses\TextResponse; /** @@ -27,6 +25,8 @@ class MailingPresenter extends ActionBasePresenter /** * Ověří e-mail semináře. * @param $code + * @throws \App\Model\Settings\SettingsException + * @throws \Nette\Application\AbortException */ public function actionVerify($code) { @@ -38,15 +38,13 @@ public function actionVerify($code) $this->settingsRepository->setValue(Settings::SEMINAR_EMAIL_VERIFICATION_CODE, NULL); $this->flashMessage('admin.configuration.mailing_email_verification_success', 'success'); - } - else { + } else { $this->flashMessage('admin.configuration.mailing_email_verification_error', 'danger'); } if ($this->user->isAllowed(Resource::CONFIGURATION, Permission::MANAGE)) { $this->redirect(':Admin:Configuration:Mailing:default'); - } - else { + } else { $this->redirect(':Web:Page:default'); } } diff --git a/app/ActionModule/presenters/MaturityPresenter.php b/app/ActionModule/presenters/MaturityPresenter.php index de4f8792b..19833ef27 100644 --- a/app/ActionModule/presenters/MaturityPresenter.php +++ b/app/ActionModule/presenters/MaturityPresenter.php @@ -2,8 +2,6 @@ namespace App\ActionModule\Presenters; -use App\Model\ACL\Permission; -use App\Model\ACL\Resource; use App\Model\ACL\Role; use App\Model\ACL\RoleRepository; use App\Model\Enums\ApplicationState; @@ -12,12 +10,11 @@ use App\Model\Program\ProgramRepository; use App\Model\Settings\Settings; use App\Model\Settings\SettingsRepository; -use App\Model\Structure\SubeventRepository; use App\Model\User\ApplicationRepository; use App\Model\User\UserRepository; use App\Services\MailService; +use App\Services\ProgramService; use Doctrine\Common\Collections\ArrayCollection; -use Nette\Application\Responses\TextResponse; /** @@ -63,6 +60,12 @@ class MaturityPresenter extends ActionBasePresenter */ public $mailService; + /** + * @var ProgramService + * @inject + */ + public $programService; + /** * Zkontroluje splatnost přihlášek. @@ -84,7 +87,7 @@ public function actionCheck() //zrušení registrace if ($cancelRegistration !== NULL && $cancelRegistrationDate > $maturityDate) { - $this->userRepository->getEntityManager()->transactional(function($em) use($application) { + $this->userRepository->getEntityManager()->transactional(function ($em) use ($application) { if ($application->isFirst()) { $user = $application->getUser(); @@ -95,24 +98,22 @@ public function actionCheck() } $this->userRepository->save($user); - $this->mailService->sendMailFromTemplate(new ArrayCollection(), new ArrayCollection([$user]), '', Template::REGISTRATION_CANCELED, [ + $this->mailService->sendMailFromTemplate($user, '', Template::REGISTRATION_CANCELED, [ TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME) ]); - } - else { + } else { $application->setState(ApplicationState::CANCELED_NOT_PAID); $this->applicationRepository->save($application); } - $this->programRepository->updateUserPrograms($application->getUser()); - $this->userRepository->save($application->getUser()); + $this->programService->updateUserPrograms($application->getUser()); }); continue; } //připomenutí splatnosti if ($maturityReminder !== NULL && $maturityReminderDate == $maturityDate) { - $this->mailService->sendMailFromTemplate(new ArrayCollection(), new ArrayCollection([$application->getUser()]), '', Template::MATURITY_REMINDER, [ + $this->mailService->sendMailFromTemplate($application->getUser(), '', Template::MATURITY_REMINDER, [ TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME), TemplateVariable::APPLICATION_MATURITY => $maturityDate->format('j. n. Y') ]); diff --git a/app/AdminModule/CMSModule/components/DocumentTagsGridControl.php b/app/AdminModule/CMSModule/components/DocumentTagsGridControl.php index 20c0f2ba8..c76401f97 100644 --- a/app/AdminModule/CMSModule/components/DocumentTagsGridControl.php +++ b/app/AdminModule/CMSModule/components/DocumentTagsGridControl.php @@ -48,6 +48,7 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentDocumentTagsGrid($name) { @@ -96,6 +97,7 @@ public function createComponentDocumentTagsGrid($name) /** * Zpracuje přidání štítku dokumentu. * @param $values + * @throws \Nette\Application\AbortException */ public function add($values) { @@ -114,6 +116,7 @@ public function add($values) * Zpracuje úpravu štítku dokumentu. * @param $id * @param $values + * @throws \Nette\Application\AbortException */ public function edit($id, $values) { @@ -131,6 +134,7 @@ public function edit($id, $values) /** * Zpracuje odstranění štítku dokumentu. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { diff --git a/app/AdminModule/CMSModule/components/DocumentsGridControl.php b/app/AdminModule/CMSModule/components/DocumentsGridControl.php index e97e5b512..421aec391 100644 --- a/app/AdminModule/CMSModule/components/DocumentsGridControl.php +++ b/app/AdminModule/CMSModule/components/DocumentsGridControl.php @@ -64,6 +64,7 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentDocumentsGrid($name) { @@ -153,6 +154,7 @@ public function createComponentDocumentsGrid($name) /** * Zpracuje přidání dokumentu. * @param $values + * @throws \Nette\Application\AbortException */ public function add($values) { @@ -179,6 +181,7 @@ public function add($values) * Zpracuje úpravu dokumentu. * @param $id * @param $values + * @throws \Nette\Application\AbortException */ public function edit($id, $values) { @@ -208,6 +211,7 @@ public function edit($id, $values) /** * Zpracuje odstranění dokumentu. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { diff --git a/app/AdminModule/CMSModule/components/FaqGridControl.php b/app/AdminModule/CMSModule/components/FaqGridControl.php index 3a108314f..6d0116461 100644 --- a/app/AdminModule/CMSModule/components/FaqGridControl.php +++ b/app/AdminModule/CMSModule/components/FaqGridControl.php @@ -46,6 +46,8 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentFaqGrid($name) { @@ -96,6 +98,7 @@ public function createComponentFaqGrid($name) /** * Zpracuje odstranění otázky. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { @@ -112,6 +115,7 @@ public function handleDelete($id) * @param $item_id * @param $prev_id * @param $next_id + * @throws \Nette\Application\AbortException */ public function handleSort($item_id, $prev_id, $next_id) { @@ -132,6 +136,8 @@ public function handleSort($item_id, $prev_id, $next_id) * Změní viditelnost otázky. * @param $id * @param $public + * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Nette\Application\AbortException */ public function changeStatus($id, $public) { diff --git a/app/AdminModule/CMSModule/components/NewsGridControl.php b/app/AdminModule/CMSModule/components/NewsGridControl.php index 3b4988548..1d10019db 100644 --- a/app/AdminModule/CMSModule/components/NewsGridControl.php +++ b/app/AdminModule/CMSModule/components/NewsGridControl.php @@ -46,6 +46,8 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentNewsGrid($name) { @@ -91,6 +93,7 @@ public function createComponentNewsGrid($name) /** * Zpracuje odstranění aktuality. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { @@ -106,6 +109,7 @@ public function handleDelete($id) * Změní připíchnutí aktuality. * @param $id * @param $pinned + * @throws \Nette\Application\AbortException */ public function changePinned($id, $pinned) { diff --git a/app/AdminModule/CMSModule/components/PagesGridControl.php b/app/AdminModule/CMSModule/components/PagesGridControl.php index 3e17576a2..0545990fb 100644 --- a/app/AdminModule/CMSModule/components/PagesGridControl.php +++ b/app/AdminModule/CMSModule/components/PagesGridControl.php @@ -54,6 +54,8 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentPagesGrid($name) { @@ -162,6 +164,8 @@ public function createComponentPagesGrid($name) /** * Zpracuje přidání stránky. * @param $values + * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Nette\Application\AbortException */ public function add($values) { @@ -182,6 +186,8 @@ public function add($values) * Zpracuje upravení stránky. * @param $id * @param $values + * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Nette\Application\AbortException */ public function edit($id, $values) { @@ -203,6 +209,8 @@ public function edit($id, $values) /** * Zpracuje odstranění stránky. * @param $id + * @throws \App\Model\Page\PageException + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { @@ -219,6 +227,7 @@ public function handleDelete($id) * @param $item_id * @param $prev_id * @param $next_id + * @throws \Nette\Application\AbortException */ public function handleSort($item_id, $prev_id, $next_id) { @@ -239,15 +248,18 @@ public function handleSort($item_id, $prev_id, $next_id) * Změní viditelnost stránky. * @param $id * @param $public + * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Nette\Application\AbortException */ public function changeStatus($id, $public) { $p = $this->getPresenter(); - if ($this->pageRepository->findById($id)->getSlug() == '/' && !$public) { + $page = $this->pageRepository->findById($id); + + if ($page->getSlug() == '/' && !$public) { $p->flashMessage('admin.cms.pages_change_public_denied', 'danger'); } else { - $page = $this->pageRepository->findById($id); $page->setPublic($public); $this->pageRepository->save($page); diff --git a/app/AdminModule/CMSModule/forms/FaqForm.php b/app/AdminModule/CMSModule/forms/FaqForm.php index 23f2930a6..fc864e2a9 100644 --- a/app/AdminModule/CMSModule/forms/FaqForm.php +++ b/app/AdminModule/CMSModule/forms/FaqForm.php @@ -108,6 +108,7 @@ public function create($id, $userId) * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \Doctrine\ORM\NonUniqueResultException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/CMSModule/forms/PageForm.php b/app/AdminModule/CMSModule/forms/PageForm.php index 543c5135d..2dae8c11d 100644 --- a/app/AdminModule/CMSModule/forms/PageForm.php +++ b/app/AdminModule/CMSModule/forms/PageForm.php @@ -31,24 +31,24 @@ class PageForm extends UI\Control * @var int */ public $id; - + /** * Upravovaná stránka. * @var Page */ private $page; - + /** * Upravovaná oblast. * @var string */ public $area; - + /** * Událost při uložení formuláře. */ public $onPageSave; - + /** * Událost při chybě ukládání stránky. */ @@ -119,6 +119,7 @@ public function render() /** * Vytvoří komponentu. * @return Form + * @throws \App\Model\Page\PageException */ public function createComponentForm() { @@ -168,6 +169,8 @@ public function createComponentForm() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Page\PageException + * @throws \Doctrine\ORM\NonUniqueResultException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/components/CustomInputsGridControl.php b/app/AdminModule/ConfigurationModule/components/CustomInputsGridControl.php index 3ab1c39c5..a79f6444c 100644 --- a/app/AdminModule/ConfigurationModule/components/CustomInputsGridControl.php +++ b/app/AdminModule/ConfigurationModule/components/CustomInputsGridControl.php @@ -2,13 +2,10 @@ namespace App\AdminModule\ConfigurationModule\Components; -use App\Model\Settings\CustomInput\CustomCheckbox; use App\Model\Settings\CustomInput\CustomInput; use App\Model\Settings\CustomInput\CustomInputRepository; -use App\Model\Settings\CustomInput\CustomText; use Kdyby\Translation\Translator; use Nette\Application\UI\Control; -use Nette\Application\UI\Form; use Ublaboo\DataGrid\DataGrid; @@ -50,6 +47,8 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentCustomInputsGrid($name) { @@ -103,6 +102,7 @@ public function createComponentCustomInputsGrid($name) /** * Zpracuje odstranění vlastního pole. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { @@ -119,6 +119,7 @@ public function handleDelete($id) * @param $item_id * @param $prev_id * @param $next_id + * @throws \Nette\Application\AbortException */ public function handleSort($item_id, $prev_id, $next_id) { @@ -139,6 +140,8 @@ public function handleSort($item_id, $prev_id, $next_id) * Změní povinnost pole. * @param $id * @param $mandatory + * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Nette\Application\AbortException */ public function changeMandatory($id, $mandatory) { diff --git a/app/AdminModule/ConfigurationModule/components/DiscountsGridControl.php b/app/AdminModule/ConfigurationModule/components/DiscountsGridControl.php index 75817add8..3bb256eb9 100644 --- a/app/AdminModule/ConfigurationModule/components/DiscountsGridControl.php +++ b/app/AdminModule/ConfigurationModule/components/DiscountsGridControl.php @@ -2,14 +2,12 @@ namespace App\AdminModule\ConfigurationModule\Components; -use App\Model\Enums\ConditionOperator; -use App\Model\Structure\Discount; + use App\Model\Structure\DiscountRepository; use App\Model\Structure\SubeventRepository; use App\Services\DiscountService; use Kdyby\Translation\Translator; use Nette\Application\UI\Control; -use Nette\Forms\Form; use Nette\Utils\Html; use Ublaboo\DataGrid\DataGrid; @@ -63,6 +61,7 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentDiscountsGrid($name) { @@ -103,6 +102,7 @@ public function createComponentDiscountsGrid($name) /** * Zpracuje odstranění slevy. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { diff --git a/app/AdminModule/ConfigurationModule/components/PlacePointsGridControl.php b/app/AdminModule/ConfigurationModule/components/PlacePointsGridControl.php index e7c48955e..6127e603d 100644 --- a/app/AdminModule/ConfigurationModule/components/PlacePointsGridControl.php +++ b/app/AdminModule/ConfigurationModule/components/PlacePointsGridControl.php @@ -46,6 +46,7 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentPlacePointsGrid($name) { @@ -87,6 +88,7 @@ public function createComponentPlacePointsGrid($name) /** * Zpracuje odstranění mapového bodu. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { diff --git a/app/AdminModule/ConfigurationModule/components/SubeventsGridControl.php b/app/AdminModule/ConfigurationModule/components/SubeventsGridControl.php index a8bd0e949..dd7009f30 100644 --- a/app/AdminModule/ConfigurationModule/components/SubeventsGridControl.php +++ b/app/AdminModule/ConfigurationModule/components/SubeventsGridControl.php @@ -53,6 +53,7 @@ public function render() /** * Vytvoří komponentu. * @param $name + * @throws \Ublaboo\DataGrid\Exception\DataGridException */ public function createComponentSubeventsGrid($name) { @@ -108,6 +109,7 @@ function ($row) { /** * Zpracuje odstranění podakce. * @param $id + * @throws \Nette\Application\AbortException */ public function handleDelete($id) { @@ -116,8 +118,7 @@ public function handleDelete($id) if ($subevent->getBlocks()->isEmpty()) { $this->subeventRepository->remove($subevent); $this->getPresenter()->flashMessage('admin.configuration.subevents_deleted', 'success'); - } - else { + } else { $this->getPresenter()->flashMessage('admin.configuration.subevents_deleted_error', 'danger'); } diff --git a/app/AdminModule/ConfigurationModule/forms/ApplicationForm.php b/app/AdminModule/ConfigurationModule/forms/ApplicationForm.php index ceca22800..42767651f 100644 --- a/app/AdminModule/ConfigurationModule/forms/ApplicationForm.php +++ b/app/AdminModule/ConfigurationModule/forms/ApplicationForm.php @@ -37,6 +37,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -64,6 +65,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/CustomInputForm.php b/app/AdminModule/ConfigurationModule/forms/CustomInputForm.php index c386bb2d0..ac54f1087 100644 --- a/app/AdminModule/ConfigurationModule/forms/CustomInputForm.php +++ b/app/AdminModule/ConfigurationModule/forms/CustomInputForm.php @@ -100,6 +100,7 @@ public function create($id) * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \Doctrine\ORM\NonUniqueResultException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/DiscountForm.php b/app/AdminModule/ConfigurationModule/forms/DiscountForm.php index 13040fa94..b0f088b75 100644 --- a/app/AdminModule/ConfigurationModule/forms/DiscountForm.php +++ b/app/AdminModule/ConfigurationModule/forms/DiscountForm.php @@ -34,7 +34,6 @@ class DiscountForm extends UI\Control * Událost při uložení formuláře. */ public $onSave; - /** * Událost při chybě podmínky. */ @@ -148,8 +147,7 @@ public function processForm(Form $form, \stdClass $values) $this->discountRepository->save($this->discount); $this->onSave($this); - } - else + } else $this->onConditionError($this); } } diff --git a/app/AdminModule/ConfigurationModule/forms/MailingForm.php b/app/AdminModule/ConfigurationModule/forms/MailingForm.php index 53748d7d6..c348123c2 100644 --- a/app/AdminModule/ConfigurationModule/forms/MailingForm.php +++ b/app/AdminModule/ConfigurationModule/forms/MailingForm.php @@ -10,7 +10,6 @@ use App\Model\User\User; use App\Model\User\UserRepository; use App\Services\MailService; -use Doctrine\Common\Collections\ArrayCollection; use Nette; use Nette\Application\LinkGenerator; use Nette\Application\UI\Form; @@ -68,6 +67,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo * Vytvoří formulář. * @param $id * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create($id) { @@ -98,6 +98,10 @@ public function create($id) * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws Nette\Application\UI\InvalidLinkException + * @throws \App\Model\Settings\SettingsException + * @throws \Ublaboo\Mailing\Exception\MailingException + * @throws \Ublaboo\Mailing\Exception\MailingMailCreationException */ public function processForm(Form $form, \stdClass $values) { @@ -109,7 +113,7 @@ public function processForm(Form $form, \stdClass $values) $link = $this->linkGenerator->link('Action:Mailing:verify', ['code' => $verificationCode]); - $this->mailService->sendMailFromTemplate(new ArrayCollection(), new ArrayCollection(), $values['seminarEmail'], + $this->mailService->sendMailFromTemplate(NULL, $values['seminarEmail'], Template::EMAIL_VERIFICATION, [ TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME), TemplateVariable::EMAIL_VERIFICATION_LINK => $link], diff --git a/app/AdminModule/ConfigurationModule/forms/PaymentForm.php b/app/AdminModule/ConfigurationModule/forms/PaymentForm.php index cdcb682f7..918919536 100644 --- a/app/AdminModule/ConfigurationModule/forms/PaymentForm.php +++ b/app/AdminModule/ConfigurationModule/forms/PaymentForm.php @@ -19,14 +19,14 @@ */ class PaymentForm extends UI\Control { - /** @var BaseForm */ - private $baseFormFactory; - /** * Událost při uložení formuláře. */ public $onSave; + /** @var BaseForm */ + private $baseFormFactory; + /** @var SettingsRepository */ private $settingsRepository; @@ -61,6 +61,7 @@ public function render() /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function createComponentForm() { @@ -137,11 +138,12 @@ public function createComponentForm() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { $this->settingsRepository->setValue(Settings::ACCOUNT_NUMBER, $values['accountNumber']); - $this->settingsRepository->setValue(Settings::VARIABLE_SYMBOL_CODE, $values['variableSymbolCode']); + $this->settingsRepository->setValue(Settings::VARIABLE_SYMBOL_CODE, $values['variableSymbolCode']); $this->settingsRepository->setValue(Settings::MATURITY_TYPE, $values['maturityType']); if (array_key_exists('maturityDate', $values)) diff --git a/app/AdminModule/ConfigurationModule/forms/PaymentProofForm.php b/app/AdminModule/ConfigurationModule/forms/PaymentProofForm.php index 3cc5a5060..2cc958d74 100644 --- a/app/AdminModule/ConfigurationModule/forms/PaymentProofForm.php +++ b/app/AdminModule/ConfigurationModule/forms/PaymentProofForm.php @@ -38,6 +38,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -78,6 +79,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/PlaceDescriptionForm.php b/app/AdminModule/ConfigurationModule/forms/PlaceDescriptionForm.php index b98777620..606a0108e 100644 --- a/app/AdminModule/ConfigurationModule/forms/PlaceDescriptionForm.php +++ b/app/AdminModule/ConfigurationModule/forms/PlaceDescriptionForm.php @@ -37,6 +37,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -61,6 +62,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/ProgramForm.php b/app/AdminModule/ConfigurationModule/forms/ProgramForm.php index 073d56a9e..b3bb93ea5 100644 --- a/app/AdminModule/ConfigurationModule/forms/ProgramForm.php +++ b/app/AdminModule/ConfigurationModule/forms/ProgramForm.php @@ -45,6 +45,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -100,6 +101,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/SeminarForm.php b/app/AdminModule/ConfigurationModule/forms/SeminarForm.php index 25db7e897..9f69258e8 100644 --- a/app/AdminModule/ConfigurationModule/forms/SeminarForm.php +++ b/app/AdminModule/ConfigurationModule/forms/SeminarForm.php @@ -45,6 +45,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -88,6 +89,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/SkautIsEventForm.php b/app/AdminModule/ConfigurationModule/forms/SkautIsEventForm.php index a3edceed4..397c75dfb 100644 --- a/app/AdminModule/ConfigurationModule/forms/SkautIsEventForm.php +++ b/app/AdminModule/ConfigurationModule/forms/SkautIsEventForm.php @@ -8,7 +8,6 @@ use App\Model\Settings\SettingsRepository; use App\Services\SkautIsEventEducationService; use App\Services\SkautIsEventGeneralService; -use App\Services\SkautIsService; use Nette; use Nette\Application\UI\Form; @@ -27,9 +26,6 @@ class SkautIsEventForm extends Nette\Object /** @var SettingsRepository */ private $settingsRepository; - /** @var SkautIsService */ - private $skautIsService; - /** @var SkautIsEventGeneralService */ private $skautIsEventGeneralService; @@ -41,7 +37,8 @@ class SkautIsEventForm extends Nette\Object * SkautIsEventForm constructor. * @param BaseForm $baseForm * @param SettingsRepository $settingsRepository - * @param SkautIsService $skautIsService + * @param SkautIsEventGeneralService $skautIsEventGeneralService + * @param SkautIsEventEducationService $skautIsEventEducationService */ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepository, SkautIsEventGeneralService $skautIsEventGeneralService, @@ -56,6 +53,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -95,6 +93,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { @@ -102,7 +101,7 @@ public function processForm(Form $form, \stdClass $values) $eventName = NULL; $eventType = $values['skautisEventType']; - switch($eventType) { + switch ($eventType) { case SkautIsEventType::GENERAL: $eventId = $values['skautisEventGeneral']; $eventName = $this->skautIsEventGeneralService->getEventDisplayName($eventId); diff --git a/app/AdminModule/ConfigurationModule/forms/SubeventForm.php b/app/AdminModule/ConfigurationModule/forms/SubeventForm.php index dc8add933..d57605e18 100644 --- a/app/AdminModule/ConfigurationModule/forms/SubeventForm.php +++ b/app/AdminModule/ConfigurationModule/forms/SubeventForm.php @@ -43,6 +43,7 @@ public function __construct(BaseForm $baseFormFactory, SubeventRepository $subev * Vytvoří formulář. * @param $id * @return Form + * @throws \Doctrine\ORM\NonUniqueResultException */ public function create($id) { @@ -71,8 +72,7 @@ public function create($id) ->addRule(Form::MIN, 'admin.configuration.subevents_capacity_low', $this->subeventRepository->countApprovedUsersInSubevent($this->subevent)); $subeventsOptions = $this->subeventRepository->getSubeventsWithoutSubeventOptions($this->subevent->getId()); - } - else { + } else { $nameText->addRule(Form::IS_NOT_IN, 'admin.configuration.subevents_name_exists', $this->subeventRepository->findAllNames()); $capacityText ->addCondition(Form::FILLED) @@ -83,7 +83,6 @@ public function create($id) } - $incompatibleSubeventsSelect = $form->addMultiSelect('incompatibleSubevents', 'admin.configuration.subevents_incompatible_subevents', $subeventsOptions); $requiredSubeventsSelect = $form->addMultiSelect('requiredSubevents', 'admin.configuration.subevents_required_subevents', $subeventsOptions); @@ -149,6 +148,7 @@ public function processForm(Form $form, \stdClass $values) * @param $field * @param $args * @return bool + * @throws \Doctrine\DBAL\ConnectionException */ public function validateIncompatibleAndRequiredCollision($field, $args) { @@ -159,8 +159,7 @@ public function validateIncompatibleAndRequiredCollision($field, $args) if ($this->subevent) { $editedSubevent = $this->subevent; - } - else { + } else { $editedSubevent = new Subevent(); $editedSubevent->setName(md5(mt_rand())); $this->subeventRepository->save($editedSubevent); diff --git a/app/AdminModule/ConfigurationModule/forms/SubeventsForm.php b/app/AdminModule/ConfigurationModule/forms/SubeventsForm.php index de180eb85..debddc502 100644 --- a/app/AdminModule/ConfigurationModule/forms/SubeventsForm.php +++ b/app/AdminModule/ConfigurationModule/forms/SubeventsForm.php @@ -37,6 +37,7 @@ public function __construct(BaseForm $baseForm, SettingsRepository $settingsRepo /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -59,6 +60,7 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/WebForm.php b/app/AdminModule/ConfigurationModule/forms/WebForm.php index 1aa9121de..3ecc89fa6 100644 --- a/app/AdminModule/ConfigurationModule/forms/WebForm.php +++ b/app/AdminModule/ConfigurationModule/forms/WebForm.php @@ -52,6 +52,7 @@ public function __construct(BaseForm $baseFormFactory, PageRepository $pageRepos /** * Vytvoří formulář. * @return Form + * @throws \App\Model\Settings\SettingsException */ public function create() { @@ -87,6 +88,8 @@ public function create() * Zpracuje formulář. * @param Form $form * @param \stdClass $values + * @throws Nette\Utils\UnknownImageFileException + * @throws \App\Model\Settings\SettingsException */ public function processForm(Form $form, \stdClass $values) { diff --git a/app/AdminModule/ConfigurationModule/forms/templates/discount_form.latte b/app/AdminModule/ConfigurationModule/forms/templates/discount_form.latte index 05a9fccd7..19d9f8bf8 100644 --- a/app/AdminModule/ConfigurationModule/forms/templates/discount_form.latte +++ b/app/AdminModule/ConfigurationModule/forms/templates/discount_form.latte @@ -40,7 +40,7 @@ buttonAnd.on('click', function () { condition.val(condition.val() + 'and|'); - conditionText.val(conditionText.val() + ' ' + {_common.condition_operator.and} + ' '); + conditionText.val(conditionText.val() + ' ' + {_common.condition_operator.and} +' '); buttonSubevent.removeClass('disabled'); buttonAnd.addClass('disabled'); @@ -51,7 +51,7 @@ buttonOr.on('click', function () { condition.val(condition.val() + 'or|'); - conditionText.val(conditionText.val() + ' ' + {_common.condition_operator.or} + ' '); + conditionText.val(conditionText.val() + ' ' + {_common.condition_operator.or} +' '); buttonSubevent.removeClass('disabled'); buttonAnd.addClass('disabled'); @@ -134,7 +134,8 @@