diff --git a/htdocs/document.php b/htdocs/document.php index 79ed9024a50..c48a0363f78 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -243,6 +243,23 @@ if (!file_exists($fullpath_original_file_osencoded)) exit; } +// Hooks +if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); +} +$hookmanager->initHooks(array('document')); +$parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file, + 'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file, + 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); +$reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been +if ($reshook < 0) { + $errors = $hookmanager->error . (is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '') . join($separator, $hookmanager->errors) : ''); + dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : " . $errors); + print "ErrorDownloadDocumentHooks: " . $errors; + exit; +} + // Permissions are ok and file found, so we return it top_httphead($type); header('Content-Description: File Transfer');