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/Model.php | 17 ++++++- src/model/entities/Email.php | 90 +++++++++++++++++++++++++++++++++--- src/model/entities/Node.php | 37 +-------------- src/model/entities/NodeData.php | 10 ++++ src/model/entities/NodeDataAsset.php | 1 - 5 files changed, 110 insertions(+), 45 deletions(-) (limited to 'src/model') diff --git a/src/model/Model.php b/src/model/Model.php index b650183..de391ff 100644 --- a/src/model/Model.php +++ b/src/model/Model.php @@ -58,11 +58,16 @@ class Model ->setParameter('page', $this->page) ->getResult(); - // groupes d'articles triés par bloc, permet de paginer par bloc foreach($bulk_data as $parent_block){ + // groupes d'articles triés par bloc, permet de paginer par bloc if(Blocks::hasPresentation($parent_block->getName())){ // = post_block ou news_block $bulk_data = array_merge($bulk_data, $this->getNextArticles($parent_block, $request)[0]); } + + // emails + if($parent_block->getName() === 'show_emails'){ + $parent_block->getNodeData()->setEmails($this->getAllEmails()); + } } } else{ // page "article" @@ -283,4 +288,14 @@ class Model $this->node->addChild($child); } } + + private function getAllEmails(): array + { + $dql = 'SELECT e FROM App\Entity\Email e'; + return $this->entityManager + ->createQuery($dql) + //->setParameter('page', $this->page) + ->getResult(); + } + //private function getEmails(string $sender): array } 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 diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index fe3a1e5..71c159d 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -72,42 +72,7 @@ class Node { $this->name_node = $name; }*/ - - /*public function getAttributes(): array - { - return $this->attributes; - } - public function setDefaultAttributes(array $attributes): void - { - $this->attributes = $attributes; - } - public function useDefaultAttributes(): void - { - $this->attributes = self::$default_attributes; - } - public function addAttribute(string $key, string $value): void - { - if(!isset($this->attributes[$key])) { // sécurité $key inexistante - $this->attributes[$key] = []; - } - if(!in_array($value, $this->attributes[$key])){ - $this->attributes[$key][] = $value; - } - }*/ - /*public function removeAttribute(string $key, string $value): void - { - if(isset($this->attributes[$key])) // sécurité $key inexistante - { - // supprime et réindex avec un nouveau tableau - $tmp_array = $this->attributes[$key]; - $this->attributes[$key] = []; - foreach($tmp_array as $entry){ - if($entry !== $value){ - $this->attributes[$key][] = $entry; - } - } - } - }*/ + public function getParent(): ?self { return $this->parent; diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index b25b540..19670fe 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php @@ -45,6 +45,7 @@ class NodeData private Collection $nda_collection; private int $nb_pages = 1; + private array $emails = []; // noeud show_emails uniquement public function __construct(array $data, Node $node, Collection $nda_collection = new ArrayCollection, ?string $presentation = null, ?bool $chrono_order = null) { @@ -179,4 +180,13 @@ class NodeData $this->new_nda = new NodeDataAsset($this, $asset, $role); $this->addNodeDataAsset($this->new_nda); }*/ + + public function getEmails(): array + { + return $this->emails; + } + public function setEmails(array $emails): void + { + $this->emails = $emails; + } } \ No newline at end of file diff --git a/src/model/entities/NodeDataAsset.php b/src/model/entities/NodeDataAsset.php index 7f92fd1..d5eb141 100644 --- a/src/model/entities/NodeDataAsset.php +++ b/src/model/entities/NodeDataAsset.php @@ -15,7 +15,6 @@ use Doctrine\ORM\Mapping as ORM; class NodeDataAsset { // clé primaire double - // inconvénient: impossible d'utiliser deux fois la même paire node_data/asset, même pour des rôles différents #[ORM\Id] #[ORM\ManyToOne(targetEntity: NodeData::class, inversedBy: 'nda_collection')] #[ORM\JoinColumn(name: 'node_data_id', referencedColumnName: 'id_node_data', onDelete: 'CASCADE')] -- cgit v1.2.3