From 95b3913910670ca42be28e7200ae8f7305e2a0df Mon Sep 17 00:00:00 2001 From: hector Date: Fri, 28 Oct 2022 13:52:22 +0200 Subject: [PATCH] Add hooks --- htdocs/comm/action/card.php | 9 +++++++++ htdocs/comm/action/document.php | 12 ++++++++++++ htdocs/comm/action/info.php | 12 ++++++++++++ htdocs/resource/element_resource.php | 12 ++++++++++++ 4 files changed, 45 insertions(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 3aa6a16d3ef..271b6eb463c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2148,6 +2148,15 @@ if ($id > 0) { $linkback .= ''.$langs->trans("ViewPerUser").''; $linkback .= ''; + // Add more views from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); + if (empty($reshook)) { + $linkback .= $hookmanager->resPrint; + } elseif ($reshook > 1) { + $linkback = $hookmanager->resPrint; + } + //$linkback.=$out; $morehtmlref = '
'; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index b02b2850346..82cc7584c07 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -63,6 +63,9 @@ if ($id > 0) { $object->fetch_thirdparty(); } +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('actioncard', 'globalcard')); + // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -155,6 +158,15 @@ if ($object->id > 0) { $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); $out .= ''.$langs->trans("ViewDay").''; + // Add more views from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); + if (empty($reshook)) { + $out .= $hookmanager->resPrint; + } elseif ($reshook > 1) { + $out = $hookmanager->resPrint; + } + $linkback .= $out; $morehtmlref = '
    '; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 749ca6a0c62..d4588223b26 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -39,6 +39,9 @@ $langs->load("commercial"); $id = GETPOST('id', 'int'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('actioncard', 'globalcard')); + // Security check if ($user->socid > 0) { $action = ''; @@ -83,6 +86,15 @@ $out .= ''.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); $out .= ''.$langs->trans("ViewDay").''; +// Add more views from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); +if (empty($reshook)) { + $out .= $hookmanager->resPrint; +} elseif ($reshook > 1) { + $out = $hookmanager->resPrint; +} + $linkback .= $out; $morehtmlref = '
    '; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index c063e049f44..eedfcc06245 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -324,6 +324,9 @@ if (!$ret) { if (($element_id || $element_ref) && $element == 'action') { require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('actioncard', 'globalcard')); + $act = fetchObjectByElement($element_id, $element, $element_ref); if (is_object($act)) { $head = actions_prepare_head($act); @@ -344,6 +347,15 @@ if (!$ret) { $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); $out .= ''.$langs->trans("ViewDay").''; + // Add more views from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); + if (empty($reshook)) { + $out .= $hookmanager->resPrint; + } elseif ($reshook > 1) { + $out = $hookmanager->resPrint; + } + $linkback .= $out; $morehtmlref = '
    ';