From 3a5a74478f7f359bac4934f2804ae08437bd3a75 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 18:05:07 +0100 Subject: [PATCH 01/10] Add auther notif --- htdocs/core/class/notify.class.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 853de6d0a41..7e011482f43 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,7 +69,9 @@ class Notify 'ORDER_CREATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', + 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', + 'PROPAL_SENTBYMAIL', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -80,7 +82,8 @@ class Notify 'EXPENSE_REPORT_APPROVE', 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', - 'ACTION_CREATE' + 'ACTION_CREATE', + 'FUNDING_SENTBYMAIL', ); /** @@ -577,6 +580,13 @@ class Notify $labeltouse = $conf->global->ACTION_CREATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextActionAdded", $link); break; + default: + $object_type = $object->element; + $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type); + $template = $notifcode.'_TEMPLATE'; + $labeltouse = $conf->global->$template; + $mesg = $outputlangs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref.' '.$dir_output; + break; } include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -812,9 +822,14 @@ class Notify $object_type = 'action'; $mesg = $langs->transnoentitiesnoconv("EMailTextActionAdded", $link); break; + default: + $object_type = $object->element; + $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type); + $mesg = $langs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref; + break; } $ref = dol_sanitizeFileName($newref); - $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; + $pdf_path = $dir_output."/".$ref.".pdf"; if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; From 032b8692b1b7425a7ee82bc834f3b32683a6d0a1 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:42:17 +0100 Subject: [PATCH 02/10] Add hook --- ...ce_50_modNotification_Notification.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index fe89a05ab20..3c52f89cd41 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -90,9 +90,26 @@ class InterfaceNotification extends DolibarrTriggers public function getListOfManagedEvents() { global $conf; + global $hookmanager; + + + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('notification')); + + $parameters = array('arrayofnotifsupported'=>$arrayofnotifsupported); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters); + if (empty($reshook)) { + if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { + $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); + } + } $ret = array(); + $sql = "SELECT rowid, code, label, description, elementtype"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; $sql .= $this->db->order("rang, elementtype, code"); From e1e573c532d9e00bf86c1b0c1be0f401f57f69fd Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:55:40 +0100 Subject: [PATCH 03/10] Add Hook --- htdocs/core/class/notify.class.php | 21 ++++++++++++------- ..._50_modNotification_Notification.class.php | 3 +-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 7e011482f43..df5f19a64bf 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -71,7 +71,6 @@ class Notify 'PROPAL_VALIDATE', 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', - 'PROPAL_SENTBYMAIL', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -83,7 +82,6 @@ class Notify 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', 'ACTION_CREATE', - 'FUNDING_SENTBYMAIL', ); /** @@ -358,17 +356,26 @@ class Notify global $dolibarr_main_url_root; global $action; - if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { - return 0; - } - - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('notification')); + + $reshook = $hookmanager->executeHooks('notifsupported'); + if (empty($reshook)) { + if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { + Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray['arrayofnotifsupported']); + } + } + + if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { + return 0; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id); $langs->load("other"); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 3c52f89cd41..2013933e54b 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -99,8 +99,7 @@ class InterfaceNotification extends DolibarrTriggers } $hookmanager->initHooks(array('notification')); - $parameters = array('arrayofnotifsupported'=>$arrayofnotifsupported); - $reshook = $hookmanager->executeHooks('notifsupported', $parameters); + $reshook = $hookmanager->executeHooks('notifsupported'); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); From 1a5beb0664ec00a373695c01bfe0ff2fe7b8c2fc Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:55:55 +0100 Subject: [PATCH 04/10] Fix style --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index df5f19a64bf..1078c02e362 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -375,7 +375,7 @@ class Notify } include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - + dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id); $langs->load("other"); From f2377627ec01cb8cecd5595a17db9c0684e65e33 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 11 Mar 2022 10:50:11 +0100 Subject: [PATCH 05/10] Add template custom module --- htdocs/admin/notification.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index db79a1503c9..f6d71fe6817 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -267,6 +267,7 @@ $constantes = array(); foreach ($listofnotifiedevents as $notifiedevent) { $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); + $model = $notifiedevent['elementtype'].'_send'; if ($notifiedevent['elementtype'] == 'order_supplier') { $elementLabel = $langs->trans('SupplierOrder'); From 80a2499844965950a154c3ff9397d9a7a9c931f3 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 11 Mar 2022 11:25:49 +0100 Subject: [PATCH 06/10] Clean --- htdocs/core/class/notify.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 1078c02e362..0b92cc47a70 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,7 +69,6 @@ class Notify 'ORDER_CREATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', - 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', From 899598bbb348d7afe551b18339c255f95cc8ccf1 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Sat, 12 Mar 2022 16:50:48 +0100 Subject: [PATCH 07/10] Cop --- htdocs/admin/notification.php | 3 ++- htdocs/core/class/notify.class.php | 1 + .../interface_50_modNotification_Notification.class.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index f6d71fe6817..ac32d01522d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -1,9 +1,10 @@ * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2022 Anthony Berton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 0b92cc47a70..8e72d8e4773 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2018 Philippe Grand * Copyright (C) 2021 Thibault FOUCART + * Copyright (C) 2022 Anthony Berton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 2013933e54b..b32b63ba3d0 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2011 Regis Houssin * Copyright (C) 2013-2014 Marcos GarcĂ­a + * Copyright (C) 2022 Anthony Berton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 316380afd26f4eeca65f5affb3e066508a25b535 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Sat, 12 Mar 2022 23:41:16 +0100 Subject: [PATCH 08/10] 1 --- htdocs/core/class/notify.class.php | 4 ++-- .../interface_50_modNotification_Notification.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 8e72d8e4773..5bb448ad11d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -81,7 +81,7 @@ class Notify 'EXPENSE_REPORT_APPROVE', 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', - 'ACTION_CREATE', + 'ACTION_CREATE' ); /** @@ -363,7 +363,7 @@ class Notify $hookmanager->initHooks(array('notification')); - $reshook = $hookmanager->executeHooks('notifsupported'); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray['arrayofnotifsupported']); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index b32b63ba3d0..6e4f8cb1563 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -100,7 +100,7 @@ class InterfaceNotification extends DolibarrTriggers } $hookmanager->initHooks(array('notification')); - $reshook = $hookmanager->executeHooks('notifsupported'); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); From 958b6abdaafa0585ac6d8ef70559207b16cd5bb2 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 23 Mar 2022 17:31:54 +0100 Subject: [PATCH 09/10] pdf_path --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 5bb448ad11d..54b0fbb749c 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -836,7 +836,7 @@ class Notify break; } $ref = dol_sanitizeFileName($newref); - $pdf_path = $dir_output."/".$ref.".pdf"; + $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; From f7f318feb2386e16b0f17ddbf327d50edf59b61b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2022 12:38:34 +0200 Subject: [PATCH 10/10] Update notification.php --- htdocs/admin/notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index ac32d01522d..e8a6c3daa46 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -268,7 +268,7 @@ $constantes = array(); foreach ($listofnotifiedevents as $notifiedevent) { $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); - $model = $notifiedevent['elementtype'].'_send'; + $model = $notifiedevent['elementtype']; if ($notifiedevent['elementtype'] == 'order_supplier') { $elementLabel = $langs->trans('SupplierOrder');