From 57e1466497e30971e9c288c04d02708c70199848 Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 9 Nov 2023 14:23:36 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20la=20possibilit=C3=A9=20de=20jo?= =?UTF-8?q?indre=20des=20fichiers=20t=C3=A9l=C3=A9verser.=20Attention,=20c?= =?UTF-8?q?es=20fichiers=20ne=20sont=20pas=20sauvegard=C3=A9s.=20Fichiers?= =?UTF-8?q?=20accept=C3=A9s=20:=20=20=20=20=20*=20images=20=20=20=20=20*?= =?UTF-8?q?=20pdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formulaires/gamumail.html | 131 +++++++++--------- formulaires/gamumail.php | 47 ++++++- .../inc-bigup_liste_fichiers_gamumail.html | 48 +++++++ lang/gamumail_fr.php | 1 + paquet.xml | 2 +- 5 files changed, 162 insertions(+), 67 deletions(-) create mode 100644 inclure/inc-bigup_liste_fichiers_gamumail.html diff --git a/formulaires/gamumail.html b/formulaires/gamumail.html index e11d38d..b3e240e 100644 --- a/formulaires/gamumail.html +++ b/formulaires/gamumail.html @@ -110,73 +110,80 @@ - #SET{fichier,#SLUG|concat{_soustexte}} - [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) - - ] - - #SET{name,Tpdfs_ok} - -

<:gamumail:pdf_envoyes:>

