From bff40827057ae01a157339a047868d12ccda7e26 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Oct 2007 19:59:21 +0000 Subject: [PATCH] =?UTF-8?q?On=20gere=20les=20mails=20html=20dans=20le=20mo?= =?UTF-8?q?dule=20adh=E9rent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/adherent.class.php | 35 ++++++++++++++++++------- htdocs/adherents/card_subscriptions.php | 2 +- htdocs/adherents/fiche.php | 8 +++--- htdocs/conf/conf.class.php | 34 ------------------------ htdocs/lib/CMailFile.class.php | 14 ++++++++-- 5 files changed, 43 insertions(+), 50 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 83981aa92eb..3c9a53fd1b2 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -116,11 +116,17 @@ class Adherent /** - \brief Fonction envoyant un email au destinataire (recipient) avec le text fourni en parametre. - \param recipients destinataires - \param text contenu du message - \param subject sujet du message - \return int <0 si ko, >0 si ok + \brief Fonction envoyant un email a l'adherent avec le texte fourni en parametre. + \param text contenu du message + \param subject sujet du message + \param filename_list tableau de fichiers attachés + \param mimetype_list tableau des types des fichiers attachés + \param mimefilename_list tableau des noms des fichiers attachés + \param addr_cc email cc + \param addr_bcc email bcc + \param deliveryreceipt demande accusé réception + \param msgishtml 1=message is a html message, 0=message is not html, 2=auto detect + \return int <0 si ko, >0 si ok \remarks La particularite de cette fonction est de remplacer certains champs \remarks par leur valeur pour l'adherent en l'occurrence : \remarks %PRENOM% : est remplace par le prenom @@ -129,7 +135,9 @@ class Adherent \remarks %SERVEUR% : URL du serveur web \remarks etc.. */ - function send_an_email($recipients,$text,$subject="Vos coordonnees sur %SERVEUR%") + function send_an_email($text,$subject, + $filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(), + $addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0, $errors_to='') { global $conf,$langs; @@ -163,6 +171,16 @@ class Adherent $infos.= $langs->trans("Photo").": $this->photo\n"; $infos.= $langs->trans("Public").": ".yn($this->public)."\n"; + // Is it an HTML Content ? + $html = $msgishtml; + if ($msgishtml == 2) + { + if (eregi('prenom, $this->nom, @@ -181,7 +199,6 @@ class Adherent ); $texttosend = preg_replace ($patterns, $replace, $text); $subjectosend = preg_replace ($patterns, $replace, $subject); - $msgishtml=0; // Envoi mail confirmation include_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); @@ -190,8 +207,8 @@ class Adherent if ($conf->global->ADHERENT_MAIL_FROM) $from=$conf->global->ADHERENT_MAIL_FROM; $mailfile = new CMailFile($subjectosend,$this->email,$from,$texttosend, - array(),array(),array(), - '', '', 0, $msgishtml); + $filename_list,$mimetype_list,$mimefilename_list, + $addr_cc, $addr_bcc, $deliveryreceipt, $html); if ($mailfile->sendfile()) { return 1; diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 4e1fe29d4ec..9a8a4504ae8 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -142,7 +142,7 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio // Envoi mail if ($_POST["sendmail"]) { - $result=$adh->send_an_email($adh->email,$conf->global->ADHERENT_MAIL_COTIS,$conf->global->ADHERENT_MAIL_COTIS_SUBJECT); + $result=$adh->send_an_email($conf->global->ADHERENT_MAIL_COTIS,$conf->global->ADHERENT_MAIL_COTIS_SUBJECT,array(),array(),array(),"","",0,2); if ($result < 0) $errmsg=$adh->error; } diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 18f386fde60..5c9b1ad3c62 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -105,7 +105,7 @@ if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes') if ($adh->email) { - $result=$adh->send_an_email($adh->email,"Voici le contenu de votre fiche\n\n%INFOS%\n\n","Contenu de votre fiche adherent"); + $result=$adh->send_an_email("Voici le contenu de votre fiche\n\n%INFOS%\n\n","Contenu de votre fiche adherent"); } } @@ -410,11 +410,11 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P { if (isset($adht->mail_valid) && $adht->mail_valid) { - $result=$adh->send_an_email($adh->email,$adht->mail_valid,$conf->adherent->email_valid_subject); + $result=$adh->send_an_email($adht->mail_valid,$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); } else { - $result=$adh->send_an_email($adh->email,$conf->global->ADHERENT_MAIL_VALID,$conf->global->ADHERENT_MAIL_VALID_SUBJECT); + $result=$adh->send_an_email($conf->global->ADHERENT_MAIL_VALID,$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); } if ($result < 0) { @@ -460,7 +460,7 @@ if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' & { if ($adh->email && $_POST["send_mail"]) { - $result=$adh->send_an_email($adh->email,$conf->adherent->email_resil,$conf->adherent->email_resil_subject); + $result=$adh->send_an_email($conf->global->ADHERENT_MAIL_RESIL,$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,2); } if ($result < 0) { diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index b34ae04a77e..7160a08a805 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -439,40 +439,6 @@ class Conf $this->mailing->email_from=$conf->global->MAILING_EMAIL_FROM; } - // $this->adherent->email_resil, ... - if (defined("MAIN_MAIL_RESIL")) - { - $this->adherent->email_resil=MAIN_MAIL_RESIL; - } - if (defined("MAIN_MAIL_RESIL_SUBJECT")) - { - $this->adherent->email_resil_subject=MAIN_MAIL_RESIL_SUBJECT; - } - if (defined("MAIN_MAIL_VALID")) - { - $this->adherent->email_valid=MAIN_MAIL_VALID; - } - if (defined("MAIN_MAIL_VALID_SUBJECT")) - { - $this->adherent->email_valid_subject=MAIN_MAIL_VALID_SUBJECT; - } - if (defined("MAIN_MAIL_EDIT")) - { - $this->adherent->email_edit=MAIN_MAIL_EDIT; - } - if (defined("MAIN_MAIL_EDIT_SUBJECT")) - { - $this->adherent->email_edit_subject=MAIN_MAIL_EDIT_SUBJECT; - } - if (defined("MAIN_MAIL_NEW")) - { - $this->adherent->email_new=MAIN_MAIL_NEW; - } - if (defined("MAIN_MAIL_NEW_SUBJECT")) - { - $this->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT; - } - // Defini MAIN_GRAPH_LIBRARY if (! in_array($this->global->MAIN_GRAPH_LIBRARY, array('phplot','artichow'))) { diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index f04ff31cabb..6bb7c879dce 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -73,7 +73,7 @@ class CMailFile \param addr_cc email cc \param addr_bcc email bcc \param deliveryreceipt demande accusé réception - \param msgishtml message is a html message + \param msgishtml 1=message is a html message, 0=message is not html, 2=auto detect */ function CMailFile($subject,$to,$from,$msg, $filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(), @@ -99,7 +99,17 @@ class CMailFile if (eregi('^mac',PHP_OS)) $this->eol="\r"; // On defini si message HTML - $this->msgishtml = $msgishtml; + if ($msgishtml == 2) + { + $this->msgishtml = 0; + if (eregi('msgishtml = 1; + elseif (eregi('msgishtml = 1; + elseif (eregi('msgishtml = 1; + } + else + { + $this->msgishtml = $msgishtml; + } $smtp_headers = ""; $mime_headers = "";