From 423755b019a09111b971e36c53e2557e2f5a704f Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 16 Dec 2025 22:41:57 +0100 Subject: page emails, application du RGPD: table email et nettoyeur, renommage de $id_email --- src/model/entities/Email.php | 90 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 7 deletions(-) (limited to 'src/model/entities/Email.php') diff --git a/src/model/entities/Email.php b/src/model/entities/Email.php index 9d87f1f..c66625f 100644 --- a/src/model/entities/Email.php +++ b/src/model/entities/Email.php @@ -11,13 +11,20 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: TABLE_PREFIX . "email")] class Email { + // en mois + const LEGAL_RETENTION_PERIOD = 36; // 3 ans, justification = prospection, durée "glissante", date de suppression remise à jour à chaque nouvel e-mail + const LEGAL_RETENTION_PERIOD_SENSITIVE = 60; // 5 ans pour données sensibles ou litige, durée de preuve légale, durée non glissante + #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: "integer")] - private int $id_log; + private int $id_email; + + #[ORM\Column(type: "string", length: 255)] + private string $sender_name; #[ORM\Column(type: "string", length: 320)] - private string $sender; + private string $sender_address; #[ORM\Column(type: "string", length: 320)] private string $recipient; @@ -30,12 +37,81 @@ class Email private string $content; #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] - private ?\DateTime $date_time ; + private \DateTime $date_time; + + #[ORM\Column(type: 'boolean')] + private bool $is_sensitive; // "sensitive" tout court est un mot réservé + + #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] + private \DateTime $last_contact_date; + + #[ORM\Column(type: 'datetime', nullable: true)] + private ?\DateTime $is_sensitive_since; - public function __construct(string $sender, string $recipient, string $content){ - $this->sender = strtolower($sender); + public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, bool $sensitive = false){ + $this->sender_name = strtolower($sender_name); + $this->sender_address = strtolower($sender_address); $this->recipient = strtolower($recipient); $this->content = $content; - $this->date_time = new \DateTime(); + $this->date_time = new \DateTime; + $this->last_contact_date = new \DateTime; + $this->makeSensitive($sensitive); + } + + public function getId(): int + { + return $this->id_email; + } + public function getSenderName(): string + { + return $this->sender_name; + } + public function getSenderAddress(): string + { + return $this->sender_address; + } + public function getRecipient(): string + { + return $this->recipient; + } + public function getContent(): string + { + return $this->content; + } + public function getDateTime(): \DateTime + { + return $this->date_time; + } + /*public function getLastContactDate(): \DateTime + { + return $this->last_contact_date; + }*/ + public function isSensitive(): bool + { + return $this->is_sensitive; + } + public function isSensitiveSince(): ?\DateTime + { + return $this->is_sensitive_since; + } + + public function makeSensitive(bool $sensitive = true): void + { + $this->is_sensitive = $sensitive; + if($sensitive && $this->is_sensitive_since === null){ + $this->is_sensitive_since = new \DateTime(); + } + } + + public function updateLastContactDate(): void + { + $this->last_contact_date = new \DateTime; + } + + public function getDeletionDate(): \DateTime + { + return $this->is_sensitive // oui durée 5 ans, non durée 3 ans "glissante" + ? (clone $this->is_sensitive_since)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD_SENSITIVE . ' month') // erreur si vrai mais sans date (pas censé arriver) + : (clone $this->last_contact_date)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD . ' month'); } -} +} \ No newline at end of file -- cgit v1.2.3