aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/Model.php17
-rw-r--r--src/model/entities/Email.php90
-rw-r--r--src/model/entities/Node.php37
-rw-r--r--src/model/entities/NodeData.php10
-rw-r--r--src/model/entities/NodeDataAsset.php1
5 files changed, 110 insertions, 45 deletions
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
58 ->setParameter('page', $this->page) 58 ->setParameter('page', $this->page)
59 ->getResult(); 59 ->getResult();
60 60
61 // groupes d'articles triés par bloc, permet de paginer par bloc
62 foreach($bulk_data as $parent_block){ 61 foreach($bulk_data as $parent_block){
62 // groupes d'articles triés par bloc, permet de paginer par bloc
63 if(Blocks::hasPresentation($parent_block->getName())){ // = post_block ou news_block 63 if(Blocks::hasPresentation($parent_block->getName())){ // = post_block ou news_block
64 $bulk_data = array_merge($bulk_data, $this->getNextArticles($parent_block, $request)[0]); 64 $bulk_data = array_merge($bulk_data, $this->getNextArticles($parent_block, $request)[0]);
65 } 65 }
66
67 // emails
68 if($parent_block->getName() === 'show_emails'){
69 $parent_block->getNodeData()->setEmails($this->getAllEmails());
70 }
66 } 71 }
67 } 72 }
68 else{ // page "article" 73 else{ // page "article"
@@ -283,4 +288,14 @@ class Model
283 $this->node->addChild($child); 288 $this->node->addChild($child);
284 } 289 }
285 } 290 }
291
292 private function getAllEmails(): array
293 {
294 $dql = 'SELECT e FROM App\Entity\Email e';
295 return $this->entityManager
296 ->createQuery($dql)
297 //->setParameter('page', $this->page)
298 ->getResult();
299 }
300 //private function getEmails(string $sender): array
286} 301}
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")]
12class Email 12class 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
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
72 { 72 {
73 $this->name_node = $name; 73 $this->name_node = $name;
74 }*/ 74 }*/
75 75
76 /*public function getAttributes(): array
77 {
78 return $this->attributes;
79 }
80 public function setDefaultAttributes(array $attributes): void
81 {
82 $this->attributes = $attributes;
83 }
84 public function useDefaultAttributes(): void
85 {
86 $this->attributes = self::$default_attributes;
87 }
88 public function addAttribute(string $key, string $value): void
89 {
90 if(!isset($this->attributes[$key])) { // sécurité $key inexistante
91 $this->attributes[$key] = [];
92 }
93 if(!in_array($value, $this->attributes[$key])){
94 $this->attributes[$key][] = $value;
95 }
96 }*/
97 /*public function removeAttribute(string $key, string $value): void
98 {
99 if(isset($this->attributes[$key])) // sécurité $key inexistante
100 {
101 // supprime et réindex avec un nouveau tableau
102 $tmp_array = $this->attributes[$key];
103 $this->attributes[$key] = [];
104 foreach($tmp_array as $entry){
105 if($entry !== $value){
106 $this->attributes[$key][] = $entry;
107 }
108 }
109 }
110 }*/
111 public function getParent(): ?self 76 public function getParent(): ?self
112 { 77 {
113 return $this->parent; 78 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
45 private Collection $nda_collection; 45 private Collection $nda_collection;
46 46
47 private int $nb_pages = 1; 47 private int $nb_pages = 1;
48 private array $emails = []; // noeud show_emails uniquement
48 49
49 public function __construct(array $data, Node $node, Collection $nda_collection = new ArrayCollection, ?string $presentation = null, ?bool $chrono_order = null) 50 public function __construct(array $data, Node $node, Collection $nda_collection = new ArrayCollection, ?string $presentation = null, ?bool $chrono_order = null)
50 { 51 {
@@ -179,4 +180,13 @@ class NodeData
179 $this->new_nda = new NodeDataAsset($this, $asset, $role); 180 $this->new_nda = new NodeDataAsset($this, $asset, $role);
180 $this->addNodeDataAsset($this->new_nda); 181 $this->addNodeDataAsset($this->new_nda);
181 }*/ 182 }*/
183
184 public function getEmails(): array
185 {
186 return $this->emails;
187 }
188 public function setEmails(array $emails): void
189 {
190 $this->emails = $emails;
191 }
182} \ No newline at end of file 192} \ 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;
15class NodeDataAsset 15class NodeDataAsset
16{ 16{
17 // clé primaire double 17 // clé primaire double
18 // inconvénient: impossible d'utiliser deux fois la même paire node_data/asset, même pour des rôles différents
19 #[ORM\Id] 18 #[ORM\Id]
20 #[ORM\ManyToOne(targetEntity: NodeData::class, inversedBy: 'nda_collection')] 19 #[ORM\ManyToOne(targetEntity: NodeData::class, inversedBy: 'nda_collection')]
21 #[ORM\JoinColumn(name: 'node_data_id', referencedColumnName: 'id_node_data', onDelete: 'CASCADE')] 20 #[ORM\JoinColumn(name: 'node_data_id', referencedColumnName: 'id_node_data', onDelete: 'CASCADE')]