From d99156c52f89c7013f07a38671c9eb86033c79c6 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/core/class/html.formmail.class.php | 28 +++++++++++++++-------- htdocs/lib/files.lib.php | 5 ++-- 3 files changed, 28 insertions(+), 17 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/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.= ''; $out.= ''.$langs->trans("MailFile").''; $out.= ''; - //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.= "\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/lib/files.lib.php b/htdocs/lib/files.lib.php index 3dbbef2c6b2..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.68 2011/07/11 06:23:22 hregis Exp $ + * \version $Id: files.lib.php,v 1.67 2011/07/10 20:03:41 eldy Exp $ */ /** @@ -561,8 +561,9 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); - if (! $notrigger && is_object($object)) + if (! $notrigger) { + if (! is_object($object)) $object=(object) 'dummy'; $object->src_file=$dest_file; // Appel des triggers