From 21d30c1b3e04fc82e905ebe147cec651deb06148 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 25 May 2012 20:49:45 +0200 Subject: [PATCH] Fix: jquery fileupload broken feature --- htdocs/adherents/document.php | 2 +- htdocs/comm/propal/document.php | 2 +- htdocs/commande/document.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/contrat/document.php | 2 +- htdocs/core/ajax/fileupload.php | 20 ++++++++++++-------- htdocs/core/class/html.formfile.class.php | 3 ++- htdocs/fichinter/document.php | 2 +- htdocs/fourn/commande/document.php | 2 +- htdocs/fourn/facture/document.php | 2 +- htdocs/product/document.php | 2 +- htdocs/projet/document.php | 2 +- htdocs/projet/tasks/document.php | 4 ++-- 13 files changed, 26 insertions(+), 21 deletions(-) diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 5552cc84bd4a7..e500c5e8804a2 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -209,7 +209,7 @@ // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/adherents/document.php?id='.$member->id,'',0,0,$user->rights->adherent->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/adherents/document.php?id='.$member->id,'',0,0,$user->rights->adherent->creer,50,$object); // List of document diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 45c4732f836ec..cbc075247e181 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -187,7 +187,7 @@ // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); // List of document diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index fabaa069a9ba0..58cbe37ede036 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -172,7 +172,7 @@ // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$object->id,'',0,0,$user->rights->commande->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$object->id,'',0,0,$user->rights->commande->creer,50,$object); // List of document diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index d76b6fc4b2dd4..a3f2e8564afbf 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -191,7 +191,7 @@ // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id,'',0,0,$user->rights->facture->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id,'',0,0,$user->rights->facture->creer,50,$object); // List of document diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 2aab133d065e0..cb270c042d8bf 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -156,7 +156,7 @@ // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id,'',0,0,$user->rights->contrat->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id,'',0,0,$user->rights->contrat->creer,50,$object); // List of document diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 76ac6499cfa39..ca06febbf136a 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -43,8 +43,9 @@ //print_r($_GET); //print 'upload_dir='.GETPOST('upload_dir'); -$fk_element = GETPOST('fk_element'); -$element = GETPOST('element'); +$fk_element = GETPOST('fk_element','int'); +$element = GETPOST('element','alpha'); +$element_ref=GETPOST('element_ref','alpha'); /** @@ -56,6 +57,7 @@ class UploadHandler private $_options; private $_fk_element; private $_element; + private $_element_ref; /** @@ -64,19 +66,21 @@ class UploadHandler * @param array $options Options array * @param int $fk_element fk_element * @param string $element element + * @param string $element_ref element ref */ - function __construct($options=null,$fk_element=null,$element=null) + function __construct($options=null,$fk_element=null,$element=null,$element_ref=null) { global $conf; $this->_fk_element=$fk_element; $this->_element=$element; + $this->_element_ref=$element_ref; $this->_options = array( 'script_url' => $_SERVER['PHP_SELF'], - 'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/', - 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/', + 'upload_dir' => $conf->$element->dir_output . '/' . $element_ref . '/', + 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$element_ref.'/', 'param_name' => 'files', // The php.ini settings upload_max_filesize and post_max_size // take precedence over the following max_file_size setting: @@ -96,8 +100,8 @@ function __construct($options=null,$fk_element=null,$element=null) ), */ 'thumbs' => array( - 'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/thumbs/', - 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/thumbs/' + 'upload_dir' => $conf->$element->dir_output . '/' . $element_ref . '/thumbs/', + 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$element_ref.'/thumbs/' ) ) ); @@ -380,7 +384,7 @@ public function delete() * View */ -$upload_handler = new UploadHandler(null,$fk_element,$element); +$upload_handler = new UploadHandler(null,$fk_element,$element,$element_ref); header('Pragma: no-cache'); header('Cache-Control: private, no-cache'); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 34ecea9488bb1..4bb658654b576 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -839,7 +839,7 @@ private function _formAjaxFileUpload($object) // Load existing files: // TODO do not delete if (1 == 2) { - $.getJSON($("#fileupload form").prop("action"), { fk_element: "'.$object->id.'", element: "'.$object->element.'"}, function (files) { + $.getJSON($("#fileupload form").prop("action"), { fk_element: "'.$object->id.'", element: "'.$object->element.'", element_ref: "'.$object->ref.'"}, function (files) { var fu = $("#fileupload").data("fileupload"); fu._adjustMaxNumberOfFiles(-files.length); fu._renderDownload(files) @@ -867,6 +867,7 @@ private function _formAjaxFileUpload($object) print '
'; print ''; print ''; + print ''; print '
'; print ''; print '