From 3a3b04f31b6147dddff1460fa3ef3cf6b77bbc47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 May 2019 17:31:50 +0200 Subject: [PATCH] Fix showdocument for external modules --- htdocs/core/class/html.formfile.class.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index d161f32d92a..a8568ca104b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -290,7 +290,7 @@ class FormFile * Return a string to show the box with list of available documents for object. * This also set the property $this->numoffiles * - * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule_temp', ...) + * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:nameofsubmodule', 'mymodule_temp', ...) * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. * @param string $filedir Directory to scan * @param string $urlsource Url of origin page (for return) @@ -336,7 +336,7 @@ class FormFile } $printer=0; - if (in_array($modulepart, array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison'))) // The direct print feature is implemented only for such elements + if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'livraison', 'ticket'))) // The direct print feature is implemented only for such elements { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } @@ -643,19 +643,23 @@ class FormFile } else { + $submodulepart = $modulepart; + // For normalized standard modules $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php', 0); if (file_exists($file)) { $res=include_once $file; } - // For normalized external modules + // For normalized external modules. modulepart = 'nameofmodule' or 'nameofmodule:nameofsubmodule' else { - $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php', 0); + $tmp=explode(':', $modulepart); + if (! empty($tmp[2])) $submodulepart=$tmp[2]; + $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); $res=include_once $file; } - $class='ModelePDF'.ucfirst($modulepart); + $class='ModelePDF'.ucfirst($submodulepart); if (class_exists($class)) { $modellist=call_user_func($class.'::liste_modeles', $this->db); @@ -670,7 +674,6 @@ class FormFile // Set headershown to avoid to have table opened a second time later $headershown=1; - $buttonlabeltoshow=$buttonlabel; if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form'; // So we switch to form after a generation