Add a warning to avoid to forget to attach file

This commit is contained in:
Laurent Destailleur 2010-01-12 23:03:34 +00:00
parent 36bcf6c05e
commit 473345d839
5 changed files with 39 additions and 31 deletions

View File

@ -17,20 +17,20 @@
*/ */
/** /**
\file htdocs/html.formmail.class.php * \file htdocs/html.formmail.class.php
\brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
\version $Id$ * \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
/** \class FormMail /** \class FormMail
\brief Classe permettant la generation du formulaire html d'envoi de mail unitaire * \brief Classe permettant la generation du formulaire html d'envoi de mail unitaire
\remarks Utilisation: $formail = new FormMail($db) * \remarks Utilisation: $formail = new FormMail($db)
\remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs * \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs
\remarks $formmail->show_form() affiche le formulaire * \remarks $formmail->show_form() affiche le formulaire
*/ */
class FormMail class FormMail
{ {
var $db; var $db;
@ -65,9 +65,9 @@ class FormMail
/** /**
\brief Constructeur * \brief Constructeur
\param DB handler d'acces base de donnee * \param DB handler d'acces base de donnee
*/ */
function FormMail($DB) function FormMail($DB)
{ {
$this->db = $DB; $this->db = $DB;
@ -176,7 +176,7 @@ class FormMail
$form=new Form($DB); $form=new Form($DB);
print "\n<!-- Debut form mail -->\n"; 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'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
foreach ($this->param as $key=>$value) foreach ($this->param as $key=>$value)
{ {
@ -475,7 +475,13 @@ class FormMail
} }
print "<tr><td align=center colspan=2><center>"; 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) if ($this->withcancel)
{ {
print " &nbsp; &nbsp; "; print " &nbsp; &nbsp; ";

View File

@ -47,6 +47,7 @@ ErrorFailedToSaveFile=Error, failed to save file.
ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported. ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported.
ErrorImageFormatNotSupported=Your PHP does not support functions to convert images of this format. ErrorImageFormatNotSupported=Your PHP does not support functions to convert images of this format.
BackgroundColorByDefault=Default background color 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 NbOfEntries=Nb of entries
GoToWikiHelpPage=Read online help (need Internet access) GoToWikiHelpPage=Read online help (need Internet access)
GoToHelpPage=Read help GoToHelpPage=Read help

View File

@ -47,6 +47,7 @@ ErrorFailedToSaveFile=Erreur, l'enregistrement du fichier a échoué.
ErrorOnlyPngJpgSupported=Erreur, seuls les formats images .jpg et .png sont supportés. 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. ErrorImageFormatNotSupported=Votre PHP ne supporte pas les fonctions de conversion de ce format d'image.
BackgroundColorByDefault=Couleur de fond 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 NbOfEntries=Nb d'entrées
GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet) GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet)
GoToHelpPage=Consulter l'aide GoToHelpPage=Consulter l'aide

View File

@ -680,7 +680,7 @@ class CMailFile
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mime_boundary."\"".$this->eol; $out.= "Content-Type: multipart/mixed; boundary=\"".$this->mime_boundary."\"".$this->eol;
$out.= "Content-Transfer-Encoding: 8bit".$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); dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out);
return $out; return $out;
} }

View File

@ -181,7 +181,7 @@ function dol_string_nospecial($str,$newstr='_')
function dol_escape_js($stringtoescape) function dol_escape_js($stringtoescape)
{ {
// escape quotes and backslashes, newlines, etc. // escape quotes and backslashes, newlines, etc.
return strtr($stringtoescape, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); return strtr($stringtoescape, array("&#039;"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
} }