diff --git a/base/gamumail.php b/base/gamumail.php index da0843f..f53ea4f 100644 --- a/base/gamumail.php +++ b/base/gamumail.php @@ -52,6 +52,7 @@ function gamumail_declarer_tables_objets_sql($tables) { 'titre' => 'varchar(255) NOT NULL DEFAULT ""', 'sujet' => 'varchar(255) NOT NULL DEFAULT ""', 'texte' => 'text NOT NULL DEFAULT ""', + 'id_docs' => 'text NOT NULL DEFAULT ""', 'statut' => 'varchar(20) DEFAULT "0" NOT NULL', 'maj' => 'TIMESTAMP' ), diff --git a/gamumail/html_footer.html b/gamumail/html_footer.html new file mode 100644 index 0000000..faf65ca --- /dev/null +++ b/gamumail/html_footer.html @@ -0,0 +1,3 @@ + + + diff --git a/gamumail/html_header.html b/gamumail/html_header.html new file mode 100644 index 0000000..b8757ff --- /dev/null +++ b/gamumail/html_header.html @@ -0,0 +1,12 @@ + + + + + + #NOM_SITE_SPIP + + +
+ [(#LOGO_SITE_SPIP|image_reduire{200})] +
+
diff --git a/gamumail_administrations.php b/gamumail_administrations.php index 511244d..bae7770 100644 --- a/gamumail_administrations.php +++ b/gamumail_administrations.php @@ -29,6 +29,7 @@ function gamumail_upgrade($nom_meta_base_version, $version_cible) { $maj['create'] = array(array('maj_tables', array('spip_gamumails'))); $maj['1.0.2'] = array(array('maj_tables', array('spip_gamumails'))); $maj['1.0.5'] = array(array('creer_compte_curl')); + $maj['1.0.6'] = array(array('maj_tables', array('spip_gamumails'))); function creer_compte_curl(){ $mdp = uniqid(uniqid(),1); diff --git a/gamumail_fonctions.php b/gamumail_fonctions.php index 9e58989..2530586 100644 --- a/gamumail_fonctions.php +++ b/gamumail_fonctions.php @@ -25,7 +25,7 @@ function gamumail_TabClient($objet, $id_objet, $champ){ **/ /** - * fonction appelée en fin de gamumail_charger() + * fonction appelée en fin de gamumail_charger_dist() * * $valeurs = array( * "slug" => $slug, @@ -69,13 +69,20 @@ function gamumail_verifier_dist($erreurs, $options, $slug, $auteur, $Tclient, $T * @param string $redirect * @param array $options * - * @return array $corps du message => $corps['html'] et $corps['texte'] + * @return array $corps + * $corps = [ + * 'html' => $html, + * 'texte' => $texte, + * 'cc' => $cc, + * 'cci' => $cci + * ]; * **/ function gamumail_traiter_dist($corps, $options, $slug, $auteur, $Tclient, $Tpdf, $redirect) { $html = $corps['html']; $html = str_replace('@@truc_a_remplacer@@', 'le machin qui remplace', $html); + include_spip('classes/facteur'); $texte = facteur_mail_html2text($html); $corps['html'] = $html; $corps['texte'] = $texte; diff --git a/inc/envoyer_gamumail.php b/inc/envoyer_gamumail.php new file mode 100644 index 0000000..0e17911 --- /dev/null +++ b/inc/envoyer_gamumail.php @@ -0,0 +1,170 @@ + 1) { + $cci = array_unique(array_merge($cci, $pour)); + $pour = [lire_config('facteur/adresse_envoi_email',lire_config('email_webmaster'))]; + } + + // docs attachés + function entier($val) { + return is_integer($val); + } + $Tid_doc = array_filter(explode(',', $id_docs), 'entier'); + //$Tpdfs_ok = _request('Tpdfs_ok'); + + $pieces_jointes = []; +/* + if ($f = charger_fonction('traiter_av_pdf', 'gamumail', true)) { + $options = $f($options, $auteur, $Tclient, $Tpdf); + } + if ($f = charger_fonction($slug . '_traiter_av_pdf', 'gamumail', true)) { + $options = $f($options, $auteur, $Tclient, $Tpdf); + } +*/ + // les documents joints + if (!empty($Tid_doc)) { + foreach ($Tid_doc as $id_document) { + $Tdocument = sql_fetsel('titre,fichier,extension','spip_documents','id_document='.intval($id_document)); + $destination = _DIR_IMG.$Tdocument['fichier']; + $extension = $Tdocument['extension']; + if ($Tdocument['titre']) { + $nom_fichier = $Tdocument['titre'] .".".$extension; + } else { + $nom_fichier = basename($Tdocument['fichier']); + } + $type_mime = bigup_get_mime_type_extension($extension); + $pieces_jointes[] = [ + 'chemin' => $destination, + 'nom' => $nom_fichier, + 'encodage' => 'base64', + 'mime' => $type_mime + ]; + } + } +/* + // les pdfs + $Tpdf_dell = []; + if (!empty($Tpdfs_ok) and is_array($Tpdfs_ok)) { + if (array_key_exists('fichier', $Tpdf)) { + $Tpdf = [$Tpdf]; + } + + $recup_pdf = charger_fonction('charger_pdf','inc'); + foreach ($Tpdfs_ok as $pdf) { + foreach ($Tpdf as $p) { + if ($p['fichier'] === $pdf) { + $c = $p['contexte']; + $nom = $p['nom']; + } + } + + $pdf = $recup_pdf($pdf, $c); + $nom_fichier = $nom.'.pdf'; + $destination = _DIR_TMP.basename($nom_fichier); + $Tpdf_dell[] = $destination; + file_put_contents($destination,$pdf); + $pieces_jointes[] = [ + 'chemin' => $destination, + 'nom' => $nom_fichier, + 'encodage' => 'base64', + 'mime' => 'application/pdf' + ]; + } + } +*/ + $html_header = ''; + if (find_in_path('gamumail/'.$slug .'_html_header.html')) { + $html_header = recuperer_fond('gamumail/'.$slug . '_html_header', $options); + } + elseif(find_in_path('gamumail/html_header.html')) { + $html_header = recuperer_fond('gamumail/html_header', $options); + } + $html_footer = ''; + if (find_in_path('gamumail/'.$slug . '_html_footer.html')) { + $html_footer = recuperer_fond('gamumail/'.$slug . '_html_footer', $options); + } + elseif (find_in_path('gamumail/html_footer.html')) { + $html_footer = recuperer_fond('gamumail/html_footer', $options); + } + $html = $html_header . $html . $html_footer; + + $corps = [ + 'html' => $html, + 'texte' => $texte, + 'cc' => $cc, + 'cci' => $cci, + 'pieces_jointes' => $pieces_jointes + ]; + + if ($f = charger_fonction('traiter', 'gamumail', true)) { + $corps = $f($corps, $options, $slug, $auteur, $Tclient, $Tpdf, $redirect); + } + if ($f = charger_fonction($slug . '_traiter', 'gamumail', true)) { + $corps = $f($corps, $options, $slug, $auteur, $Tclient, $Tpdf, $redirect); + } + + $envoyer_mail = charger_fonction('envoyer_mail', 'inc/'); + $ok = $envoyer_mail($pour, $sujet, $corps); + if (!$ok) { + spip_log("Erreur d'envoi du mail : ","gamumail"); + spip_log($corps,"roc"); + $retour['message_erreur'] = _T("gamumail:erreur_envoi_mail"); + } else { + $retour['message_ok'] = _T('gamumail:mail_envoye'); + } +/* + // on supprime les pdfs temporaires + if (count($Tpdf_dell)) { + foreach ($Tpdf_dell as $pdf) { + unlink($pdf); + } + } + + if ($redirect) { + $retour['redirect'] = $redirect; + } +*/ + + return $retour; +} \ No newline at end of file diff --git a/inclure/gamumail_config.html b/inclure/gamumail_config.html index 34612fe..e1e2512 100644 --- a/inclure/gamumail_config.html +++ b/inclure/gamumail_config.html @@ -3,6 +3,9 @@ display: inline-block; width: 100%; } + .objet--mail { + margin-top: 1.5rem; + } .well { background-color: #cecece; margin: 10px auto; @@ -53,6 +56,9 @@ width: 2rem; height: 2rem; } + span > em { + font-size: 85%; + }
@@ -84,17 +90,28 @@
[(#AUTORISER{webmestre}|oui) -
+
Slug : - [(#SLUG|sinon{cliquez})] + [(#SLUG|sinon{Double clic pour éditer})]
]
Objet : - [(#SUJET|sinon{cliquez})] + [(#SUJET|sinon{Double clic pour éditer})] +
+
+ Message : +
+ [(#TEXTE|sinon{Double clic pour éditer})] +
+
+
+ Documents attachés : liste d'id_document séparés par une virgule , +
+ [(#ID_DOCS|sinon{Double clic pour éditer})] +
+
- Message : -
[(#TEXTE|sinon{cliquez})]
[(#REM) Pour l'instant, inutile
diff --git a/lang/gamumail_fr.php b/lang/gamumail_fr.php index f77c4b5..0b0fbd3 100644 --- a/lang/gamumail_fr.php +++ b/lang/gamumail_fr.php @@ -20,6 +20,8 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( //EE 'envoyer' => 'Envoyer', "erreur_envoi_mail" => "Erreur dans l'envoi de votre mail", + 'erreur_format_slug' => 'Le slug est un identifiant qui ne peut contenir que des chiffres, lettres et _ ou -', + // I 'icone_creer_gamumail' => 'Créer un gamumail', @@ -32,6 +34,9 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( //MM "mail_envoye" => "Votre message a bien été envoyé", + // P + 'pas_de_slug' => 'Pas de slug avec cet identifiant', + // R 'retirer_lien_gamumail' => 'Retirer ce gamumail', 'retirer_tous_liens_gamumails' => 'Retirer tous les gamumails', diff --git a/paquet.xml b/paquet.xml index 7592001..c4031ff 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,12 +1,12 @@ GamuMail