diff --git a/base/gamumail.php b/base/gamumail.php index bb89929..4a3016c 100644 --- a/base/gamumail.php +++ b/base/gamumail.php @@ -56,17 +56,18 @@ function gamumail_declarer_tables_objets_sql($tables) { 'statut' => 'varchar(20) DEFAULT "0" NOT NULL', 'public' => 'varchar(20) DEFAULT "oui" NOT NULL', 'editable' => 'varchar(5) DEFAULT "oui" NOT NULL', + 'date' => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"', 'maj' => 'TIMESTAMP', - 'rang' => 'smallint(6) NOT NULL' + 'rang' => 'smallint(6) NOT NULL' ), 'key' => array( - 'PRIMARY KEY' => 'id_gamumail', - 'KEY statut' => 'statut', + 'PRIMARY KEY' => 'id_gamumail', + 'KEY statut' => 'statut', ), - 'titre' => 'slug AS titre, "" AS lang', + // 'titre' => 'slug AS titre, "" AS lang', #'date' => '', - 'champs_editables' => array('slug', 'sujet', 'texte','titre', 'editable'), - 'champs_versionnes' => array('slug', 'sujet', 'texte','titre', 'editable'), + 'champs_editables' => array('slug', 'sujet', 'texte','titre', 'editable', 'public', 'id_docs', 'rang', 'statut', 'date'), + 'champs_versionnes' => array('slug', 'sujet', 'texte','titre', 'editable', 'public', 'id_docs', 'rang', 'statut', 'date'), 'rechercher_champs' => array("slug" => 8), 'tables_jointures' => array(), 'statut'=> array( diff --git a/css/gamumail.css b/css/gamumail.css index 83b76dd..39dbfdf 100644 --- a/css/gamumail.css +++ b/css/gamumail.css @@ -20,14 +20,17 @@ overflow: hidden; margin: 3px 0; } + .tag-editor div { float: left; padding: 0 4px; } + .tag-editor .placeholder { padding: 0 8px; color: #bbb; } + .tag-editor .tag-editor-spacer { padding: 0; width: 8px; @@ -35,6 +38,7 @@ color: transparent; background: none; } + .tag-editor input { vertical-align: inherit; border: 0; @@ -50,15 +54,18 @@ background: none; color: #444; } + /* hide original input field or textarea visually to allow tab navigation */ .tag-editor-hidden-src { position: absolute !important; left: -99999px; } + /* hide IE10 "clear field" X */ .tag-editor ::-ms-clear { display: none; } + /* tag style */ .tag-editor .tag-editor-tag { /*padding-left: 5px; color: #46799b; background: #e0eaf1; white-space: nowrap;*/ @@ -71,6 +78,7 @@ cursor: pointer; border-radius: 4px 0 0 4px; } + /* delete icon */ /*.tag-editor .tag-editor-delete { background: #e0eaf1; cursor: pointer; border-radius: 0 2px 2px 0; padding-left: 3px; padding-right: 4px; }*/ .tag-editor .tag-editor-delete { @@ -80,10 +88,12 @@ padding-left: 3px; padding-right: 4px; } + .tag-editor .tag-editor-delete i { line-height: 18px; display: inline-block; } + /*.tag-editor .tag-editor-delete i:before { font-size: 16px; color: #8ba7ba; content: "×"; font-style: normal; }*/ .tag-editor .tag-editor-delete i:before { font-size: 16px; @@ -91,14 +101,17 @@ content: '×'; font-style: normal; } + .tag-editor .tag-editor-delete:hover i:before { color: #d65454; } -.tag-editor .tag-editor-tag.active + .tag-editor-delete, -.tag-editor .tag-editor-tag.active + .tag-editor-delete i { + +.tag-editor .tag-editor-tag.active+.tag-editor-delete, +.tag-editor .tag-editor-tag.active+.tag-editor-delete i { visibility: hidden; cursor: text; } + .tag-editor .tag-editor-tag.active { background: none !important; } @@ -111,9 +124,11 @@ cursor: default; font-size: 14px; } + .ui-front { z-index: 9999; } + .ui-menu { list-style: none; padding: 1px; @@ -121,21 +136,26 @@ display: block; outline: none; } + .ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px 0.4em; line-height: 1.4; - min-height: 0; /* support: IE7 */ + min-height: 0; + /* support: IE7 */ } + .ui-widget-content { border: 1px solid #bbb; background: #fff; color: #555; } + .ui-widget-content a { color: #46799b; } + .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, @@ -143,6 +163,7 @@ .ui-widget-header .ui-state-focus { background: #e0eaf1; } + .ui-helper-hidden-accessible { display: none; } @@ -151,47 +172,73 @@ .formulaire_gamumail { padding-top: 0; } + .formulaire_gamumail .editer { padding-top: 0; } + .editer_pour { display: flex; } + .editer_pour label { width: 50px; } + +.editer_envoi_separe { + display: flex; +} + .editer_cc { display: flex; } + .editer_cc label { width: 50px; } + .editer_cci { display: flex; } + .editer_cci label { width: 50px; } + +.editer_repondre_a { + display: flex; +} + +.editer_repondre_a label { + width: 120px; +} + .reponse_formulaire { padding: 1rem; margin-bottom: 2rem; font-weight: bold; } -.reponse_formulaire_erreur, .editer .erreur_message { + +.reponse_formulaire_erreur, +.editer .erreur_message { background-color: #f7d1d1; border: solid 2px #f00; display: block; } + .reponse_formulaire_ok { background-color: #c4ecd6; - border: solid 2px #080; + border: solid 2px #080; } + .remplacements_slugs { margin-top: 3rem; } + .formulaire_gamumail .boutons { margin-top: 3rem; } + .formulaire_gamumail .btn { font-size: 3rem; } diff --git a/formulaires/gamumail.html b/formulaires/gamumail.html index b54bad7..d369028 100644 --- a/formulaires/gamumail.html +++ b/formulaires/gamumail.html @@ -33,6 +33,25 @@ + +
+ #SET{name,envoi_separe} + #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} + #SET{obli,"obligatoire"} +
+ +
+ + +
+
+ + +
+
+
+ +
#SET{name,cc} @@ -56,6 +75,19 @@
+ +
+ #SET{name,repondre_a} + #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} + #SET{obli,"obligatoire"} +
+ + [(#GET{erreurs})] + +
+
+ +
#SET{name,sujet} #SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} @@ -130,6 +162,13 @@
+ #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}} diff --git a/formulaires/gamumail.php b/formulaires/gamumail.php index c42b857..25c114f 100644 --- a/formulaires/gamumail.php +++ b/formulaires/gamumail.php @@ -27,6 +27,7 @@ function formulaires_gamumail_charger_dist($slug, $destinataires = 0, $Tclient = $Tcc = lire_config('gamumail/mail_cc') !== '' ? explode(',', lire_config('gamumail/mail_cc', '')) : []; $Tcci = lire_config('gamumail/mail_cci') !== '' ? explode(',', lire_config('gamumail/mail_cci', '')) : []; + $Trepondre_a = lire_config('gamumail/mail_repondre_a') !== '' ? explode(',', lire_config('gamumail/mail_repondre_a', '')) : []; if (!empty($destinataires) and !is_array($destinataires)) { $destinataires = explode(',', $destinataires); @@ -70,12 +71,10 @@ function formulaires_gamumail_charger_dist($slug, $destinataires = 0, $Tclient = $Tpdf = [$Tpdf]; } foreach ($Tpdf as $id => $pdf) { - //$TFichierPdf[] = $pdf['fichier']; $TFichierPdf[$id] = $pdf; - //$options[$id] = $pdf; } } -//var_dump($Tcc); + $gamuMail = sql_fetsel('sujet, texte, id_docs', 'spip_gamumails', 'slug='.sql_quote($slug)); $texte = $gamuMail['texte'] ?? ''; $sujet = $gamuMail['sujet'] ?? ''; @@ -91,11 +90,13 @@ function formulaires_gamumail_charger_dist($slug, $destinataires = 0, $Tclient = 'pour' => implode(',', $Tmails), 'cc' => implode(',', $Tcc), 'cci' => implode(',', $Tcci), + 'repondre_a' => implode(',', $Trepondre_a), 'TFichierpdfs' => $TFichierPdf, 'Tpdfs_ok' => [], 'docs_spip' => $gamuMail['id_docs'] ?? '', 'Tid_fichiers' => [], - 'options' => $options + 'options' => $options, + 'envoi_separe' => $options['envoi_separe'] ?? '' ); // surcharges charger : d'abord les surcharges pour tous les slugs (tous_charge.php) puis les spécifiques par slug (nom_slug_charger.php) @@ -209,21 +210,12 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = include_spip('inc/texte'); include_spip('classes/facteur'); - $retour = array(); + $retour = []; - $pour = _request('pour'); - $cc = _request('cc'); - $cci = _request('cci'); - $sujet = _request('sujet'); - $html = propre(_request('texte')); - $docs_spip = _request('docs_spip'); - $Tpdfs_ok = _request('Tpdfs_ok'); - $Tid_doc = _request('Tid_doc'); - $texte = facteur_mail_html2text($html); + $envoi_separe = _request('envoi_separe') ?? ''; + $pour = _request('pour'); $pour = explode(',', $pour); - $cc = explode(',', $cc); - $cci = explode(',', $cci); $destinataires = []; foreach ($pour as $dest) { @@ -231,12 +223,58 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = if ($mail = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.$dest)) { $destinataires[] = $mail; } - } - elseif (email_valide($dest)) { + } elseif (email_valide($dest)) { $destinataires[] = $dest; } } + if (empty($envoi_separe)) { + gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, $retour); + } else { + $ok = true; + foreach ($destinataires as $d) { + $r = gamuSend($slug, $options, [$d], $Tclient, $Tpdf, $redirect); + if (!$r) { + $ok = false; + } + } + if (!$ok) { + $retour['message_erreur'] = _T("gamumail:erreur_envoi_mail"); + } + else { + $retour['message_ok'] = _T('gamumail:mail_envoye'); + + // dans le retour message_ok ajouter que le gamumail est OK + $retour['message_ok'] .= '@@gamumail_ok'; + } + } + + + if ($redirect AND $redirect != '') { + $retour['redirect'] = $redirect; + } + + return $retour; +} + + +function gamuSend($slug, $options, $destinataires, $Tclient, $Tpdf, $redirect, &$retour = []) { + + $cc = _request('cc'); + $cci = _request('cci'); + $repondre_a = _request('repondre_a'); + + $cc = explode(',', $cc); + $cci = explode(',', $cci); + $repondre_a = explode(',', $repondre_a); + + $sujet = _request('sujet'); + $html = propre(_request('texte')); + $docs_spip = _request('docs_spip'); + $Tpdfs_ok = _request('Tpdfs_ok'); + $Tid_doc = _request('Tid_doc'); + $texte = facteur_mail_html2text($html); + $pieces_jointes = []; if ($f = charger_fonction('traiter_av_pdf', 'gamumail', true)) { $options = $f($options, $destinataires, $Tclient, $Tpdf); @@ -250,7 +288,7 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = if (!empty($docs_spip)) { foreach ($docs_spip as $id_document) { $protected = ''; - $Tdocument = sql_fetsel('*','spip_documents','id_document='.intval($id_document)); + $Tdocument = sql_fetsel('*','spip_documents','id_document='.intval($id_document)); if ( array_key_exists('protected', $Tdocument) and $Tdocument['protected'] === 'oui' @@ -323,6 +361,20 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = ]; } } + + if ($f = charger_fonction('traiter_pieces_jointes', 'gamumail', true)) { + $pc = $f($slug, $options, $destinataires, $Tclient, $Tpdf); + if (!empty($pc)) { + $pieces_jointes[] = $pc; + } + } + if ($f = charger_fonction($slug . '_traiter_pieces_jointes', 'gamumail', true)) { + $pc = $f($options, $destinataires, $Tclient, $Tpdf); + if (!empty($pc)) { + $pieces_jointes[] = $pc; + } + } + $html_header = ''; if (find_in_path('gamumail/'.$slug .'_html_header.html')) { $html_header = recuperer_fond('gamumail/'.$slug . '_html_header', $options); @@ -360,6 +412,10 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = 'cci' => $cci, 'pieces_jointes' => $pieces_jointes ]; + if ($repondre_a) { + $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)) { @@ -377,7 +433,8 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = ]); $sujet = $remplacement_generiques($args, $sujet); -//var_dump($corps);die; + $args['corps'] = $corps; + $args['sujet'] = $sujet; // envoyer ! $envoyer_mail = charger_fonction('envoyer_mail', 'inc/'); @@ -407,9 +464,5 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = } } - if ($redirect AND $redirect != '') { - $retour['redirect'] = $redirect; - } - - return $retour; + return $ok; } diff --git a/gamumail/remplacements_slugs.html b/gamumail/remplacements_slugs.html index b708955..b0bdd04 100644 --- a/gamumail/remplacements_slugs.html +++ b/gamumail/remplacements_slugs.html @@ -1,6 +1,6 @@ [(#REM) la liste des remplacements joués dans tous les slugs GamuMail - + tous ceux des plugins qui les documentent via $GLOBALS'remplacements_gamumail' + + tous ceux des plugins qui les documentent via $GLOBALS'remplacements_gamumail' inclure pour la page de configuration des gamumails @@ -9,8 +9,11 @@

<:gamumail:remplacements_disponibles:>

    -
  • [(#CLE)] : [(#VALEUR)]
  • +
  • [(#CLE)] : [(#VALEUR)]
<:gamumail:avertissement_remplacements:> + + + diff --git a/gamumail_administrations.php b/gamumail_administrations.php index 3adb9b0..0bcc4ad 100644 --- a/gamumail_administrations.php +++ b/gamumail_administrations.php @@ -36,8 +36,8 @@ function gamumail_upgrade($nom_meta_base_version, $version_cible) { $maj['1.0.11'] = array( array('maj_tables', array('spip_gamumails'))); $maj['1.0.12'] = array(array('creer_compte_curl')); $maj['1.0.14'] = array(array('maj_tables', array('spip_gamumails'))); - $maj['1.0.15'] = array(array('maj_tables', array('spip_gamumails'))); - + $maj['1.0.16'] = array(array('maj_tables', array('spip_gamumails'))); + include_spip('base/upgrade'); maj_plugin($nom_meta_base_version, $version_cible, $maj); @@ -55,7 +55,9 @@ function creer_compte_curl(){ 'statut' => '1comite' ]; - $id_auteur = sql_insertq('spip_auteurs', $set); + include_spip('action/editer_auteur'); + $id_auteur = auteur_inserer(null, $set); + if ($id_auteur) { include_spip('inc/config'); ecrire_config('curl_login', $set['login']); diff --git a/inc/charger_pdf.php b/inc/charger_pdf.php index 8a67873..ec1d35c 100644 --- a/inc/charger_pdf.php +++ b/inc/charger_pdf.php @@ -7,19 +7,9 @@ function inc_charger_pdf_dist($fichier_pdf, $contexte = []){ $login = lire_config('curl_login'); $password = lire_config('curl_mdp'); - $url = $GLOBALS['meta']['adresse_site'].'/spip.php?page=spipdf&spipdf='.$fichier_pdf; - if (is_array($contexte) and count($contexte)) { - foreach ($contexte as $champ => $val) { -/* if (intval($val) === $val) { - // if (intval($val)) { - $val = intval($val); - } else { - $val = "$val"; - } -*/ - $url .= "&$champ=$val"; - } - } + + $contexte['spipdf'] = $contexte['spipdf'] ?? $fichier_pdf ; + $url = generer_url_public('spipdf', $contexte, true, false); $CurlConnect = curl_init(); // pour une connexion https locale avec certificat auto-signé @@ -34,8 +24,8 @@ function inc_charger_pdf_dist($fichier_pdf, $contexte = []){ $retour = curl_exec($CurlConnect); if( ! $retour = curl_exec($CurlConnect)) { trigger_error(curl_error($CurlConnect)); - } + } curl_close($CurlConnect); - + return $retour; } diff --git a/inc/gamumail_remplacements.php b/inc/gamumail_remplacements.php index 220f06c..f587e56 100644 --- a/inc/gamumail_remplacements.php +++ b/inc/gamumail_remplacements.php @@ -14,22 +14,21 @@ if (!defined('_ECRIRE_INC_VERSION')) { **/ function inc_gamumail_remplacements_dist($args, $html) { /** - * @@nom@@ => Prenom Nom | Nom (gère la présence/absence du champ prenom dans spip_auteurs) + * @@nom@@ => $nom ou un espace pour vider le champ @@nom@@ **/ - $nom = sql_getfetsel('nom', 'spip_auteurs', 'email='.sql_quote($args['destinataires'][0])); - $prenom = $nom; + $nom = sql_getfetsel('nom', 'spip_auteurs', 'email='.sql_quote($args['destinataires'][0])) ?? ' '; + $html = gamumail_remplacer_modele('nom', ucwords($nom), $html); + + /** + * @@prenom@@ => $prenom ou un espace pour vider le champ @@prenom@@ + **/ + $prenom = ' '; $trouver_table = charger_fonction('trouver_table', 'base'); $desc = $trouver_table('spip_auteurs'); - if (array_key_exists('prenom', $desc['field']) - and $prenom = sql_getfetsel('prenom', 'spip_auteurs', 'email='.sql_quote($args['destinataires'][0]))) { - $nom = $prenom.' '.$nom; - } - if ($nom) { - $html = gamumail_remplacer_modele('nom', ucwords($nom), $html); - } - if ($prenom) { - $html = gamumail_remplacer_modele('prenom', ucwords($prenom), $html); + if (array_key_exists('prenom', $desc['field'])) { + $prenom = sql_getfetsel('prenom', 'spip_auteurs', 'email='.sql_quote($args['destinataires'][0])) ?? ' '; } + $html = gamumail_remplacer_modele('prenom', ucwords($prenom), $html); /** * @@url_site@@ => URL du site diff --git a/js/toClip.js b/js/toClip.js new file mode 100644 index 0000000..5b23a14 --- /dev/null +++ b/js/toClip.js @@ -0,0 +1,15 @@ +jQuery(function ($) { + $('.toClip').on('mousedown', function (e) { + e.preventDefault(); + const t = $(this).data('clipboard-text') ?? $(this).text(); + navigator.clipboard.writeText(t).then(() => { + barre_inserer(t); + const html = `✔ copié`; + $(this).append(html); + setTimeout(() => { + $(this).children('.copierOk').remove(); + }, 1000); + }); + }); +}); + diff --git a/paquet.xml b/paquet.xml index 20c49e1..da1d8eb 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,12 +1,12 @@ GamuMail