diff --git a/formulaires/gamucontact.php b/formulaires/gamucontact.php
index a428752..a58a2cc 100644
--- a/formulaires/gamucontact.php
+++ b/formulaires/gamucontact.php
@@ -84,6 +84,9 @@ function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') {
}
}
$set['date_heure'] = date("Y-m-d H:i:s");
+ $set['statut'] = 'publie';
+ $set['titre'] = _T('gamucontact:formulaire_contact');
+
if (count($set) > 0) {
$set = pipeline(
'pre_edition',
@@ -134,21 +137,41 @@ function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') {
$test_mail = true;
if (count($destinataires)) {
- $html = recuperer_fond('modeles/gamucontact_message', ['id_message' => $id_message]);
+ $GLOBALS['forcer_lang'] = false;
+ $langue_defaut = lire_config('langue_site');
include_spip('classes/facteur');
- $texte = Facteur::html2text($html);
- $corps = array(
- 'html' => $html,
- 'texte' => $texte,
- );
+ // récupérer les infos de langue des destinataires
+ $dest_langues = sql_allfetsel('id_auteur,lang,email', 'spip_auteurs', sql_in('email', $destinataires), 'email');
+ // array avec les langues des destinataires
+ if (is_array($dest_langues) and count($dest_langues)) {
+ $langues = array_filter(array_unique(array_column($dest_langues, 'lang')));
+ }
- $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
- $test_mail = $envoyer_mail($destinataires, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
+ // trier les destinataires par langue et envoyer un mail par langue
+ foreach ($langues as $langue) {
+ $Tdest_langue = [];
+ foreach ($dest_langues as $dest) {
+ if ($dest['lang'] == '') {
+ $dest['lang'] = $langue_defaut;
+ }
+ if ($dest['lang'] == $langue)
+ $Tdest_langue[] = $dest['email'];
+ }
+ // envoi du mail dans cette langue
+ $html = recuperer_fond('modeles/gamucontact_message', ['id_message' => $id_message, 'lang' => $langue]);
+ $texte = Facteur::html2text($html);
+ $corps = array(
+ 'html' => $html,
+ 'texte' => $texte,
+ );
+ $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
+ $test_mail = $envoyer_mail($Tdest_langue, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
+ }
}
if (intval($id_message) and $test_mail) {
- $retour['message_ok'] = _T('gamucontact:formulaire_bien_envoyé');
+ $retour['message_ok'] = _T('gamucontact:formulaire_bien_envoye');
}
if ($redirect) {
diff --git a/gamucontact_options.php b/gamucontact_options.php
index 525369f..f708efc 100644
--- a/gamucontact_options.php
+++ b/gamucontact_options.php
@@ -21,7 +21,7 @@ $GLOBALS['gamucontact'] = [
'saisie' => 'input',
'options' => array(
'nom' => 'nom',
- 'label' => 'Votre Nom',
+ 'label' => '<:gamucontact:votre_nom:>',
'obligatoire' => 'oui',
//'fonction' => 'ma_super_fonction'
)
@@ -30,7 +30,7 @@ $GLOBALS['gamucontact'] = [
'saisie' => 'input',
'options' => array(
'nom' => 'email_contact',
- 'label' => 'Votre Email',
+ 'label' => '<:gamucontact:votre_email:>',
'obligatoire' => 'oui',
)
],
@@ -38,7 +38,7 @@ $GLOBALS['gamucontact'] = [
'saisie' => 'input',
'options' => array(
'nom' => 'objet',
- 'label' => 'Objet',
+ 'label' => '<:gamucontact:objet:>',
'obligatoire' => 'oui',
'class' => 'w100'
//'fonction' => 'ma_super_fonction'
@@ -48,7 +48,7 @@ $GLOBALS['gamucontact'] = [
'saisie' => 'textarea',
'options' => array(
'nom' => 'texte',
- 'label' => 'Message',
+ 'label' => '<:gamucontact:message:>',
'obligatoire' => 'oui',
'class' => 'w100',
'rows' => 4
diff --git a/lang/gamucontact_en.php b/lang/gamucontact_en.php
new file mode 100644
index 0000000..2cf2684
--- /dev/null
+++ b/lang/gamucontact_en.php
@@ -0,0 +1,42 @@
+ 'GamuContact',
+
+ // C
+ 'cfg_exemple' => 'Example',
+ 'cfg_exemple_explication' => 'Explication de cet exemple',
+ 'cfg_titre_parametrages' => 'Parameters',
+
+ // EE
+ 'envoyer' => "Send",
+ 'email' => 'Email',
+
+ // F
+ 'formulaire_bien_envoye' => 'Your message had been send.',
+ 'formulaire_contact' => 'Contact form',
+
+ // M
+ 'message' => 'Message',
+
+ // N
+ 'nom' => 'Name',
+
+ // O
+ 'objet' => 'Object',
+
+ // V
+ 'votre_nom' => 'Your name',
+ 'votre_email' => 'Your email',
+
+ // T
+ 'titre_page_configurer_gamucontact' => 'GamuContact',
+ 'telephone' => 'Phone number',
+);
diff --git a/lang/gamucontact_fr.php b/lang/gamucontact_fr.php
index 568d2db..bfd9941 100644
--- a/lang/gamucontact_fr.php
+++ b/lang/gamucontact_fr.php
@@ -17,7 +17,26 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
// EE
'envoyer' => "Envoyer",
+ 'email' => 'Email',
+
+ // F
+ 'formulaire_bien_envoye' => 'Votre message à bien été envoyé.',
+ 'formulaire_contact' => 'Formulaire de contact',
+
+ // M
+ 'message' => 'Message',
+
+ // N
+ 'nom' => 'Nom',
+
+ // O
+ 'objet' => 'Objet',
+
+ // V
+ 'votre_nom' => 'Votre nom',
+ 'votre_email' => 'Votre email',
// T
'titre_page_configurer_gamucontact' => 'GamuContact',
+ 'telephone' => 'Téléphone',
);
diff --git a/modeles/gamucontact_message.html b/modeles/gamucontact_message.html
index 0a70be5..7f549f2 100644
--- a/modeles/gamucontact_message.html
+++ b/modeles/gamucontact_message.html
@@ -10,14 +10,15 @@
[]
-