On gere les mails html dans le module adhrent

This commit is contained in:
Laurent Destailleur 2007-10-04 19:59:21 +00:00
parent 0ab789c7bf
commit bff4082705
5 changed files with 43 additions and 50 deletions

View File

@ -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('<html',$text)) $html = 1;
elseif (eregi('<body',$text)) $html = 1;
elseif (eregi('<br',$text)) $html = 1;
}
if ($html) $infos = nl2br($infos);
$replace = array (
$this->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;

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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')))
{

View File

@ -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('<html',$msg)) $this->msgishtml = 1;
elseif (eregi('<body',$msg)) $this->msgishtml = 1;
elseif (eregi('<br',$msg)) $this->msgishtml = 1;
}
else
{
$this->msgishtml = $msgishtml;
}
$smtp_headers = "";
$mime_headers = "";