From 2472dff67bd84284d36a121c4e5f832b19c51272 Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 28 Sep 2021 12:08:45 +0200 Subject: [PATCH 1/3] Fix FormFile::list_of_autoecmfiles object_instance classname after hook FormFile::list_of_autoecmfiles() can instantiate object with parameters resulting of hook `addSectionECMAuto` but for do this, it use `${$hookmanager->resArray['classname']}` which return a `null`. Instead we should do this `$hookmanager->resArray['classname']`. --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60054ecf5ad..71d8c02b5f2 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1672,7 +1672,7 @@ class FormFile dol_include_once($hookmanager->resArray['classpath']); if (array_key_exists('classname', $hookmanager->resArray) && !empty($hookmanager->resArray['classname'])) { if (class_exists($hookmanager->resArray['classname'])) { - $object_instance = new ${$hookmanager->resArray['classname']}($this->db); + $object_instance = new $hookmanager->resArray['classname']($this->db); } } } From fae0337b3e58cc160afdd2bc20343a6563af47c2 Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 28 Sep 2021 16:22:28 +0200 Subject: [PATCH 2/3] Fix show for external module in ecm index auto page This set the correct `modulepart` parameter for link generated to `document.php` of ecm auto index page if `src_object_type` for ecm document has a module suffix (`@modulename`). --- htdocs/core/class/html.formfile.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60054ecf5ad..55460c587d8 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1811,9 +1811,11 @@ class FormFile print ''; // File + // Check if document source has external module part, if it the case use it for module part on document.php + preg_match('/^[^@]*@([^@]*)$/', $modulepart.'@expertisemedical', $modulesuffix); print ''; //print "XX".$file['name']; //$file['name'] must be utf8 - print 'getDocumentsLink($modulepart, $modulesubdir, $filedir, '^'.preg_quote($file['name'],'/').'$'); - print $this->showPreview($file, $modulepart, $file['relativename']); + print $this->showPreview($file, (empty($modulesuffix) ? $modulepart : $modulesuffix[1]), $file['relativename']); print "\n"; From ae9643bbeff659ee7424cafba02eee6bfce616e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 13:38:38 +0200 Subject: [PATCH 3/3] Update html.formfile.class.php --- htdocs/core/class/html.formfile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 71d8c02b5f2..53c00327746 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1672,7 +1672,8 @@ class FormFile dol_include_once($hookmanager->resArray['classpath']); if (array_key_exists('classname', $hookmanager->resArray) && !empty($hookmanager->resArray['classname'])) { if (class_exists($hookmanager->resArray['classname'])) { - $object_instance = new $hookmanager->resArray['classname']($this->db); + $tmpclassname = $hookmanager->resArray['classname']; + $object_instance = new $tmpclassname($this->db); } } }