diff options
Diffstat (limited to 'src/controller')
| -rw-r--r-- | src/controller/ContactFormController.php | 25 | ||||
| -rw-r--r-- | src/controller/UserController.php | 2 | ||||
| -rw-r--r-- | src/controller/ViewController.php | 2 |
3 files changed, 28 insertions, 1 deletions
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){ |
