aboutsummaryrefslogtreecommitdiff
path: root/src/View/ShowEmailsBuilder.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-23 00:47:32 +0200
committerpolo <ordipolo@gmx.fr>2026-10-23 00:47:32 +0200
commitf27cca08ff786ceff1870147f6d6bad14d71117f (patch)
treed36597a72025313d6faf4ed228755fa267ebe2f6 /src/View/ShowEmailsBuilder.php
parentc7309f900ef05bd5cb313110ec159b761af394ec (diff)
downloadcms-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/View/ShowEmailsBuilder.php')
-rw-r--r--src/View/ShowEmailsBuilder.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/View/ShowEmailsBuilder.php b/src/View/ShowEmailsBuilder.php
new file mode 100644
index 0000000..b02174d
--- /dev/null
+++ b/src/View/ShowEmailsBuilder.php
@@ -0,0 +1,71 @@
1<?php
2// src/View/ShowEmailsBuilder.php
3
4declare(strict_types=1);
5
6namespace App\View;
7
8use App\Entity\Node;
9use App\Service\URL;
10
11class ShowEmailsBuilder extends AbstractBuilder
12{
13 public function __construct(?Node $node)
14 {
15 //parent::__construct($node);
16 $viewFile = self::VIEWS_PATH . $node->getName() . '.php';
17 if(file_exists($viewFile))
18 {
19 // objets Email groupés par destinataire
20 $emails_by_recipient = [];
21 foreach($node->getNodeData()->getEmails() as $email){
22 $recipient = $email->getRecipient();
23 $emails_by_recipient[$recipient][] = $email;
24 }
25
26 // affiche une table par destinataire
27 $emails = '';
28 foreach($emails_by_recipient as $recipient => $emails_list){
29 $html = '<h4>Destinataire: ' . $recipient . '</h4>
30 <table>
31 <thead>
32 <tr>
33 <th>Expéditeur</th>
34 <th>Adresse</th>
35 <th>Contenu</th>
36 <th>Date</th>
37 <th>Effacement prévu le</th>
38 <th>Sensible</th>
39 <th class="email_delete_button"></th>
40 </tr>
41 </thead>
42 <tbody>';
43
44 // insère les données
45 foreach($emails_list as $email){
46 $html .= '<tr id="' . $email->getId() . '">
47 <td>' . htmlspecialchars($email->getSenderName()) . '</td>
48 <td>' . htmlspecialchars($email->getSenderAddress()) . '</td>
49 <td>' . htmlspecialchars($email->getContent()) . '</td>
50 <td>' . $email->getDateTime()->format('d/m/Y') . '</td>
51 <td class="deletion_date">' . $email->getDeletionDate()->format('d/m/Y') . '</td>
52 <td><input class="make_checkbox_sensitive" type="checkbox" ' . ($email->isSensitive() ? 'checked' : '') . ' onclick="toggleSensitiveEmail(' . $email->getId() . ')"></td>
53 <td class="email_delete_button"><img class="action_icon" src="assets/delete-bin.svg" onclick="deleteEmail(' . $email->getId() . ')"></td>
54 </tr>';
55 }
56
57 $html .= '</tbody>
58 </table>';
59 $emails .= $html;
60 }
61
62 ob_start();
63 require $viewFile; // insertion de $this->html généré par unfoldMenu
64 $this->html = ob_get_clean(); // pas de concaténation .= cette fois on écrase
65 }
66 else{
67 header('Location: ' . new URL(['error' => 'show_emails_view_not_found']));
68 die;
69 }
70 }
71} \ No newline at end of file