diff options
| -rw-r--r-- | bin/cron.php | 12 | ||||
| -rw-r--r-- | composer.json | 5 | ||||
| -rw-r--r-- | public/css/form.css | 4 | ||||
| -rw-r--r-- | public/css/show_emails.css | 24 | ||||
| -rw-r--r-- | public/js/form.js | 101 | ||||
| -rw-r--r-- | src/EmailService.php | 30 | ||||
| -rw-r--r-- | src/controller/ContactFormController.php | 25 | ||||
| -rw-r--r-- | src/controller/UserController.php | 2 | ||||
| -rw-r--r-- | src/controller/ViewController.php | 2 | ||||
| -rw-r--r-- | src/installation.php | 8 | ||||
| -rw-r--r-- | src/model/Model.php | 17 | ||||
| -rw-r--r-- | src/model/entities/Email.php | 90 | ||||
| -rw-r--r-- | src/model/entities/Node.php | 37 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 12 | ||||
| -rw-r--r-- | src/model/entities/NodeDataAsset.php | 1 | ||||
| -rw-r--r-- | src/router.php | 16 | ||||
| -rw-r--r-- | src/view/ShowEmailsBuilder.php | 69 | ||||
| -rw-r--r-- | src/view/templates/form.php | 16 | ||||
| -rw-r--r-- | src/view/templates/form_admin.php | 8 | ||||
| -rw-r--r-- | src/view/templates/show_emails.php | 29 |
20 files changed, 444 insertions, 64 deletions
diff --git a/bin/cron.php b/bin/cron.php new file mode 100644 index 0000000..5e158a4 --- /dev/null +++ b/bin/cron.php | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #!/usr/bin/env php | ||
| 2 | <?php | ||
| 3 | // bin/cron.php | ||
| 4 | |||
| 5 | declare(strict_types=1); | ||
| 6 | |||
| 7 | chdir(dirname(__FILE__)); // = /chemin/du/site/bin = même niveau que public/ | ||
| 8 | require('../src/Config.php'); | ||
| 9 | Config::load('../config/config.ini'); | ||
| 10 | require '../src/model/doctrine-bootstrap.php'; | ||
| 11 | |||
| 12 | EmailService::cleanEmails($entityManager); \ No newline at end of file | ||
diff --git a/composer.json b/composer.json index a661963..38b46de 100644 --- a/composer.json +++ b/composer.json | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "name": "ordipolo/cms", | 2 | "name": "ordipolo/cms", |
| 3 | "description": "CMS maison avec PHP, doctrine et tinMCE", | 3 | "description": "CMS maison avec PHP, doctrine et tinyMCE", |
| 4 | "require": { | 4 | "require": { |
| 5 | "doctrine/dbal": "^4.3", | 5 | "doctrine/dbal": "^4.3", |
| 6 | "doctrine/orm": "^3.5", | 6 | "doctrine/orm": "^3.5", |
| @@ -10,7 +10,8 @@ | |||
| 10 | "tinymce/tinymce": "^8.2", | 10 | "tinymce/tinymce": "^8.2", |
| 11 | "phpmailer/phpmailer": "^7.0", | 11 | "phpmailer/phpmailer": "^7.0", |
| 12 | "symfony/http-foundation": "^7.3", | 12 | "symfony/http-foundation": "^7.3", |
| 13 | "twbs/bootstrap-icons": "^1.13" | 13 | "twbs/bootstrap-icons": "^1.13", |
| 14 | "symfony/var-exporter": "^7.0" | ||
| 14 | }, | 15 | }, |
| 15 | "scripts": { | 16 | "scripts": { |
| 16 | "post-install-cmd": [ | 17 | "post-install-cmd": [ |
diff --git a/public/css/form.css b/public/css/form.css index c17662d..30673c9 100644 --- a/public/css/form.css +++ b/public/css/form.css | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | background-color: white; | 2 | background-color: white; |
| 3 | margin: auto; | 3 | margin: auto; |
| 4 | padding: 10px; | 4 | padding: 10px; |
| 5 | max-width: 800px; | ||
| 6 | display: grid; | 5 | display: grid; |
| 7 | grid-template-columns: auto 1fr; | 6 | grid-template-columns: auto 1fr; |
| 8 | gap: 10px; | 7 | gap: 10px; |
| @@ -35,6 +34,9 @@ | |||
| 35 | .form .admin_form i{ | 34 | .form .admin_form i{ |
| 36 | font-size: smaller; | 35 | font-size: smaller; |
| 37 | } | 36 | } |
| 37 | .form_warning{ | ||
| 38 | font-size: smaller; | ||
| 39 | } | ||
| 38 | 40 | ||
| 39 | @media screen and (max-width: 600px){ | 41 | @media screen and (max-width: 600px){ |
| 40 | .form_inputs{ | 42 | .form_inputs{ |
diff --git a/public/css/show_emails.css b/public/css/show_emails.css new file mode 100644 index 0000000..4fb9f3b --- /dev/null +++ b/public/css/show_emails.css | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | .show_emails p{ | ||
| 2 | font-size: smaller; | ||
| 3 | } | ||
| 4 | .show_emails table{ | ||
| 5 | |||
| 6 | padding: 10px; | ||
| 7 | border-collapse: collapse; | ||
| 8 | font-size: smaller; | ||
| 9 | } | ||
| 10 | .show_emails table th, .show_emails table td{ | ||
| 11 | background-color: white; | ||
| 12 | border: 1px black solid; | ||
| 13 | } | ||
| 14 | .show_emails table td{ | ||
| 15 | vertical-align: top; | ||
| 16 | text-align: center; | ||
| 17 | } | ||
| 18 | .show_emails table .email_delete_button{ | ||
| 19 | /*background-color: initial;*/ | ||
| 20 | /*border: none;*/ | ||
| 21 | } | ||
| 22 | .show_emails .action_icon{ | ||
| 23 | width: 20px; | ||
| 24 | } \ No newline at end of file | ||
diff --git a/public/js/form.js b/public/js/form.js index 4be83c6..7cee970 100644 --- a/public/js/form.js +++ b/public/js/form.js | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | //function sendMessage(){} | ||
| 2 | |||
| 3 | // modif des paramètres d'e-mail: e-mail source/dest, mot de passe, serveur smtp & chiffrement tls/ssl | 1 | // modif des paramètres d'e-mail: e-mail source/dest, mot de passe, serveur smtp & chiffrement tls/ssl |
| 4 | function setEmailParam(what_param, id){ | 2 | function setEmailParam(what_param, id){ |
| 5 | const value = document.getElementById(what_param + '_' + id).value; | 3 | const value = document.getElementById(what_param + '_' + id).value; |
| @@ -28,8 +26,41 @@ function setEmailParam(what_param, id){ | |||
| 28 | }); | 26 | }); |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | function checkCase(){ | 29 | function keepEmails(block_id){ |
| 32 | if(document.getElementById('email_address').value.match('[A-Z]')){ | 30 | const form = document.getElementById('keep_emails_' + block_id); |
| 31 | const warning = document.getElementById('form_warning_' + block_id); | ||
| 32 | if(!form || !warning){ | ||
| 33 | return; | ||
| 34 | } | ||
| 35 | |||
| 36 | fetch('index.php?action=keep_emails', { | ||
| 37 | method: 'POST', | ||
| 38 | headers: { | ||
| 39 | 'Content-Type': 'application/json' | ||
| 40 | }, | ||
| 41 | body: JSON.stringify({ | ||
| 42 | id: block_id, | ||
| 43 | checked: form.checked | ||
| 44 | }) | ||
| 45 | }) | ||
| 46 | .then(response => response.json()) | ||
| 47 | .then(data => { | ||
| 48 | if(data.success){ | ||
| 49 | form.checked = data.checked; | ||
| 50 | data.checked ? warning.classList.remove('hidden') : warning.classList.add('hidden'); | ||
| 51 | toastNotify(data.checked ? "Les e-mails seront conservés. Pensez au RGPD." : "Les nouveaux e-mails ne seront pas conservés."); | ||
| 52 | } | ||
| 53 | else{ | ||
| 54 | toastNotify("Erreur, le réglage n'a pas été enregistré par le serveur."); | ||
| 55 | } | ||
| 56 | }) | ||
| 57 | .catch(error => { | ||
| 58 | console.error('Erreur:', error); | ||
| 59 | }); | ||
| 60 | } | ||
| 61 | |||
| 62 | function checkCase(id){ | ||
| 63 | if(document.getElementById('email_address_' + id).value.match('[A-Z]')){ | ||
| 33 | toastNotify("Votre e-mail comporte une lettre majuscule, il s'agit probablement d'une erreur."); | 64 | toastNotify("Votre e-mail comporte une lettre majuscule, il s'agit probablement d'une erreur."); |
| 34 | } | 65 | } |
| 35 | } | 66 | } |
| @@ -118,4 +149,66 @@ function sendVisitorEmail(id){ | |||
| 118 | .catch(error => { | 149 | .catch(error => { |
| 119 | console.error('Erreur:', error); | 150 | console.error('Erreur:', error); |
| 120 | }); | 151 | }); |
| 152 | } | ||
| 153 | |||
| 154 | function deleteEmail(id){ | ||
| 155 | const table_row = document.getElementById(id); | ||
| 156 | if(!table_row){ | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | |||
| 160 | if(confirm('Voulez-vous supprimer cet e-mail ?')){ | ||
| 161 | fetch('index.php?action=delete_email', { | ||
| 162 | method: 'POST', | ||
| 163 | headers: { | ||
| 164 | 'Content-Type': 'application/json' | ||
| 165 | }, | ||
| 166 | body: JSON.stringify({ | ||
| 167 | id: id | ||
| 168 | }) | ||
| 169 | }) | ||
| 170 | .then(response => response.json()) | ||
| 171 | .then(data => { | ||
| 172 | if(data.success){ | ||
| 173 | table_row.remove(); | ||
| 174 | toastNotify("E-mail supprimé"); | ||
| 175 | } | ||
| 176 | else{} | ||
| 177 | }) | ||
| 178 | .catch(error => { | ||
| 179 | console.error('Erreur:', error); | ||
| 180 | }); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | function toggleSensitiveEmail(id){ | ||
| 185 | const table_row = document.getElementById(id); | ||
| 186 | const checkbox = table_row.querySelector("input[class='make_checkbox_sensitive']"); | ||
| 187 | const deletion_date = table_row.querySelector(".deletion_date"); | ||
| 188 | if(!table_row || !checkbox || !deletion_date){ | ||
| 189 | return; | ||
| 190 | } | ||
| 191 | |||
| 192 | fetch('index.php?action=toggle_sensitive_email', { | ||
| 193 | method: 'POST', | ||
| 194 | headers: { | ||
| 195 | 'Content-Type': 'application/json' | ||
| 196 | }, | ||
| 197 | body: JSON.stringify({ | ||
| 198 | id: id, | ||
| 199 | checked: checkbox.checked | ||
| 200 | }) | ||
| 201 | }) | ||
| 202 | .then(response => response.json()) | ||
| 203 | .then(data => { | ||
| 204 | if(data.success){ | ||
| 205 | checkbox.checked = data.checked; | ||
| 206 | deletion_date.innerHTML = data.deletion_date; | ||
| 207 | console.log(data.checked ? "Cet e-mail est maintenant considéré comme sensible." : "Cet e-mail n'est plus sensible."); | ||
| 208 | } | ||
| 209 | else{} | ||
| 210 | }) | ||
| 211 | .catch(error => { | ||
| 212 | console.error('Erreur:', error); | ||
| 213 | }); | ||
| 121 | } \ No newline at end of file | 214 | } \ No newline at end of file |
diff --git a/src/EmailService.php b/src/EmailService.php index 1bcca0f..5d1b2eb 100644 --- a/src/EmailService.php +++ b/src/EmailService.php | |||
| @@ -11,6 +11,8 @@ use App\Entity\NodeData; | |||
| 11 | 11 | ||
| 12 | class EmailService | 12 | class EmailService |
| 13 | { | 13 | { |
| 14 | const KEEP_EMAILS_DEFAULT = false; | ||
| 15 | |||
| 14 | static public function send(EntityManager $entityManager, NodeData $form_data, bool $test_email, string $name = '', string $email = '', string $message = ''): bool | 16 | static public function send(EntityManager $entityManager, NodeData $form_data, bool $test_email, string $name = '', string $email = '', string $message = ''): bool |
| 15 | { | 17 | { |
| 16 | $mail = new PHPMailer(true); // true => exceptions | 18 | $mail = new PHPMailer(true); // true => exceptions |
| @@ -64,17 +66,37 @@ class EmailService | |||
| 64 | $mail->send(); | 66 | $mail->send(); |
| 65 | 67 | ||
| 66 | // copie en BDD | 68 | // copie en BDD |
| 67 | if(!$test_email){ | 69 | if(!$test_email && ($form_data->getData()['keep_emails'] ?? self::KEEP_EMAILS_DEFAULT)){ |
| 68 | $db_email = new Email($email, Config::$email_dest, $message); | 70 | $db_email = new Email($name, $email, Config::$email_dest, $message); |
| 69 | $entityManager->persist($db_email); | 71 | $entityManager->persist($db_email); |
| 72 | self::updateLastContactDate($entityManager, $email); | ||
| 70 | $entityManager->flush(); | 73 | $entityManager->flush(); |
| 71 | } | 74 | } |
| 72 | 75 | ||
| 73 | return true; | 76 | return true; |
| 74 | } | 77 | } |
| 75 | catch(Exception $e){ | 78 | catch(Exception $e){ |
| 76 | return false; | 79 | echo "Le message n'a pas pu être envoyé. Erreur : {$e} <br> {$mail->ErrorInfo}"; |
| 77 | //echo "Le message n'a pas pu être envoyé. Erreur : {$mail->ErrorInfo}"; | 80 | return false; |
| 78 | } | 81 | } |
| 79 | } | 82 | } |
| 83 | |||
| 84 | static public function updateLastContactDate(EntityManager $entityManager, string $sender): void | ||
| 85 | { | ||
| 86 | foreach($entityManager->getRepository('App\Entity\Email')->findAll() as $email){ | ||
| 87 | $email->getSenderAddress() === $sender ? $email->updateLastContactDate() : null; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | // peut être appelée par bin/clean_emails_cron.php | ||
| 92 | static public function cleanEmails(EntityManager $entityManager): void | ||
| 93 | { | ||
| 94 | $emails = $entityManager->getRepository('App\Entity\Email')->findAll(); | ||
| 95 | foreach($emails as $email){ | ||
| 96 | if($email->getDeletionDate() < new \DateTime()){ | ||
| 97 | $entityManager->remove($email); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | $entityManager->flush(); | ||
| 101 | } | ||
| 80 | } \ No newline at end of file | 102 | } \ No newline at end of file |
diff --git a/src/controller/ContactFormController.php b/src/controller/ContactFormController.php index 181e93c..243740f 100644 --- a/src/controller/ContactFormController.php +++ b/src/controller/ContactFormController.php | |||
| @@ -7,6 +7,15 @@ use Doctrine\ORM\EntityManager; | |||
| 7 | 7 | ||
| 8 | class ContactFormController | 8 | class ContactFormController |
| 9 | { | 9 | { |
| 10 | static public function keepEmails(EntityManager $entityManager, array $json): void | ||
| 11 | { | ||
| 12 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | ||
| 13 | $form_data->updateData('keep_emails', $json['checked'] ? true : false); | ||
| 14 | $entityManager->persist($form_data); | ||
| 15 | $entityManager->flush(); | ||
| 16 | echo json_encode(['success' => true, 'checked' => $json['checked']]); | ||
| 17 | die; | ||
| 18 | } | ||
| 10 | static public function setEmailParam(EntityManager $entityManager, array $json): void | 19 | static public function setEmailParam(EntityManager $entityManager, array $json): void |
| 11 | { | 20 | { |
| 12 | $form = new FormValidation($json, 'email_params'); | 21 | $form = new FormValidation($json, 'email_params'); |
| @@ -80,4 +89,20 @@ class ContactFormController | |||
| 80 | } | 89 | } |
| 81 | die; | 90 | die; |
| 82 | } | 91 | } |
| 92 | static public function deleteEmail(EntityManager $entityManager, array $json): void | ||
| 93 | { | ||
| 94 | $email = $entityManager->find('App\Entity\Email', $json['id']); | ||
| 95 | $entityManager->remove($email); | ||
| 96 | $entityManager->flush(); | ||
| 97 | echo json_encode(['success' => true]); | ||
| 98 | die; | ||
| 99 | } | ||
| 100 | static public function toggleSensitiveEmail(EntityManager $entityManager, array $json): void | ||
| 101 | { | ||
| 102 | $email = $entityManager->find('App\Entity\Email', $json['id']); | ||
| 103 | $email->makeSensitive($json['checked']); | ||
| 104 | $entityManager->flush(); | ||
| 105 | echo json_encode(['success' => true, 'checked' => $json['checked'], 'deletion_date' => $email->getDeletionDate()->format('d/m/Y')]); | ||
| 106 | die; | ||
| 107 | } | ||
| 83 | } \ No newline at end of file | 108 | } \ No newline at end of file |
diff --git a/src/controller/UserController.php b/src/controller/UserController.php index a35b09e..f3c99e7 100644 --- a/src/controller/UserController.php +++ b/src/controller/UserController.php | |||
| @@ -90,6 +90,8 @@ class UserController | |||
| 90 | $_SESSION['user'] = $_POST['login']; | 90 | $_SESSION['user'] = $_POST['login']; |
| 91 | $_SESSION['admin'] = true; | 91 | $_SESSION['admin'] = true; |
| 92 | 92 | ||
| 93 | EmailService::cleanEmails($entityManager); | ||
| 94 | |||
| 93 | $url = new URL(isset($_GET['from']) ? ['page' => $_GET['from']] : []); | 95 | $url = new URL(isset($_GET['from']) ? ['page' => $_GET['from']] : []); |
| 94 | isset($_GET['id']) ? $url->addParams(['id' => $_GET['id']]) : ''; | 96 | isset($_GET['id']) ? $url->addParams(['id' => $_GET['id']]) : ''; |
| 95 | } | 97 | } |
diff --git a/src/controller/ViewController.php b/src/controller/ViewController.php index 9139dd4..8c95526 100644 --- a/src/controller/ViewController.php +++ b/src/controller/ViewController.php | |||
| @@ -55,7 +55,7 @@ class ViewController extends AbstractBuilder // ViewController est aussi le prem | |||
| 55 | self::$root_node = $model->getNode(); | 55 | self::$root_node = $model->getNode(); |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | /* 3/ 2ème contrôle utilisant les données récupérées */ | 58 | /* 3/ 2ème contrôle des paramètres avec les données récupérées */ |
| 59 | 59 | ||
| 60 | // article non trouvé en BDD | 60 | // article non trouvé en BDD |
| 61 | if(CURRENT_PAGE === 'article' && !$_SESSION['admin'] && self::$root_node->getNodeByName('main')->getAdoptedChild() === null){ | 61 | if(CURRENT_PAGE === 'article' && !$_SESSION['admin'] && self::$root_node->getNodeByName('main')->getAdoptedChild() === null){ |
diff --git a/src/installation.php b/src/installation.php index 3d75449..78f1768 100644 --- a/src/installation.php +++ b/src/installation.php | |||
| @@ -100,6 +100,9 @@ function fillStartingDatabase(EntityManager $entityManager){ | |||
| 100 | $new_page = new Page('Nouvelle page', 'new_page', "Nouvelle page", true, false, false, NULL, NULL); | 100 | $new_page = new Page('Nouvelle page', 'new_page', "Nouvelle page", true, false, false, NULL, NULL); |
| 101 | $new_page->addCSS('new_page'); | 101 | $new_page->addCSS('new_page'); |
| 102 | $new_page->addJS('new_page'); | 102 | $new_page->addJS('new_page'); |
| 103 | $emails = new Page("Courriels", 'emails', "Consulter les courriels en base de données", true, false, false, NULL, NULL); | ||
| 104 | $emails->addCSS('show_emails'); | ||
| 105 | $emails->addJS('form'); | ||
| 103 | 106 | ||
| 104 | /* -- table node -- */ | 107 | /* -- table node -- */ |
| 105 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article | 108 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article |
| @@ -113,12 +116,14 @@ function fillStartingDatabase(EntityManager $entityManager){ | |||
| 113 | $user_edit = new Node('user_edit', 1, $main, $my_account, NULL); | 116 | $user_edit = new Node('user_edit', 1, $main, $my_account, NULL); |
| 114 | $bloc_edit_menu = new Node('menu', 1, $main, $menu_paths, NULL); | 117 | $bloc_edit_menu = new Node('menu', 1, $main, $menu_paths, NULL); |
| 115 | $bloc_new_page = new Node('new_page', 1, $main, $new_page, NULL); | 118 | $bloc_new_page = new Node('new_page', 1, $main, $new_page, NULL); |
| 119 | $bloc_emails = new Node('show_emails', 1, $main, $emails, NULL); | ||
| 116 | 120 | ||
| 117 | /* -- table node_data -- */ | 121 | /* -- table node_data -- */ |
| 118 | // paramètres: data, node, images | 122 | // paramètres: data, node, images |
| 119 | $head_data = new NodeData([], $head); | 123 | $head_data = new NodeData([], $head); |
| 120 | $header_data = new NodeData([], $header); | 124 | $header_data = new NodeData([], $header); |
| 121 | $footer_data = new NodeData([], $footer); | 125 | $footer_data = new NodeData([], $footer); |
| 126 | $emails_data = new NodeData([], $bloc_emails); | ||
| 122 | 127 | ||
| 123 | /* -- table page -- */ | 128 | /* -- table page -- */ |
| 124 | $entityManager->persist($accueil); | 129 | $entityManager->persist($accueil); |
| @@ -127,6 +132,7 @@ function fillStartingDatabase(EntityManager $entityManager){ | |||
| 127 | $entityManager->persist($my_account); | 132 | $entityManager->persist($my_account); |
| 128 | $entityManager->persist($menu_paths); | 133 | $entityManager->persist($menu_paths); |
| 129 | $entityManager->persist($new_page); | 134 | $entityManager->persist($new_page); |
| 135 | $entityManager->persist($emails); | ||
| 130 | 136 | ||
| 131 | /* -- table node -- */ | 137 | /* -- table node -- */ |
| 132 | $entityManager->persist($head); | 138 | $entityManager->persist($head); |
| @@ -139,11 +145,13 @@ function fillStartingDatabase(EntityManager $entityManager){ | |||
| 139 | $entityManager->persist($user_edit); | 145 | $entityManager->persist($user_edit); |
| 140 | $entityManager->persist($bloc_edit_menu); | 146 | $entityManager->persist($bloc_edit_menu); |
| 141 | $entityManager->persist($bloc_new_page); | 147 | $entityManager->persist($bloc_new_page); |
| 148 | $entityManager->persist($bloc_emails); | ||
| 142 | 149 | ||
| 143 | /* -- table node_data -- */ | 150 | /* -- table node_data -- */ |
| 144 | $entityManager->persist($head_data); | 151 | $entityManager->persist($head_data); |
| 145 | $entityManager->persist($header_data); | 152 | $entityManager->persist($header_data); |
| 146 | $entityManager->persist($footer_data); | 153 | $entityManager->persist($footer_data); |
| 154 | $entityManager->persist($emails_data); | ||
| 147 | 155 | ||
| 148 | $entityManager->flush(); | 156 | $entityManager->flush(); |
| 149 | header('Location: ' . new URL); | 157 | header('Location: ' . new URL); |
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")] |
| 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 |
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..4c07a69 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 | { |
| @@ -69,7 +70,7 @@ class NodeData | |||
| 69 | { | 70 | { |
| 70 | $this->data = $data; | 71 | $this->data = $data; |
| 71 | }*/ | 72 | }*/ |
| 72 | public function updateData(string $key, string|array $value = ''): void | 73 | public function updateData(string $key, string|bool|array $value = ''): void |
| 73 | { | 74 | { |
| 74 | if($value !== ''){ | 75 | if($value !== ''){ |
| 75 | $this->data[$key] = $value; | 76 | $this->data[$key] = $value; |
| @@ -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; | |||
| 15 | class NodeDataAsset | 15 | class 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')] |
diff --git a/src/router.php b/src/router.php index 15d5a4c..228fae2 100644 --- a/src/router.php +++ b/src/router.php | |||
| @@ -38,6 +38,12 @@ if($request->getMethod() === 'GET'){ | |||
| 38 | CalendarController::getData($entityManager); | 38 | CalendarController::getData($entityManager); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | // pages interdites | ||
| 42 | if(!$_SESSION['admin'] && in_array(CURRENT_PAGE, ['menu_paths', 'new_page', 'user_edit', 'emails'])){ | ||
| 43 | header('Location: ' . new URL); | ||
| 44 | die; | ||
| 45 | } | ||
| 46 | |||
| 41 | if($_SESSION['admin'] === true){ | 47 | if($_SESSION['admin'] === true){ |
| 42 | // ... | 48 | // ... |
| 43 | } | 49 | } |
| @@ -106,6 +112,9 @@ elseif($request->getMethod() === 'POST'){ | |||
| 106 | } | 112 | } |
| 107 | 113 | ||
| 108 | /* -- bloc Formulaire -- */ | 114 | /* -- bloc Formulaire -- */ |
| 115 | elseif($_GET['action'] === 'keep_emails'){ | ||
| 116 | ContactFormController::keepEmails($entityManager, $json); | ||
| 117 | } | ||
| 109 | elseif($_GET['action'] === 'set_email_param'){ | 118 | elseif($_GET['action'] === 'set_email_param'){ |
| 110 | ContactFormController::setEmailParam($entityManager, $json); | 119 | ContactFormController::setEmailParam($entityManager, $json); |
| 111 | } | 120 | } |
| @@ -113,6 +122,13 @@ elseif($request->getMethod() === 'POST'){ | |||
| 113 | ContactFormController::sendTestEmail($entityManager, $json); | 122 | ContactFormController::sendTestEmail($entityManager, $json); |
| 114 | } | 123 | } |
| 115 | 124 | ||
| 125 | /* -- page emails -- */ | ||
| 126 | elseif($_GET['action'] === 'delete_email'){ | ||
| 127 | ContactFormController::deleteEmail($entityManager, $json); | ||
| 128 | } | ||
| 129 | elseif($_GET['action'] === 'toggle_sensitive_email'){ | ||
| 130 | ContactFormController::toggleSensitiveEmail($entityManager, $json); | ||
| 131 | } | ||
| 116 | 132 | ||
| 117 | /* -- upload d'image dans tinymce par copier-coller -- */ | 133 | /* -- upload d'image dans tinymce par copier-coller -- */ |
| 118 | // collage de HTML contenant une ou plusieurs balises <img> | 134 | // collage de HTML contenant une ou plusieurs balises <img> |
diff --git a/src/view/ShowEmailsBuilder.php b/src/view/ShowEmailsBuilder.php new file mode 100644 index 0000000..3d2d6a9 --- /dev/null +++ b/src/view/ShowEmailsBuilder.php | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | <?php | ||
| 2 | // src/view/ShowEmailsBuilder.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | use App\Entity\Node; | ||
| 7 | use App\Entity\Page; | ||
| 8 | |||
| 9 | class ShowEmailsBuilder extends AbstractBuilder | ||
| 10 | { | ||
| 11 | public function __construct(Node $node = null) | ||
| 12 | { | ||
| 13 | //parent::__construct($node); | ||
| 14 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 15 | if(file_exists($viewFile)) | ||
| 16 | { | ||
| 17 | // objets Email groupés par destinataire | ||
| 18 | $emails_by_recipient = []; | ||
| 19 | foreach($node->getNodeData()->getEmails() as $email){ | ||
| 20 | $recipient = $email->getRecipient(); | ||
| 21 | $emails_by_recipient[$recipient][] = $email; | ||
| 22 | } | ||
| 23 | |||
| 24 | // affiche une table par destinataire | ||
| 25 | $emails = ''; | ||
| 26 | foreach($emails_by_recipient as $recipient => $emails_list){ | ||
| 27 | $html = '<h4>Destinataire: ' . $recipient . '</h4> | ||
| 28 | <table> | ||
| 29 | <thead> | ||
| 30 | <tr> | ||
| 31 | <th>Expéditeur</th> | ||
| 32 | <th>Adresse</th> | ||
| 33 | <th>Contenu</th> | ||
| 34 | <th>Date</th> | ||
| 35 | <th>Effacement prévu le</th> | ||
| 36 | <th>Sensible</th> | ||
| 37 | <th class="email_delete_button"></th> | ||
| 38 | </tr> | ||
| 39 | </thead> | ||
| 40 | <tbody>'; | ||
| 41 | |||
| 42 | // insère les données | ||
| 43 | foreach($emails_list as $email){ | ||
| 44 | $html .= '<tr id="' . $email->getId() . '"> | ||
| 45 | <td>' . htmlspecialchars($email->getSenderName()) . '</td> | ||
| 46 | <td>' . htmlspecialchars($email->getSenderAddress()) . '</td> | ||
| 47 | <td>' . htmlspecialchars($email->getContent()) . '</td> | ||
| 48 | <td>' . $email->getDateTime()->format('d/m/Y') . '</td> | ||
| 49 | <td class="deletion_date">' . $email->getDeletionDate()->format('d/m/Y') . '</td> | ||
| 50 | <td><input class="make_checkbox_sensitive" type="checkbox" ' . ($email->isSensitive() ? 'checked' : '') . ' onclick="toggleSensitiveEmail(' . $email->getId() . ')"></td> | ||
| 51 | <td class="email_delete_button"><img class="action_icon" src="assets/delete-bin.svg" onclick="deleteEmail(' . $email->getId() . ')"></td> | ||
| 52 | </tr>'; | ||
| 53 | } | ||
| 54 | |||
| 55 | $html .= '</tbody> | ||
| 56 | </table>'; | ||
| 57 | $emails .= $html; | ||
| 58 | } | ||
| 59 | |||
| 60 | ob_start(); | ||
| 61 | require $viewFile; // insertion de $this->html généré par unfoldMenu | ||
| 62 | $this->html = ob_get_clean(); // pas de concaténation .= cette fois on écrase | ||
| 63 | } | ||
| 64 | else{ | ||
| 65 | header('Location: ' . new URL(['error' => 'show_emails_view_not_found'])); | ||
| 66 | die; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } \ No newline at end of file | ||
diff --git a/src/view/templates/form.php b/src/view/templates/form.php index 5c959a0..54dcd02 100644 --- a/src/view/templates/form.php +++ b/src/view/templates/form.php | |||
| @@ -3,20 +3,20 @@ | |||
| 3 | <h3><?= $title ?></h3> | 3 | <h3><?= $title ?></h3> |
| 4 | <?= $admin_content ?> | 4 | <?= $admin_content ?> |
| 5 | <div class="form_inputs"> | 5 | <div class="form_inputs"> |
| 6 | <label for="email_name">Votre nom</label> | 6 | <label for="email_name_<?= $node->getNodeData()->getId() ?>">Votre nom</label> |
| 7 | <input id="email_name_<?= $node->getNodeData()->getId() ?>" type="text" name="email_name" value=""> | 7 | <input id="email_name_<?= $node->getNodeData()->getId() ?>" type="text" name="email_name" value=""> |
| 8 | 8 | ||
| 9 | <label for="email_address">Votre e-mail</label> | 9 | <label for="email_address_<?= $node->getNodeData()->getId() ?>">Votre e-mail</label> |
| 10 | <input id="email_address_<?= $node->getNodeData()->getId() ?>" type="email" name="email_address" placeholder="mon-adresse@email.fr" value="" onchange="checkCase()"> | 10 | <input id="email_address_<?= $node->getNodeData()->getId() ?>" type="email" name="email_address" placeholder="mon-adresse@email.fr" value="" onchange="checkCase(<?= $node->getNodeData()->getId() ?>)"> |
| 11 | 11 | ||
| 12 | <label for="email_message">Votre message</label> | 12 | <label for="email_message_<?= $node->getNodeData()->getId() ?>">Votre message</label> |
| 13 | <textarea id="email_message_<?= $node->getNodeData()->getId() ?>" type="text" name="email_message" rows="4"></textarea> | 13 | <textarea id="email_message_<?= $node->getNodeData()->getId() ?>" type="text" name="email_message" rows="4"></textarea> |
| 14 | 14 | ||
| 15 | <div class="full_width_column"> | 15 | <div class="full_width_column"> |
| 16 | <label for="captcha" >Montrez que vous n'êtes pas un robot</label> | 16 | <label for="email_captcha_<?= $node->getNodeData()->getId() ?>" >Montrez que vous n'êtes pas un robot</label> |
| 17 | </div> | 17 | </div> |
| 18 | 18 | ||
| 19 | <label for="email_captcha" >Combien font <?= self::$captcha->getA() ?> fois <?= self::$captcha->getB() ?>?</label> | 19 | <label for="email_captcha_<?= $node->getNodeData()->getId() ?>" >Combien font <?= self::$captcha->getA() ?> fois <?= self::$captcha->getB() ?>?</label> |
| 20 | <div> | 20 | <div> |
| 21 | <input id="email_captcha_<?= $node->getNodeData()->getId() ?>" type="text" name="email_captcha" size="1" autocomplete="off"> | 21 | <input id="email_captcha_<?= $node->getNodeData()->getId() ?>" type="text" name="email_captcha" size="1" autocomplete="off"> |
| 22 | </div> | 22 | </div> |
| @@ -30,4 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | <p class="send_email_success_<?= $node->getNodeData()->getId() ?> full_width_column"></p> | 31 | <p class="send_email_success_<?= $node->getNodeData()->getId() ?> full_width_column"></p> |
| 32 | </div> | 32 | </div> |
| 33 | <p id="form_warning_<?= $node->getNodeData()->getId() ?>" class="form_warning <?= ($keep_emails ?? false) ? '' : 'hidden' ?>"><i> | ||
| 34 | Une copie de votre e-mail (nom, adresse et message) sera conservée dans notre base de données dans le but de pouvoir répondre à votre demande et et éventuellement dans un but de prospection. Ces données seront traitées automatiquement par notre serveur et conservées pendant au maximum 3 ans à compter de votre dernier message.<br> | ||
| 35 | Ce traitement repose sur votre consentement. Vous pouvez consulter, modifier ou supprimer vos données en base de données sur simple demande. | ||
| 36 | </i></p> | ||
| 33 | </section> \ No newline at end of file | 37 | </section> \ No newline at end of file |
diff --git a/src/view/templates/form_admin.php b/src/view/templates/form_admin.php index 3559d25..bf281b5 100644 --- a/src/view/templates/form_admin.php +++ b/src/view/templates/form_admin.php | |||
| @@ -4,6 +4,14 @@ declare(strict_types=1); | |||
| 4 | // note: l'id ici n'est pas celui du noeud bloc mais celui de l'entrée dans node_data correspondante | 4 | // note: l'id ici n'est pas celui du noeud bloc mais celui de l'entrée dans node_data correspondante |
| 5 | ?> | 5 | ?> |
| 6 | <div class="admin_form"> | 6 | <div class="admin_form"> |
| 7 | <p> | ||
| 8 | <label for="keep_emails_<?= $node->getNodeData()->getId() ?>">Conserver les e-mails en base de données</label> | ||
| 9 | <input type="checkbox" id="keep_emails_<?= $node->getNodeData()->getId() ?>" <?= ($keep_emails ?? false) ? 'checked' : '' ?> onclick="keepEmails(<?= $node->getNodeData()->getId() ?>)"> | ||
| 10 | </p> | ||
| 11 | <p><i>Notez que ces enregistrements sont des données personnelles et sont concernés par le RGPD.</i></p> | ||
| 12 | <p><a href="<?= new URL(['page' => 'emails']) ?>"><button>Consulter les e-mails enregistrés</button></a></p> | ||
| 13 | </div> | ||
| 14 | <div class="admin_form"> | ||
| 7 | <h3>Paramètres d'envoi</h3> | 15 | <h3>Paramètres d'envoi</h3> |
| 8 | <p> | 16 | <p> |
| 9 | <label for="smtp_host_<?= $node->getNodeData()->getId() ?>">Adresse serveur SMTP</label> | 17 | <label for="smtp_host_<?= $node->getNodeData()->getId() ?>">Adresse serveur SMTP</label> |
diff --git a/src/view/templates/show_emails.php b/src/view/templates/show_emails.php new file mode 100644 index 0000000..2cb102e --- /dev/null +++ b/src/view/templates/show_emails.php | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | ||
| 2 | <section class="show_emails"> | ||
| 3 | <h3>Table "<?= TABLE_PREFIX ?>email" de la base de données</h3> | ||
| 4 | <p><i> | ||
| 5 | Les e-mails ci-dessous sont des copies de ceux arrivés dans votre boite de messagerie (qui en théorie sont également concernés par le RGPD) depuis tous les formulaires existant sur le site. Ils sont conservés dans un but pratique et éventuellement dans un but de prospection, ou dans tout autre but justifiant leur conservation. | ||
| 6 | </i></p> | ||
| 7 | <h4>Durées de conservation</h4> | ||
| 8 | <p><i> | ||
| 9 | Ce sont des durées maximales, les données peuvent être supprimées plus tôt ou même immédiatement. Le faire est d'ailleurs une obligation dans le cas où les personnes concernées le demandent.<br> | ||
| 10 | </i></p> | ||
| 11 | <p><i> | ||
| 12 | Les e-mails ordinaires d'un même expéditeur (même adresse e-mail) sont tous supprimés simultanément lorsque le plus récent d'entre eux atteint les 3 ans (utilisateur "inactif").<br> | ||
| 13 | Les e-mails sensibles quand à eux sont supprimés 5 ans après être devenus sensibles (durée juridique d'une preuve). | ||
| 14 | </i></p> | ||
| 15 | <p><i> | ||
| 16 | Un nettoyeur supprimant les messages dépassant ces durées est exécuté au moment de votre connexion au mode administrateur.<br> | ||
| 17 | Si vos connexions sont rares, il est possible d'automatiser ce nettoyage à l'aide d'une tâche CRON. Pour cela, vous devez configurer le serveur pour qu'il exécute periodiquement la commande "php /chemin/du/site/bin/cron.php". | ||
| 18 | </i></p> | ||
| 19 | <h4>Données sensibles</h4> | ||
| 20 | <p><i> | ||
| 21 | Un e-mail peut-être considéré comme "sensible". Vous pouvez rendre un e-mail sensible lorsqu'il possède une valeur de preuve dans le cas d'un litige.<br> | ||
| 22 | Lorsqu'une personne demande la suppression de ses données personnelles du serveur, les e-mails sensibles peuvent être conservés, vous aurez noté que la durée de conservation est calculée différement. | ||
| 23 | </i></p> | ||
| 24 | <p><i> | ||
| 25 | Les spams ne sont pas sensibles, c'est juste de la pollution, supprimez-les! | ||
| 26 | </i></p> | ||
| 27 | |||
| 28 | <?= $emails ?> | ||
| 29 | </section> \ No newline at end of file | ||
