From 1dd30c2f754eb560081fb0582a5baa80af4a690d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?=
Date: Mon, 18 Mar 2024 10:34:55 +0100
Subject: [PATCH 01/10] refactor(contact-handler.php): PSR2 autoformat
---
src/form/contact-form-handler.php | 204 +++++++++++++++---------------
1 file changed, 102 insertions(+), 102 deletions(-)
diff --git a/src/form/contact-form-handler.php b/src/form/contact-form-handler.php
index 04d0506..937b36d 100644
--- a/src/form/contact-form-handler.php
+++ b/src/form/contact-form-handler.php
@@ -1,102 +1,102 @@
-", $emailBody);
-
- $mail->isSMTP();
- $mail->Host = getenv('ASTRO_SMTP_HOSTNAME');
- $mail->SMTPAuth = true;
- $mail->Username = getenv('ASTRO_SMTP_USERNAME');
- $mail->Password = getenv('ASTRO_SMTP_PASSWORD');
- $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
- $mail->Port = 587;
-
- //Options
- $mail->CharSet = 'UTF-8';
- $mail->WordWrap = 70;
-
- //Recipients
- $mail->setFrom($myEmail);
- $mail->addAddress($myEmail);
- $mail->addReplyTo($emailAddress, $name);
-
- // Content
- $mail->isHTML(true);
- $mail->Subject = $emailSubject;
- $mail->Body = $emailBodyHTML;
- $mail->AltBody = $emailBody;
-
- $mail->send();
-
- // if subscribe add to mailing list
- if(!empty($subscribe)) {
- // process
- // enovoi mail add to mailing list
- }
-
- // redirect to the 'thank you' page
- header("Location: /thank-you/index.html");
- }
-?>
-
-
-
- Contact form handler
-
-
-
-
-
-
-
+", $emailBody);
+
+ $mail->isSMTP();
+ $mail->Host = getenv('ASTRO_SMTP_HOSTNAME');
+ $mail->SMTPAuth = true;
+ $mail->Username = getenv('ASTRO_SMTP_USERNAME');
+ $mail->Password = getenv('ASTRO_SMTP_PASSWORD');
+ $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
+ $mail->Port = 587;
+
+ //Options
+ $mail->CharSet = 'UTF-8';
+ $mail->WordWrap = 70;
+
+ //Recipients
+ $mail->setFrom($myEmail);
+ $mail->addAddress($myEmail);
+ $mail->addReplyTo($emailAddress, $name);
+
+ // Content
+ $mail->isHTML(true);
+ $mail->Subject = $emailSubject;
+ $mail->Body = $emailBodyHTML;
+ $mail->AltBody = $emailBody;
+
+ $mail->send();
+
+ // if subscribe add to mailing list
+ if(!empty($subscribe)) {
+ // process
+ // enovoi mail add to mailing list
+ }
+
+ // redirect to the 'thank you' page
+ header("Location: /thank-you/index.html");
+}
+?>
+
+
+
+ Contact form handler
+
+
+
+
+
+
+
From 0b6c22c7a33b5a28ab891a1fdc584d77f24dbd42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?=
Date: Mon, 18 Mar 2024 10:35:43 +0100
Subject: [PATCH 02/10] feat(contact-handler.php): manager other e-mails from
POST
---
src/form/contact-form-handler.php | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/form/contact-form-handler.php b/src/form/contact-form-handler.php
index 937b36d..7fffbb1 100644
--- a/src/form/contact-form-handler.php
+++ b/src/form/contact-form-handler.php
@@ -7,6 +7,21 @@ $mail = new PHPMailer(true);
$errors = '';
$myEmail = getenv('ASTRO_SMTP_FROM');
+$myEmailSplitted = explode('@', $myEmail);
+$domainFromMyEmail = (
+ empty($myEmailSplitted[1])
+ || count($myEmailSplitted) != 2
+) ? ''
+: $myEmailSplitted[1];
+
+$wantedContact = filter_input(INPUT_POST, 'contactTo', FILTER_VALIDATE_EMAIL);
+if (
+ empty($wantedContact)
+ || empty($domainFromMyEmail)
+ || substr($wantedContact, -strlen($domainFromMyEmail)) != $domainFromMyEmail
+) {
+ $wantedContact = $myEmail;
+}
if(empty($_POST['namezzz']) || empty($_POST['emailzzz']) || empty($_POST['message'])) {
$errors .= "\n Error: all fields are required";
@@ -27,7 +42,6 @@ if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
}
if(empty($errors)) {
- $to = $myEmail;
$emailSubject = "[Formulaire Astrolabe] Nouveau message";
switch ($select) {
@@ -66,7 +80,7 @@ if(empty($errors)) {
//Recipients
$mail->setFrom($myEmail);
- $mail->addAddress($myEmail);
+ $mail->addAddress($wantedContact);
$mail->addReplyTo($emailAddress, $name);
// Content
From 2afe8ce4baa22d0a960b2ea1c7fa7db5440de0f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?=
Date: Mon, 18 Mar 2024 15:13:23 +0100
Subject: [PATCH 03/10] feat(members/contact): create pages
---
src/members-contact.njk | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 src/members-contact.njk
diff --git a/src/members-contact.njk b/src/members-contact.njk
new file mode 100644
index 0000000..ce2c2ed
--- /dev/null
+++ b/src/members-contact.njk
@@ -0,0 +1,37 @@
+---
+title: 'Contacter un membre'
+pagination:
+ data: collections.members
+ size: 1
+ alias: member
+permalink: '/members/{{ member.fileSlug }}/contact/'
+---
+
+{% extends 'layouts/base.njk' %}
+
+{% set memberData = member.data %}
+{% set title = ["Écrire à ",memberData.name] | join %}
+
+{% block content %}
+
+
+
+ {{ title }}
+ {{ memberData.position }}
+ {% if memberData.positionInternal %}
+ {{ memberData.positionInternal }}
+ {% endif %}
+
+
+
+
+
+ {% set contactMember = member.fileSlug | replace("-",".") %}
+ {% include "partials/components/contact-form.njk" %}
+
+
+
+ Voir tous les membres
+
+
+{% endblock %}
\ No newline at end of file
From 08fcc19e53b35a6fe1db5ac5cf4a05c2d7dda109 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?=
Date: Mon, 18 Mar 2024 15:13:45 +0100
Subject: [PATCH 04/10] feat(members): create link to email form
---
src/_includes/layouts/member.njk | 1 +
src/scss/components/_member.scss | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/src/_includes/layouts/member.njk b/src/_includes/layouts/member.njk
index 2f19950..745d183 100644
--- a/src/_includes/layouts/member.njk
+++ b/src/_includes/layouts/member.njk
@@ -21,6 +21,7 @@
{% endif %}
+ - @
{% if socialMastodon %}
{% endif %}
diff --git a/src/scss/components/_member.scss b/src/scss/components/_member.scss
index 22e1ea8..6d5c91a 100644
--- a/src/scss/components/_member.scss
+++ b/src/scss/components/_member.scss
@@ -45,6 +45,15 @@
svg > path {
fill: var(--color-secondary);
}
+
+ .member-contact-at {
+ text-decoration: none;
+ font-size: 1.7rem;
+ font-weight: 800;
+ &, &:visited, &:focus {
+ color: var(--color-secondary);
+ }
+ }
}
}
From 63ccebb4521273e48e1f9c425695e5f65cbca107 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?=
Date: Mon, 18 Mar 2024 15:14:03 +0100
Subject: [PATCH 05/10] feat(contact-form): adapt to member
---
.../partials/components/contact-form.njk | 42 +++++++++++++------
src/form/contact-form-handler.php | 6 +--
2 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/src/_includes/partials/components/contact-form.njk b/src/_includes/partials/components/contact-form.njk
index faf90ef..aee53c1 100644
--- a/src/_includes/partials/components/contact-form.njk
+++ b/src/_includes/partials/components/contact-form.njk
@@ -1,9 +1,13 @@
-{% from "macros/form.njk" import label, field, select, option, textarea, checkboxes, button %}
+{% from "macros/form.njk" import label, field, select, option, textarea, checkboxes, button, hidden_field %}