diff options
Diffstat (limited to 'src/model/entities/Email.php')
| -rw-r--r-- | src/model/entities/Email.php | 90 |
1 files changed, 83 insertions, 7 deletions
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; | |||
| 11 | #[ORM\Table(name: TABLE_PREFIX . "email")] | 11 | #[ORM\Table(name: TABLE_PREFIX . "email")] |
| 12 | class Email | 12 | class Email |
| 13 | { | 13 | { |
| 14 | // en mois | ||
| 15 | const LEGAL_RETENTION_PERIOD = 36; // 3 ans, justification = prospection, durée "glissante", date de suppression remise à jour à chaque nouvel e-mail | ||
| 16 | const LEGAL_RETENTION_PERIOD_SENSITIVE = 60; // 5 ans pour données sensibles ou litige, durée de preuve légale, durée non glissante | ||
| 17 | |||
| 14 | #[ORM\Id] | 18 | #[ORM\Id] |
| 15 | #[ORM\GeneratedValue] | 19 | #[ORM\GeneratedValue] |
| 16 | #[ORM\Column(type: "integer")] | 20 | #[ORM\Column(type: "integer")] |
| 17 | private int $id_log; | 21 | private int $id_email; |
| 22 | |||
| 23 | #[ORM\Column(type: "string", length: 255)] | ||
| 24 | private string $sender_name; | ||
| 18 | 25 | ||
| 19 | #[ORM\Column(type: "string", length: 320)] | 26 | #[ORM\Column(type: "string", length: 320)] |
| 20 | private string $sender; | 27 | private string $sender_address; |
| 21 | 28 | ||
| 22 | #[ORM\Column(type: "string", length: 320)] | 29 | #[ORM\Column(type: "string", length: 320)] |
| 23 | private string $recipient; | 30 | private string $recipient; |
| @@ -30,12 +37,81 @@ class Email | |||
| 30 | private string $content; | 37 | private string $content; |
| 31 | 38 | ||
| 32 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] | 39 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] |
| 33 | private ?\DateTime $date_time ; | 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; | ||
| 34 | 50 | ||
| 35 | public function __construct(string $sender, string $recipient, string $content){ | 51 | public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, bool $sensitive = false){ |
| 36 | $this->sender = strtolower($sender); | 52 | $this->sender_name = strtolower($sender_name); |
| 53 | $this->sender_address = strtolower($sender_address); | ||
| 37 | $this->recipient = strtolower($recipient); | 54 | $this->recipient = strtolower($recipient); |
| 38 | $this->content = $content; | 55 | $this->content = $content; |
| 39 | $this->date_time = new \DateTime(); | 56 | $this->date_time = new \DateTime; |
| 57 | $this->last_contact_date = new \DateTime; | ||
| 58 | $this->makeSensitive($sensitive); | ||
| 59 | } | ||
| 60 | |||
| 61 | public function getId(): int | ||
| 62 | { | ||
| 63 | return $this->id_email; | ||
| 64 | } | ||
| 65 | public function getSenderName(): string | ||
| 66 | { | ||
| 67 | return $this->sender_name; | ||
| 68 | } | ||
| 69 | public function getSenderAddress(): string | ||
| 70 | { | ||
| 71 | return $this->sender_address; | ||
| 72 | } | ||
| 73 | public function getRecipient(): string | ||
| 74 | { | ||
| 75 | return $this->recipient; | ||
| 76 | } | ||
| 77 | public function getContent(): string | ||
| 78 | { | ||
| 79 | return $this->content; | ||
| 80 | } | ||
| 81 | public function getDateTime(): \DateTime | ||
| 82 | { | ||
| 83 | return $this->date_time; | ||
| 84 | } | ||
| 85 | /*public function getLastContactDate(): \DateTime | ||
| 86 | { | ||
| 87 | return $this->last_contact_date; | ||
| 88 | }*/ | ||
| 89 | public function isSensitive(): bool | ||
| 90 | { | ||
| 91 | return $this->is_sensitive; | ||
| 92 | } | ||
| 93 | public function isSensitiveSince(): ?\DateTime | ||
| 94 | { | ||
| 95 | return $this->is_sensitive_since; | ||
| 96 | } | ||
| 97 | |||
| 98 | public function makeSensitive(bool $sensitive = true): void | ||
| 99 | { | ||
| 100 | $this->is_sensitive = $sensitive; | ||
| 101 | if($sensitive && $this->is_sensitive_since === null){ | ||
| 102 | $this->is_sensitive_since = new \DateTime(); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | public function updateLastContactDate(): void | ||
| 107 | { | ||
| 108 | $this->last_contact_date = new \DateTime; | ||
| 109 | } | ||
| 110 | |||
| 111 | public function getDeletionDate(): \DateTime | ||
| 112 | { | ||
| 113 | return $this->is_sensitive // oui durée 5 ans, non durée 3 ans "glissante" | ||
| 114 | ? (clone $this->is_sensitive_since)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD_SENSITIVE . ' month') // erreur si vrai mais sans date (pas censé arriver) | ||
| 115 | : (clone $this->last_contact_date)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD . ' month'); | ||
| 40 | } | 116 | } |
| 41 | } | 117 | } \ No newline at end of file |
