diff --git a/.env b/.env index d293315..ef0afda 100644 --- a/.env +++ b/.env @@ -19,6 +19,6 @@ MAILER_SENDER=noreply@vision # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml # # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4" -DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8" +DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4" +# DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8" ###< doctrine/doctrine-bundle ### \ No newline at end of file diff --git a/config/packages/security.yaml b/config/packages/security.yaml index dd72fe7..939219f 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -43,6 +43,7 @@ security: - { path: ^/verify/password, roles: PUBLIC_ACCESS } - { path: ^/reset-password, roles: PUBLIC_ACCESS } - { path: ^/share, roles: PUBLIC_ACCESS } + - { path: ^/wanted, roles: PUBLIC_ACCESS } - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/directory/history, roles: ROLE_ADMIN } - { path: ^/, roles: IS_AUTHENTICATED_REMEMBERED } #IS_AUTHENTICATED_REMEMBERED= user is logged, with form or with cookie diff --git a/migrations/Version20221031135251.php b/migrations/Version20221031135251.php new file mode 100644 index 0000000..18a900f --- /dev/null +++ b/migrations/Version20221031135251.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE directory ADD wanted_public_display TINYINT(1) DEFAULT \'0\' NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE directory DROP wanted_public_display'); + } +} diff --git a/src/Controller/GroupController.php b/src/Controller/GroupController.php index 0ef6987..a4e09c5 100644 --- a/src/Controller/GroupController.php +++ b/src/Controller/GroupController.php @@ -85,7 +85,8 @@ class GroupController extends AbstractController } if ( - $User->getMainRank()->getPower() >= $currentUser->getMainRank()->getPower() + null != $User->getMainRank() + && $User->getMainRank()->getPower() >= $currentUser->getMainRank()->getPower() && !$currentUser->getAdminMode() ) { $this->addFlash('danger', 'alert_error_cant_fire_superior_or_same_rank'); diff --git a/src/Controller/WantedController.php b/src/Controller/WantedController.php new file mode 100644 index 0000000..89ae1d3 --- /dev/null +++ b/src/Controller/WantedController.php @@ -0,0 +1,22 @@ +render('wanted/index.html.twig', [ + 'controller_name' => 'WantedController', + 'wanted' => + $DirectoryRepository->list()->notDead()->wanted()->wantedPublicDisplay()->getResult(), + 'shared' => true + ]); + } +} diff --git a/src/Entity/Directory.php b/src/Entity/Directory.php index 4410629..c923730 100644 --- a/src/Entity/Directory.php +++ b/src/Entity/Directory.php @@ -421,6 +421,12 @@ class Directory */ private $wantedDisplay = true; + /** + * @ORM\Column(type="boolean", options={"default":"0"}) + * @Gedmo\Versioned + */ + private $wantedPublicDisplay = false; + /** * @ORM\OneToMany(targetEntity=Infringement::class, mappedBy="directory", orphanRemoval=true) * @ORM\OrderBy({"createdAt" = "DESC"}) @@ -709,9 +715,9 @@ class Directory } /** - * - * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $backImageFile - */ + * + * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $backImageFile + */ public function setBackImageFile(?File $backImageFile = null): void { $this->backImageFile = $backImageFile; @@ -748,7 +754,7 @@ class Directory return $this->backImageSize; } -/** + /** * * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $leftImageFile */ @@ -1358,6 +1364,18 @@ class Directory return $this; } + public function getWantedPublicDisplay(): ?bool + { + return $this->wantedPublicDisplay; + } + + public function setWantedPublicDisplay(bool $wantedPublicDisplay): self + { + $this->wantedPublicDisplay = $wantedPublicDisplay; + + return $this; + } + /** * @return Collection|Infringement[] */ diff --git a/src/Form/DirectoryType.php b/src/Form/DirectoryType.php index b098dde..7e64dee 100644 --- a/src/Form/DirectoryType.php +++ b/src/Form/DirectoryType.php @@ -68,6 +68,7 @@ class DirectoryType extends AbstractType ->add('wanted', null, ['label' => 'form_label_wanted']) ->add('wantedReason', null, ['label' => 'form_label_wantedReason', 'help' => 'form_help_wantedReason']) ->add('wantedDisplay', null, ['label' => 'form_label_wantedDisplay']) + ->add('wantedPublicDisplay', null, ['label' => 'form_label_wantedPublicDisplay']) ; } diff --git a/src/Repository/DirectoryRepository.php b/src/Repository/DirectoryRepository.php index 278a697..1a3a9ca 100644 --- a/src/Repository/DirectoryRepository.php +++ b/src/Repository/DirectoryRepository.php @@ -83,6 +83,12 @@ class DirectoryRepository extends ServiceEntityRepository return $this; } + public function wantedPublicDisplay() + { + $this->qb->andWhere('d.wantedPublicDisplay = 1'); + return $this; + } + public function wantedNotDisplay() { $this->qb->andWhere('d.wantedDisplay = 0'); diff --git a/templates/wanted/index.html.twig b/templates/wanted/index.html.twig new file mode 100644 index 0000000..e056f7f --- /dev/null +++ b/templates/wanted/index.html.twig @@ -0,0 +1,34 @@ +{% extends 'base.html.twig' %} + +{% block title %}{% trans %}title_wanted{% endtrans %}{% endblock %} + +{% block body %} + {% if wanted %} +