From 752a00ff4c3ca92c8e25b2cecaf10f742ad675f3 Mon Sep 17 00:00:00 2001 From: tofulm Date: Sat, 22 Apr 2023 16:59:53 +0200 Subject: [PATCH] feat: * le remplacement de @@nom@@ renvoi que la valeur du champ nom ou un espace pour supprimer @@nom@@ * le remplacement de @@prenom@@ renvoi que la valeur du champ prenom ou un espace pour supprimer @@prenom@@ --- inc/gamumail_remplacements.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) 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