From bfeb3ca7fa69c4f4c33b8aa7a4d3693c34699562 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Jul 2011 20:03:38 +0000 Subject: [PATCH] Fix: file add and delte in email forms was broken with firefox 5 --- htdocs/admin/mails.php | 12 +++---- htdocs/comm/propal.php | 14 ++++---- htdocs/commande/fiche.php | 12 +++---- htdocs/compta/facture.php | 10 +++--- htdocs/core/class/html.formmail.class.php | 28 +++++++++++----- htdocs/expedition/fiche.php | 10 +++--- htdocs/fichinter/fiche.php | 41 ++++++++++++++++++++--- htdocs/fourn/commande/fiche.php | 10 +++--- htdocs/fourn/facture/fiche.php | 10 +++--- htdocs/langs/fr_FR/other.lang | 2 +- htdocs/lib/files.lib.php | 23 +++++++------ 11 files changed, 109 insertions(+), 63 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 05b12ff10b8..c9d5ac88812 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -20,7 +20,7 @@ /** * \file htdocs/admin/mails.php * \brief Page to setup emails sending - * \version $Id: mails.php,v 1.72 2011/07/09 06:10:06 hregis Exp $ + * \version $Id: mails.php,v 1.73 2011/07/10 20:03:39 eldy Exp $ */ require("../main.inc.php"); @@ -80,7 +80,7 @@ if ($_POST['addfile'] || $_POST['addfilehtml']) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir = $vardir.'/temp'; if (create_exdir($upload_dir) >= 0) { @@ -127,7 +127,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml'])) { // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir = $vardir.'/temp'; $keytodelete=isset($_POST['removedfile'])?$_POST['removedfile']:$_POST['removedfilehtml']; $keytodelete--; @@ -468,7 +468,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; print ''; - + // From $var=!$var; print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; @@ -574,7 +574,7 @@ else print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print ''; - + // Errors To $var=!$var; print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; @@ -737,5 +737,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/09 06:10:06 $ - $Revision: 1.72 $'); +llxFooter('$Date: 2011/07/10 20:03:39 $ - $Revision: 1.73 $'); ?> diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 35d69e13cda..dad5364d523 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -27,7 +27,7 @@ * \file htdocs/comm/propal.php * \ingroup propale * \brief Page of commercial proposals card and list - * \version $Id: propal.php,v 1.609 2011/07/07 21:32:22 eldy Exp $ + * \version $Id: propal.php,v 1.610 2011/07/10 20:03:41 eldy Exp $ */ require("../main.inc.php"); @@ -427,9 +427,9 @@ if ($_POST['addfile']) // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $action='presend'; $_POST["action"]='presend'; @@ -444,7 +444,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -1291,7 +1291,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // adresse de livraison + // Delivery address (deprecated) if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) { print ''; @@ -1335,7 +1335,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Origine de la demande + // Origin of demand print ''; print ''; $out.= ''; $out.= '\n"; } @@ -546,7 +556,7 @@ class FormMail if ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } if ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } if ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - + if ($conf->paypal->enabled && $conf->global->PAYPAL_ADD_PAYMENT_URL) { require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php"); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 4eda7ddacb4..c4e2f0c25ff 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/expedition/fiche.php * \ingroup expedition * \brief Fiche descriptive d'une expedition - * \version $Id: fiche.php,v 1.209 2011/07/07 21:32:19 eldy Exp $ + * \version $Id: fiche.php,v 1.210 2011/07/10 20:03:39 eldy Exp $ */ require("../main.inc.php"); @@ -291,9 +291,9 @@ if ($_POST['addfile']) // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $action ='presend'; } @@ -307,7 +307,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -1381,5 +1381,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/07 21:32:19 $ - $Revision: 1.209 $'); +llxFooter('$Date: 2011/07/10 20:03:39 $ - $Revision: 1.210 $'); ?> diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 0442cdb6125..26399ef51fe 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -23,7 +23,7 @@ * \file htdocs/fichinter/fiche.php * \brief Fichier fiche intervention * \ingroup ficheinter - * \version $Id: fiche.php,v 1.170 2011/07/07 22:02:48 eldy Exp $ + * \version $Id: fiche.php,v 1.171 2011/07/10 20:03:39 eldy Exp $ */ require("../main.inc.php"); @@ -444,6 +444,39 @@ if ($action == 'down' && $user->rights->ficheinter->creer) exit; } + +/* + * Add file in email form + */ +if ($_POST['addfile']) +{ + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + $mesg=dol_add_file_process($upload_dir_tmp,0,0); + + $action='presend'; +} + +/* + * Remove file in email form + */ +if (! empty($_POST['removedfile'])) +{ + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + $mesg=dol_remove_file_process($_POST['removedfile'],0); + + $action='presend'; +} + /* * Send mail */ @@ -1148,7 +1181,7 @@ elseif ($fichinterid) $formmail = new FormMail($db); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; - $formmail->fromname = $user->fullname; + $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; @@ -1158,7 +1191,7 @@ elseif ($fichinterid) $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendInterventionRef','__FICHINTERREF__'); - $formmail->withfile=1; + $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; @@ -1186,5 +1219,5 @@ elseif ($fichinterid) $db->close(); -llxFooter('$Date: 2011/07/07 22:02:48 $ - $Revision: 1.170 $'); +llxFooter('$Date: 2011/07/10 20:03:39 $ - $Revision: 1.171 $'); ?> diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index e634bbb50b1..b977bfe42a1 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/fourn/commande/fiche.php * \ingroup supplier, order * \brief Card supplier order - * \version $Id: fiche.php,v 1.231 2011/07/07 21:32:21 eldy Exp $ + * \version $Id: fiche.php,v 1.232 2011/07/10 20:03:40 eldy Exp $ */ require("../../main.inc.php"); @@ -578,9 +578,9 @@ if ($_POST['addfile']) // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $action='presend'; } @@ -594,7 +594,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -1545,5 +1545,5 @@ if ($id > 0 || ! empty($ref)) $db->close(); -llxFooter('$Date: 2011/07/07 21:32:21 $ - $Revision: 1.231 $'); +llxFooter('$Date: 2011/07/10 20:03:40 $ - $Revision: 1.232 $'); ?> diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 027f32a4c98..e2821a326ab 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/fourn/facture/fiche.php * \ingroup facture, fournisseur * \brief Page for supplier invoice card (view, edit, validate) - * \version $Id: fiche.php,v 1.260 2011/07/07 21:32:19 eldy Exp $ + * \version $Id: fiche.php,v 1.261 2011/07/10 20:03:39 eldy Exp $ */ require("../../main.inc.php"); @@ -629,9 +629,9 @@ if ($_POST['addfile']) // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $_GET["action"]='presend'; $_POST["action"]='presend'; @@ -646,7 +646,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -1916,5 +1916,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/07 21:32:19 $ - $Revision: 1.260 $'); +llxFooter('$Date: 2011/07/10 20:03:39 $ - $Revision: 1.261 $'); ?> diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 26a04f20d51..53195d78899 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -53,7 +53,7 @@ PredefinedMailContentSendOrder=Veuillez trouver ci-joint la commande __ORDERREF_ PredefinedMailContentSendSupplierOrder=Veuillez trouver ci-joint notre commande __ORDERREF__\n\nCordialement\n\n PredefinedMailContentSendSupplierInvoice=Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n PredefinedMailContentSendShipping=Veuillez trouver ci-joint le bon d'expédition __SHIPPINGREF__\n\nCordialement\n\n -PredefinedMailContentSendFichInter=Veuillez trouver ci-joint le intervention __FICHINTERREF__\n\nCordialement\n\n +PredefinedMailContentSendFichInter=Veuillez trouver ci-joint la fiche d'intervention __FICHINTERREF__\n\nCordialement\n\n DemoDesc=Dolibarr est un logiciel de gestion d'activité (professionnelle ou associative) composé de modules fonctionnels indépendants et optionnels. Une démonstration qui inclut tous ces modules n'a pas de sens car les modules ne sont jamais tous utilisés en même temps. Aussi, plusieurs profils type de démo sont disponibles. ChooseYourDemoProfil=Veuillez choisir le profil de démo qui correspond le mieux à votre activité... DemoFundation=Gestion des adhérents d'une association diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index d14de3b804d..8b6ea639ec8 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -20,7 +20,7 @@ /** * \file htdocs/lib/files.lib.php * \brief Library for file managing functions - * \version $Id: files.lib.php,v 1.66 2011/07/06 16:56:01 eldy Exp $ + * \version $Id: files.lib.php,v 1.67 2011/07/10 20:03:41 eldy Exp $ */ /** @@ -709,7 +709,7 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession= if (! empty($_FILES['addedfile']['tmp_name'])) { - if (create_exdir($upload_dir) >= 0) + if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],$allowoverwrite,0, $_FILES['addedfile']['error']); if (is_numeric($resupload) && $resupload > 0) @@ -755,10 +755,11 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession= * Remove an uploaded file (for example after submitting a new file a mail form). * All information used are in db, conf, langs, user and _FILES. * @param filenb File nb to delete - * @param donotupdatesession 1=Do no edit _SESSION variable + * @param donotupdatesession 1=Do not edit _SESSION variable + * @param donotdeletefile 1=Do not delete physically file * @return string Message with result of upload and store. */ -function dol_remove_file_process($filenb,$donotupdatesession=0) +function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0) { global $db,$user,$conf,$langs,$_FILES; @@ -778,14 +779,16 @@ function dol_remove_file_process($filenb,$donotupdatesession=0) { $pathtodelete=$listofpaths[$keytodelete]; $filetodelete=$listofnames[$keytodelete]; - $result = dol_delete_file($pathtodelete,1); + if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); + else $result=0; if ($result >= 0) { - $langs->load("other"); - - $mesg = '
'.$langs->trans("FileWasRemoved",$filetodelete).'
'; - //print_r($_FILES); - + if (empty($donotdeletefile)) + { + $langs->load("other"); + $mesg = '
'.$langs->trans("FileWasRemoved",$filetodelete).'
'; + //print_r($_FILES); + } if (empty($donotupdatesession)) { include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
'; print $langs->trans('Source'); @@ -1975,6 +1975,6 @@ else } $db->close(); -llxFooter('$Date: 2011/07/07 21:32:22 $ - $Revision: 1.609 $'); +llxFooter('$Date: 2011/07/10 20:03:41 $ - $Revision: 1.610 $'); ?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 35d5f47a393..c1aad5fefb6 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -26,7 +26,7 @@ * \file htdocs/commande/fiche.php * \ingroup commande * \brief Page to show customer order - * \version $Id: fiche.php,v 1.524 2011/07/07 21:32:21 eldy Exp $ + * \version $Id: fiche.php,v 1.525 2011/07/10 20:03:41 eldy Exp $ */ require("../main.inc.php"); @@ -931,7 +931,7 @@ if ($action == 'remove_file') { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); - $upload_dir = $conf->commande->dir_output . "/"; + $upload_dir = $conf->commande->dir_output; $file = $upload_dir . '/' . $_GET['file']; dol_delete_file($file); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; @@ -947,9 +947,9 @@ if ($_POST['addfile']) // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $action ='presend'; } @@ -963,7 +963,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -2134,5 +2134,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/07 21:32:21 $ - $Revision: 1.524 $'); +llxFooter('$Date: 2011/07/10 20:03:41 $ - $Revision: 1.525 $'); ?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e22afcef693..9e80ceb78c6 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -26,7 +26,7 @@ * \file htdocs/compta/facture.php * \ingroup facture * \brief Page to create/see an invoice - * \version $Id: facture.php,v 1.847 2011/07/08 10:22:14 hregis Exp $ + * \version $Id: facture.php,v 1.848 2011/07/10 20:03:40 eldy Exp $ */ require('../main.inc.php'); @@ -1191,9 +1191,9 @@ if ($_POST['addfile']) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); $action='presend'; } @@ -1207,7 +1207,7 @@ if (! empty($_POST['removedfile'])) // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; + $upload_dir_tmp = $vardir.'/temp'; $mesg=dol_remove_file_process($_POST['removedfile'],0); @@ -3241,5 +3241,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/08 10:22:14 $ - $Revision: 1.847 $'); +llxFooter('$Date: 2011/07/10 20:03:40 $ - $Revision: 1.848 $'); ?> diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0de9a763c66..3164f86d8e1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -22,7 +22,7 @@ * \file htdocs/core/class/html.formmail.class.php * \ingroup core * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire - * \version $Id: html.formmail.class.php,v 1.30 2011/07/09 10:26:19 hregis Exp $ + * \version $Id: html.formmail.class.php,v 1.31 2011/07/10 20:03:41 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"); @@ -124,9 +124,9 @@ class FormMail /** * Add a file into the list of attached files (stored in SECTION array) * - * @param $path - * @param $file - * @param $type + * @param string $path Full absolute path on filesystem of file, including file name + * @param string $file Only filename + * @param string $type Mime type */ function add_attached_files($path,$file,$type) { @@ -505,14 +505,26 @@ class FormMail $out.= '
'.$langs->trans("MailFile").''; - //print '
'; + // FIXME Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) { $out.= '
'; $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) $out.= ' '; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } $out.= '
'; } } @@ -522,11 +534,9 @@ class FormMail } if ($this->withfile == 2) // Can add other files { - //print '
'; $out.= ''; $out.= ' '; $out.= ''; - //print '
'; } $out.= "