diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index fa5c92c8130..5dbdb79438c 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -162,27 +162,8 @@ if ($propalid > 0) if ($mesg) { print "$mesg
"; } // Affiche formulaire upload - if ($conf->global->MAIN_UPLOAD_DOC) - { - print_titre($langs->trans("AttachANewFile")); - - print '
'; - - print ''; - print '"; - print "
'; - - print ''; - print ''; - print '   '; - print ''; - - print "
"; - - print '
'; - print '
'; - } - + $html=new Form($db); + $html->form_attach_new_file('document.php?propalid='.$propal->id); // Affiche liste des documents existant print_titre($langs->trans("AttachedFiles")); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 713ad9e527e..02e3fe68c90 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -167,28 +167,9 @@ if ($facid > 0) if ($mesg) { print $mesg."
"; } // Affiche formulaire upload - if ($conf->global->MAIN_UPLOAD_DOC) - { - print_titre($langs->trans("AttachANewFile")); - - print '
'; - - print ''; - print '"; - print "
'; - - print ''; - print ''; - print '   '; - print ''; - - print "
"; - - print '
'; - print '
'; - } - - + $html=new Form($db); + $html->form_attach_new_file('document.php?facid='.$facture->id); + // Affiche liste des documents existant print_titre($langs->trans("AttachedFiles")); diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 4e13175254d..24c93f626e8 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -40,7 +40,6 @@ class Conf /** \public */ var $db; // Objet des caractéristiques de connexions // base db->host, db->name, db->user, db->pass, db->type - var $maxfilesize = 2000000; // Taille max des fichiers uploadés var $externalrss; var $commande; @@ -134,8 +133,7 @@ class Conf * Autorisation globale d'uploader (necessaire pour desactiver dans la demo) * conf->upload peut etre écrasée dans main.inc.php (selon user) */ - if ($this->global->MAIN_UPLOAD_DOC) $this->upload = 1; - else $this->upload = 0; + $this->upload = $this->global->MAIN_UPLOAD_DOC; /* * Definition des parametres d'activation de module et dependants des modules diff --git a/htdocs/docsoc.php b/htdocs/docsoc.php index d590865be1e..a3d043a3200 100644 --- a/htdocs/docsoc.php +++ b/htdocs/docsoc.php @@ -69,7 +69,7 @@ $upload_dir = $conf->societe->dir_output . "/" . $socid ; // Envoie fichier -if ( $_POST["sendit"] && $conf->upload) +if ( $_POST["sendit"] && $conf->upload != 0) { if (! is_dir($upload_dir)) create_exdir($upload_dir); @@ -166,26 +166,9 @@ if ($socid > 0) if ($mesg) { print "$mesg
"; } - // Affiche formulaire upload - if ($conf->global->MAIN_UPLOAD_DOC) - { - print_titre($langs->trans("AttachANewFile")); - echo '
'; - - print ''; - print '"; - print "
'; - - print ''; - print ''; - print '   '; - print ''; - - print "
"; - - print '
'; - print '
'; - } + // Affiche formulaire upload + $html=new Form($db); + $html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),1); // Affiche liste des documents existant print_titre($langs->trans("AttachedFiles")); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index bf36c2f51ca..f4f32dd65b7 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -162,21 +162,8 @@ if ($facid > 0) if ($mesg) { print $mesg.'
'; } // Affiche formulaire upload - if ($conf->global->MAIN_UPLOAD_DOC) - { - print_titre($langs->trans('AttachANewFile')); - print '
'; - print ''; - print ''; - print '
'; - print ''; - print ''; - print '   '; - print ''; - print '
'; - print '
'; - print '
'; - } + $html=new Form($db); + $html->form_attach_new_file('document.php?facid='.$facture->id); // Affiche liste des documents existant print_titre($langs->trans('AttachedFiles')); diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 0efd87a8c16..065054fa16f 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1742,6 +1742,56 @@ class Form } + /** + * \brief Affiche formulaire ajout fichier + * \param url Url + * \param titre Titre zone + * \param addcancel 1=Ajoute un bouton 'Annuler' + * \return int <0 si ko, >0 si ok + */ + function form_attach_new_file($url,$titre='',$addcancel=0) + { + global $conf,$langs; + + if ($conf->upload != 0) + { + print "\n\n\n"; + + if (! $titre) $titre=$langs->trans("AttachANewFile"); + print_titre($titre); + + print '
'; + + print ''; + print '"; + print "
'; + + if ($conf->upload > 0) + { + print ''; + } + print ''; + print '   '; + print ''; + + if ($addcancel) + { + print '   '; + print ''; + } + + print ' ('.$langs->trans("MaxSize").': '.$conf->upload.' '.$langs->trans("Kb").')'; + print "
"; + + print '
'; + print '
'; + + print "\n\n\n"; + } + + return 1; + } + /** * \brief Affiche formulaire de selection de la remise fixe * \param page Page diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 91243f29cb2..2c3bc920db1 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -157,7 +157,6 @@ ChangeContactInProcess=Change status to 'Contact in process' ChangeContactDone=Change status to 'Contact done' ProspectsByStatus=Prospects by status BillingContact=Billing contact -TotalSizeOfAttachedFiles=Total size of attached files NbOfAttachedFiles=Number of attached files AttachANewFile=Attach a new file FileWasRemoved=Files was removed diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 2b77a892574..7b917d482fa 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Validate intervention Notify_NOTIFY_VAL_FAC=Validate bill NbOfAttachedFiles=Number of attached files/documents TotalSizeOfAttachedFiles=Total size of attached files/documents +MaxSize=Maximum size AttachANewFile=Attach a new file/document LinkedObject=Linked object NbOfActiveNotifications=Number of notifications diff --git a/htdocs/langs/fr_BE/companies.lang b/htdocs/langs/fr_BE/companies.lang index 622489c24ce..d2a48b2514e 100644 --- a/htdocs/langs/fr_BE/companies.lang +++ b/htdocs/langs/fr_BE/companies.lang @@ -157,7 +157,6 @@ ChangeContactInProcess=Changer le statut ChangeContactDone=Changer le statut à 'Contact effectué' ProspectsByStatus=Prospects par statut BillingContact=Contact de facturation -TotalSizeOfAttachedFiles=Taille totale des fichiers attachés NbOfAttachedFiles=Nombre de fichiers attachés AttachANewFile=Attacher un nouveau fichier FileWasRemoved=Fichiers supprimés diff --git a/htdocs/langs/fr_BE/other.lang b/htdocs/langs/fr_BE/other.lang index 0d8095a38b1..1dc4baabdb8 100644 --- a/htdocs/langs/fr_BE/other.lang +++ b/htdocs/langs/fr_BE/other.lang @@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Valider intervention Notify_NOTIFY_VAL_FAC=Valider facture NbOfAttachedFiles=Nombre de fichiers/documents attachés TotalSizeOfAttachedFiles=Taille totale des fichiers/documents attachés +MaxSize=Taille maximum AttachANewFile=Attacher un nouveau fichier/document LinkedObject=Objets liés NbOfActiveNotifications=Nombre d'alertes diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 9df9a0dba52..888c45dc5a6 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -157,7 +157,6 @@ ChangeContactInProcess=Changer l' ChangeContactDone=Changer l'état à 'Contact réalisé' ProspectsByStatus=Prospects par état BillingContact=Contact facturation -TotalSizeOfAttachedFiles=Taille totale des fichiers joints NbOfAttachedFiles=Nombre de fichiers joints AttachANewFile=Joindre un nouveau fichier FileWasRemoved=Le fichier a été supprimé diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 7c02100cf98..aeb913142fe 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention Notify_NOTIFY_VAL_FAC=Validation facture NbOfAttachedFiles=Nombre de fichiers/documents liés TotalSizeOfAttachedFiles=Taille total des fichiers/documents liés +MaxSize=Taille maximum AttachANewFile=Ajouter un nouveau fichier/document LinkedObject=Objet lié NbOfActiveNotifications=Nombre de notifications diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 37e4b0e9059..6ebb785a740 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -165,28 +165,11 @@ if ($product->id) print ''; - // Affiche forumlaire upload - if ($conf->upload && $user->rights->produit->creer) - { - print_titre($langs->trans('AttachANewFile')); + // Affiche formulaire upload + $html=new Form($db); + $html->form_attach_new_file('document.php?id='.$product->id); - print '
'; - - print ''; - print '"; - print "
'; - - print ''; - print ''; - print '   '; - print ''; - - print "
"; - - print '
'; - print '
'; - } - + $errorlevel=error_reporting(); error_reporting(0); $handle=opendir($upload_dir); diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 978cc3d6285..07c438570a2 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -53,7 +53,7 @@ $types[1] = $langs->trans("Service"); * Actions */ -if ($_POST["sendit"] && $conf->global->MAIN_UPLOAD_DOC) +if ($_POST["sendit"] && $conf->upload != 0) { if ($_GET["id"]) { @@ -64,7 +64,7 @@ if ($_POST["sendit"] && $conf->global->MAIN_UPLOAD_DOC) // var_dump($_FILES); - $product->add_photo($conf->produit->dir_output, $_FILES['photofile']); + $product->add_photo($conf->produit->dir_output, $_FILES['userfile']); } } @@ -153,23 +153,9 @@ if ($_GET["id"] || $_GET["ref"]) */ if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer) { - print_titre($langs->trans("AddPhoto")); - - print '
'; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print '
'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')
'; - print '   '; - - print '
'; - - print '
'; + // Affiche formulaire upload + $html=new Form($db); + $html->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1); } // Affiche photos diff --git a/htdocs/telephonie/ligne/commande/retour/index.php b/htdocs/telephonie/ligne/commande/retour/index.php index 0e6a7ae67cd..1d03777ce86 100644 --- a/htdocs/telephonie/ligne/commande/retour/index.php +++ b/htdocs/telephonie/ligne/commande/retour/index.php @@ -34,7 +34,7 @@ if (! is_dir($upload_dir)) } } -if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1) +if ( $_POST["sendit"] && $conf->upload != 0) { if (is_dir($upload_dir)) { diff --git a/pgsql/data/data.sql b/pgsql/data/data.sql index 17f031bab80..ff6ef8e7443 100644 --- a/pgsql/data/data.sql +++ b/pgsql/data/data.sql @@ -48,7 +48,7 @@ insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,' -- insert into llx_const (name, value, type, note, visible) values ('MAIN_MONNAIE','euros','chaine','Monnaie',0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_UPLOAD_DOC','1','chaine','Autorise l\'upload de document',1); +insert into llx_const (name, value, type, note, visible) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_NOT_INSTALLED','1','chaine','Test d\'installation',1); insert into llx_const (name, value, type, note, visible) values ('MAIN_TITLE','Dolibarr','chaine','Titre des pages',0);