NEW: Add new hook on document.php page

initHooks: document
method: downloadDocument
parameters: ecmfile, modulepart, original_file, entity, refname, fullpath_original_file, filename, fullpath_original_file_osencoded
This commit is contained in:
kamel 2020-11-03 15:12:56 +01:00
parent 351c8a5a2d
commit f7253ab032

View File

@ -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');