diff --git a/src/Bundle/ChillMainBundle/Entity/UserGroup.php b/src/Bundle/ChillMainBundle/Entity/UserGroup.php index b39216b11..d720d4ffc 100644 --- a/src/Bundle/ChillMainBundle/Entity/UserGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/UserGroup.php @@ -19,6 +19,7 @@ use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; +use Symfony\Component\Validator\Constraints as Assert; #[ORM\Entity] #[ORM\Table(name: 'chill_main_user_group')] @@ -66,6 +67,10 @@ class UserGroup #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $excludeKey = ''; + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] + #[Assert\Email] + private string $email = ''; + public function __construct() { $this->adminUsers = new ArrayCollection(); @@ -187,6 +192,23 @@ class UserGroup return $this; } + public function getEmail(): string + { + return $this->email; + } + + public function setEmail(string $email): self + { + $this->email = $email; + + return $this; + } + + public function hasEmail(): bool + { + return '' !== $this->email; + } + /** * Checks if the current object is an instance of the UserGroup class. * diff --git a/src/Bundle/ChillMainBundle/Form/UserGroupType.php b/src/Bundle/ChillMainBundle/Form/UserGroupType.php index 8a4685c7c..3f98907fa 100644 --- a/src/Bundle/ChillMainBundle/Form/UserGroupType.php +++ b/src/Bundle/ChillMainBundle/Form/UserGroupType.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ColorType; +use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; @@ -34,6 +35,11 @@ class UserGroupType extends AbstractType ->add('foregroundColor', ColorType::class, [ 'label' => 'user_group.ForegroundColor', ]) + ->add('email', EmailType::class, [ + 'label' => 'user_group.Email', + 'help' => 'user_group.EmailHelp', + 'empty_data' => '', + ]) ->add('excludeKey', TextType::class, [ 'label' => 'user_group.ExcludeKey', 'help' => 'user_group.ExcludeKeyHelp', diff --git a/src/Bundle/ChillMainBundle/migrations/Version20241015142142.php b/src/Bundle/ChillMainBundle/migrations/Version20241015142142.php new file mode 100644 index 000000000..c4367a05d --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20241015142142.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_main_user_group ADD email TEXT DEFAULT \'\' NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_user_group DROP COLUMN email'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index bce38cb76..51b263095 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -69,6 +69,8 @@ user_group: me_only: Uniquement moi me: Moi append_users: Ajouter des utilisateurs + Email: Adresse email du groupe + EmailHelp: Si rempli, des notifications supplémentaires seront envoyées à l'adresse email du groupe (workflow en attente, etc.) inactive: inactif