diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
| commit | f27cca08ff786ceff1870147f6d6bad14d71117f (patch) | |
| tree | d36597a72025313d6faf4ed228755fa267ebe2f6 /src/model/entities/Email.php | |
| parent | c7309f900ef05bd5cb313110ec159b761af394ec (diff) | |
| download | cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2 cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip | |
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
Diffstat (limited to 'src/model/entities/Email.php')
| -rw-r--r-- | src/model/entities/Email.php | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/src/model/entities/Email.php b/src/model/entities/Email.php deleted file mode 100644 index 60fcc1f..0000000 --- a/src/model/entities/Email.php +++ /dev/null | |||
| @@ -1,131 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/entities/Email.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | namespace App\Entity; | ||
| 7 | |||
| 8 | use Doctrine\ORM\Mapping as ORM; | ||
| 9 | |||
| 10 | #[ORM\Entity] | ||
| 11 | #[ORM\Table(name: TABLE_PREFIX . "email")] | ||
| 12 | class Email | ||
| 13 | { | ||
| 14 | // en mois | ||
| 15 | const DEFAULT_RETENTION_PERIOD = 36; // 3 ans, justification = prospection, durée "glissante", date de suppression remise à jour à chaque nouvel e-mail | ||
| 16 | const DEFAULT_RETENTION_PERIOD_SENSITIVE = 60; // 5 ans pour données sensibles ou litige, durée de preuve légale, durée non glissante | ||
| 17 | |||
| 18 | #[ORM\Id] | ||
| 19 | #[ORM\GeneratedValue] | ||
| 20 | #[ORM\Column(type: "integer")] | ||
| 21 | private int $id_email; | ||
| 22 | |||
| 23 | #[ORM\Column(type: "string", length: 255)] | ||
| 24 | private string $sender_name; | ||
| 25 | |||
| 26 | #[ORM\Column(type: "string", length: 320)] | ||
| 27 | private string $sender_address; | ||
| 28 | |||
| 29 | #[ORM\Column(type: "string", length: 320)] | ||
| 30 | private string $recipient; | ||
| 31 | |||
| 32 | // inutile, objet = 'Message envoyé par ' . $name . ' (' . $email . ') depuis le site web' | ||
| 33 | /*#[ORM\Column(type: "text")] | ||
| 34 | private string $subject;*/ | ||
| 35 | |||
| 36 | #[ORM\Column(type: "text")] | ||
| 37 | private string $content; | ||
| 38 | |||
| 39 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] | ||
| 40 | private \DateTime $date_time; | ||
| 41 | |||
| 42 | #[ORM\Column(type: 'boolean')] | ||
| 43 | private bool $is_sensitive; // "sensitive" tout court est un mot réservé | ||
| 44 | |||
| 45 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] | ||
| 46 | private \DateTime $last_contact_date; | ||
| 47 | |||
| 48 | #[ORM\Column(type: 'datetime', nullable: true)] | ||
| 49 | private ?\DateTime $is_sensitive_since; | ||
| 50 | |||
| 51 | #[ORM\ManyToOne(targetEntity: EmailForm::class)] | ||
| 52 | #[ORM\JoinColumn(name: "email_form_id", referencedColumnName: "id_email_form", nullable: true)] | ||
| 53 | private ?EmailForm $email_form; | ||
| 54 | |||
| 55 | public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, EmailForm $email_form, bool $sensitive = false){ | ||
| 56 | $this->sender_name = strtolower($sender_name); | ||
| 57 | $this->sender_address = strtolower($sender_address); | ||
| 58 | $this->recipient = strtolower($recipient); | ||
| 59 | $this->content = $content; | ||
| 60 | $this->date_time = new \DateTime; | ||
| 61 | $this->last_contact_date = new \DateTime; | ||
| 62 | $this->email_form = $email_form; | ||
| 63 | $this->makeSensitive($sensitive); | ||
| 64 | } | ||
| 65 | |||
| 66 | public function getId(): int | ||
| 67 | { | ||
| 68 | return $this->id_email; | ||
| 69 | } | ||
| 70 | public function getSenderName(): string | ||
| 71 | { | ||
| 72 | return $this->sender_name; | ||
| 73 | } | ||
| 74 | public function getSenderAddress(): string | ||
| 75 | { | ||
| 76 | return $this->sender_address; | ||
| 77 | } | ||
| 78 | public function getRecipient(): string | ||
| 79 | { | ||
| 80 | return $this->recipient; | ||
| 81 | } | ||
| 82 | public function getContent(): string | ||
| 83 | { | ||
| 84 | return $this->content; | ||
| 85 | } | ||
| 86 | public function getDateTime(): \DateTime | ||
| 87 | { | ||
| 88 | return $this->date_time; | ||
| 89 | } | ||
| 90 | /*public function getLastContactDate(): \DateTime | ||
| 91 | { | ||
| 92 | return $this->last_contact_date; | ||
| 93 | }*/ | ||
| 94 | public function isSensitive(): bool | ||
| 95 | { | ||
| 96 | return $this->is_sensitive; | ||
| 97 | } | ||
| 98 | public function isSensitiveSince(): ?\DateTime | ||
| 99 | { | ||
| 100 | return $this->is_sensitive_since; | ||
| 101 | } | ||
| 102 | |||
| 103 | public function makeSensitive(bool $sensitive = true): void | ||
| 104 | { | ||
| 105 | $this->is_sensitive = $sensitive; | ||
| 106 | if($sensitive && $this->is_sensitive_since === null){ | ||
| 107 | $this->is_sensitive_since = new \DateTime(); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | public function updateLastContactDate(): void | ||
| 112 | { | ||
| 113 | $this->last_contact_date = new \DateTime; | ||
| 114 | } | ||
| 115 | |||
| 116 | public function getDeletionDate(): \DateTime // utilise une durée de conservation $period qui est propre au bloc formulaire (à son EmailForm) | ||
| 117 | { | ||
| 118 | // tests appliqués: | ||
| 119 | // => e-mail associé à un formulaire? | ||
| 120 | // => ce formulaire dispose d'une durée de stockage spécifique? | ||
| 121 | // => cette donnée est un entier > 0 | ||
| 122 | $key = $this->is_sensitive ? 'retention_period_sensible' : 'retention_period'; | ||
| 123 | $period = $this->email_form ? (int)($this->email_form->getData()[$key] ?? null) : null; | ||
| 124 | |||
| 125 | $default = $this->is_sensitive ? self::DEFAULT_RETENTION_PERIOD_SENSITIVE : self::DEFAULT_RETENTION_PERIOD; | ||
| 126 | $period = ($period === null || $period <= 0) ? $default : $period; | ||
| 127 | |||
| 128 | $date = clone ($this->is_sensitive ? $this->is_sensitive_since : $this->last_contact_date); // erreur si "sensible" mais sans date disponible (pas censé arriver) | ||
| 129 | return $date->modify('+ ' . (string)$period . ' month'); | ||
| 130 | } | ||
| 131 | } \ No newline at end of file | ||