-
- #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} - #SET{obli,"obligatoire"} -
- -
- - [(#SET{url_pdf, #URL_PAGE{spipdf} - |parametre_url{spipdf, #VALEUR|table_valeur{fichier}} - |parametre_url{lang, #GET{lang_dest}} - })] - - [(#SET{url_pdf,[(#GET{url_pdf}|parametre_url{#CLE,#VALEUR})]})] - - +
+
+ #SET{fichier,#SLUG|concat{_soustexte}} + [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) + + ] + #SET{name,Tpdfs_ok} + +

<:gamumail:pdf_envoyes:>

+
+ #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} + #SET{obli,"obligatoire"} +
+ +
+ + [(#SET{url_pdf, #URL_PAGE{spipdf} + |parametre_url{spipdf, #VALEUR|table_valeur{fichier}} + |parametre_url{lang, #GET{lang_dest}} + })] + + [(#SET{url_pdf,[(#GET{url_pdf}|parametre_url{#CLE,#VALEUR})]})] + + +
+
- +
+
+ + #SET{name,docs_spip} +

<:gamumail:documents_attaches:>

+
+ #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} +
+
+ [(#GET{erreurs})] + + +
+ +
+ +
+
+
+
+ #SET{fichier,all_fichiers} + [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) + #SET{erreurs,#ENV**{erreurs}|table_valeur{Tid_doc}} + [(#GET{erreurs})] + + ] + + #SET{fichier,#SLUG|concat{_fichiers}} + [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) + #SET{erreurs,#ENV**{erreurs}|table_valeur{Tid_doc}} + [(#GET{erreurs})] +

<:gamumail:fichiers_annexes:>

+ + ] +
+
+

<:gamumail:fichiers_televerser:>

+
- - #SET{name,docs_spip} -

<:gamumail:documents_attaches:>

-
- #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} -
-
- [(#GET{erreurs})] - - -
- -
- -
-
-
-
- #SET{fichier,all_fichiers} - [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) - #SET{erreurs,#ENV**{erreurs}|table_valeur{Tid_doc}} - [(#GET{erreurs})] - - ] - - #SET{fichier,#SLUG|concat{_fichiers}} - [(#CHEMIN{gamumail/#GET{fichier}.html}|oui) - #SET{erreurs,#ENV**{erreurs}|table_valeur{Tid_doc}} - [(#GET{erreurs})] -

<:gamumail:fichiers_annexes:>

- - ] - -
+
diff --git a/formulaires/gamumail.php b/formulaires/gamumail.php index 62ecfec..79776e1 100644 --- a/formulaires/gamumail.php +++ b/formulaires/gamumail.php @@ -112,6 +112,8 @@ function formulaires_gamumail_charger_dist($slug, $destinataires = 0, $Tclient = $valeurs = $f($valeurs, $options, $slug, $destinataires, $Tclient, $Tpdf, $redirect); } + $valeurs['_bigup_rechercher_fichiers'] = true; + return $valeurs; } @@ -197,6 +199,21 @@ function formulaires_gamumail_verifier_dist($slug, $destinataires = 0, $Tclient $erreurs = $f($erreurs, $options, $slug, $destinataires, $Tclient, $Tpdf, $redirect); } + /* + * Verification des fichiers téléversés + */ + defined('_IMG_MAX_WIDTH') || define('_IMG_MAX_WIDTH', 2048); + $options = [ + 'mime' => 'tout_mime', + 'dimension_max' => [ + 'largeur' => 10000, + 'hauteur' => 10000, + ] + ]; + + $bigform = charger_fonction('bigform_verifier','inc'); + $bigform($options,$erreurs); + return $erreurs; } @@ -233,12 +250,22 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = } } + /* + * on recupère d'éventuels fichiers téléversés + */ + include_spip('inc/joindre_document'); + set_request('joindre_upload','ok'); + $Tfiles = joindre_trouver_fichier_envoye(); + if (!is_array($Tfiles)) { + $Tfiles = []; + } + if (empty($envoi_separe)) { - gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, $retour); + gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $Tfiles, $redirect, $retour); } else { $ok = true; foreach ($destinataires as $d) { - $r = gamuSend($slug, $options, [$d], $Tclient, $Tpdf, $redirect); + $r = gamuSend($slug, $options, [$d], $Tclient, $Tpdf, $Tfiles, $redirect); if (!$r) { $ok = false; } @@ -263,7 +290,7 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = } -function gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, &$retour = []) { +function gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $Tfiles, $redirect, &$retour = []) { $cc = _request('cc'); $cci = _request('cci'); @@ -341,6 +368,19 @@ function gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, & ]; } } + + // les documents par tFiles (téléversés) + if (!empty($Tfiles)) { + foreach ($Tfiles as $key => $fichier) { + $pieces_jointes[] = [ + 'chemin' => $fichier['tmp_name'], + 'nom' => $fichier['name'], + 'encodage' => 'base64', + 'mime' => $fichier['type'] + ]; + } + } + // les pdfs générés en fonction du contexte $Tpdf_del = []; if (!empty($Tpdfs_ok) and is_array($Tpdfs_ok)) { @@ -437,7 +477,6 @@ function gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, & $corps['repondre_a'] = $repondre_a; } - // surcharges de traiter : d'abord les surcharges pour tous les slugs (tous_traiter.php) puis les spécifiques par slug (nom_slug_traiter.php) if ($f = charger_fonction('traiter', 'gamumail', true)) { $corps = $f($corps, $options, $slug, $destinataires, $Tclient, $Tpdf, $redirect); diff --git a/inclure/inc-bigup_liste_fichiers_gamumail.html b/inclure/inc-bigup_liste_fichiers_gamumail.html new file mode 100644 index 0000000..2729dbe --- /dev/null +++ b/inclure/inc-bigup_liste_fichiers_gamumail.html @@ -0,0 +1,48 @@ + +[(#REM) + surcharge du fichier de bigform : + - inclure/inc-bigup_liste_fichiers.html +] + +
+ +
+
+ [(#VALEUR{bigup/vignette/data}|oui) +
+ +
] + [(#VALEUR{bigup/vignette/data}|non) +
] +
+ #NAME + [(#SIZE|taille_en_octets)] +
+
+ +
+
+
+ +
+
+ diff --git a/lang/gamumail_fr.php b/lang/gamumail_fr.php index 9e24363..eea0323 100644 --- a/lang/gamumail_fr.php +++ b/lang/gamumail_fr.php @@ -39,6 +39,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( // F 'fichiers_annexes' => 'Fichiers annexes', + 'fichiers_televerser' => 'Fichiers téléversés', // I 'icone_creer_gamumail' => 'Créer un gamumail', diff --git a/paquet.xml b/paquet.xml index bf8cc91..41f595c 100644 --- a/paquet.xml +++ b/paquet.xml @@ -15,7 +15,7 @@ GNU/GPL - +