Add a warning to avoid to forget to attach file
This commit is contained in:
parent
36bcf6c05e
commit
473345d839
@ -17,20 +17,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/html.formmail.class.php
|
||||
\brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/html.formmail.class.php
|
||||
* \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
|
||||
|
||||
|
||||
/** \class FormMail
|
||||
\brief Classe permettant la generation du formulaire html d'envoi de mail unitaire
|
||||
\remarks Utilisation: $formail = new FormMail($db)
|
||||
\remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs
|
||||
\remarks $formmail->show_form() affiche le formulaire
|
||||
*/
|
||||
* \brief Classe permettant la generation du formulaire html d'envoi de mail unitaire
|
||||
* \remarks Utilisation: $formail = new FormMail($db)
|
||||
* \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs
|
||||
* \remarks $formmail->show_form() affiche le formulaire
|
||||
*/
|
||||
class FormMail
|
||||
{
|
||||
var $db;
|
||||
@ -65,9 +65,9 @@ class FormMail
|
||||
|
||||
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param DB handler d'acces base de donnee
|
||||
*/
|
||||
* \brief Constructeur
|
||||
* \param DB handler d'acces base de donnee
|
||||
*/
|
||||
function FormMail($DB)
|
||||
{
|
||||
$this->db = $DB;
|
||||
@ -176,7 +176,7 @@ class FormMail
|
||||
$form=new Form($DB);
|
||||
|
||||
print "\n<!-- Debut form mail -->\n";
|
||||
print "<form method=\"post\" ENCTYPE=\"multipart/form-data\" action=\"".$this->param["returnurl"]."\">\n";
|
||||
print "<form method=\"POST\" name=\"mailform\" enctype=\"multipart/form-data\" action=\"".$this->param["returnurl"]."\">\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
foreach ($this->param as $key=>$value)
|
||||
{
|
||||
@ -475,7 +475,13 @@ class FormMail
|
||||
}
|
||||
|
||||
print "<tr><td align=center colspan=2><center>";
|
||||
print "<input class=\"button\" type=\"submit\" name=\"sendmail\" value=\"".$langs->trans("SendMail")."\">";
|
||||
print "<input class=\"button\" type=\"submit\" name=\"sendmail\" value=\"".$langs->trans("SendMail")."\"";
|
||||
// Add a javascript test to avoid to forget to submit file before sending email
|
||||
if ($this->withfile == 2 && $conf->use_javascript_ajax)
|
||||
{
|
||||
print ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
|
||||
}
|
||||
print ">";
|
||||
if ($this->withcancel)
|
||||
{
|
||||
print " ";
|
||||
|
||||
@ -47,6 +47,7 @@ ErrorFailedToSaveFile=Error, failed to save file.
|
||||
ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported.
|
||||
ErrorImageFormatNotSupported=Your PHP does not support functions to convert images of this format.
|
||||
BackgroundColorByDefault=Default background color
|
||||
FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this.
|
||||
NbOfEntries=Nb of entries
|
||||
GoToWikiHelpPage=Read online help (need Internet access)
|
||||
GoToHelpPage=Read help
|
||||
|
||||
@ -47,6 +47,7 @@ ErrorFailedToSaveFile=Erreur, l'enregistrement du fichier a échoué.
|
||||
ErrorOnlyPngJpgSupported=Erreur, seuls les formats images .jpg et .png sont supportés.
|
||||
ErrorImageFormatNotSupported=Votre PHP ne supporte pas les fonctions de conversion de ce format d'image.
|
||||
BackgroundColorByDefault=Couleur de fond
|
||||
FileWasNotUploaded=Un fichier a été sélectionné pour attachement mais n'a pas encore été uploadé. Cliquer sur "Joindre ce fichier" pour cela.
|
||||
NbOfEntries=Nb d'entrées
|
||||
GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet)
|
||||
GoToHelpPage=Consulter l'aide
|
||||
|
||||
@ -196,7 +196,7 @@ class CMailFile
|
||||
$this->css = $css;
|
||||
$this->buildCSS();
|
||||
}
|
||||
|
||||
|
||||
$msg = $this->html;
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Send mail that was prepared by constructor
|
||||
*
|
||||
*
|
||||
* @return boolean True if mail sent, false otherwise
|
||||
*/
|
||||
function sendfile()
|
||||
@ -597,7 +597,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Read a file on disk and return encoded content for emails
|
||||
*
|
||||
*
|
||||
* @param sourcefile
|
||||
* @return <0 if KO, encoded string if OK
|
||||
*/
|
||||
@ -650,7 +650,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Create SMTP headers
|
||||
*
|
||||
*
|
||||
* @return smtp headers
|
||||
*/
|
||||
function write_smtpheaders()
|
||||
@ -680,7 +680,7 @@ class CMailFile
|
||||
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: 8bit".$this->eol;
|
||||
|
||||
$out.=$this->eol;
|
||||
//$out.=$this->eol; // Comment this to try to solve pb of hidden attached files
|
||||
dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out);
|
||||
return $out;
|
||||
}
|
||||
@ -688,7 +688,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Creation header MIME
|
||||
*
|
||||
*
|
||||
* @param filename_list
|
||||
* @param mimefilename_list
|
||||
* @return mime headers
|
||||
@ -716,7 +716,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Permet d'ecrire le corps du message (mode = 'mail')
|
||||
*
|
||||
*
|
||||
* @param msgtext
|
||||
*/
|
||||
function write_body($msgtext)
|
||||
@ -813,7 +813,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Permet d'attacher un fichier
|
||||
*
|
||||
*
|
||||
* @param filename_list Tableau
|
||||
* @param mimetype_list Tableau
|
||||
* @param mimefilename_list Tableau
|
||||
@ -857,7 +857,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Permet d'attacher une image
|
||||
*
|
||||
*
|
||||
* @param images_list Tableau
|
||||
* @return out Chaine images encodees
|
||||
*/
|
||||
@ -963,7 +963,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Recherche la presence d'images dans le message html
|
||||
*
|
||||
*
|
||||
* @param images_dir Emplacement des images
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
@ -982,22 +982,22 @@ class CMailFile
|
||||
if (preg_match('/file=([A-Za-z0-9_\-\/]+[\.]?[A-Za-z0-9]+)?$/i',$full,$regs))
|
||||
{
|
||||
$img = $regs[1];
|
||||
|
||||
|
||||
if (file_exists($images_dir.'/'.$img))
|
||||
{
|
||||
// Image path in src
|
||||
$src = preg_quote($full,'/');
|
||||
|
||||
|
||||
// Image full path
|
||||
$this->html_images[$i]["fullpath"] = $images_dir.'/'.$img;
|
||||
|
||||
|
||||
// Image name
|
||||
$this->html_images[$i]["name"] = $img;
|
||||
|
||||
|
||||
// Content type
|
||||
$ext = preg_replace('/^.*\.(\w{3,4})$/e', 'strtolower("$1")', $img);
|
||||
$this->html_images[$i]["content_type"] = $this->image_types[$ext];
|
||||
|
||||
|
||||
// cid
|
||||
$this->html_images[$i]["cid"] = md5(uniqid(time()));
|
||||
$this->html = preg_replace("/src=\"$src\"|src='$src'/i", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html);
|
||||
@ -1052,7 +1052,7 @@ class CMailFile
|
||||
|
||||
/**
|
||||
* Return an address for SMTP protocol
|
||||
*
|
||||
*
|
||||
* @param adresses Example: 'John Doe <john@doe.com>' or 'john@doe.com'
|
||||
* @param format 0=Auto, 1=emails with <>, 2=emails without <>
|
||||
* @param encode 1=Encode name to RFC2822
|
||||
|
||||
@ -181,7 +181,7 @@ function dol_string_nospecial($str,$newstr='_')
|
||||
function dol_escape_js($stringtoescape)
|
||||
{
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return strtr($stringtoescape, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
|
||||
return strtr($stringtoescape, array("'"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user