';
+print '';
+
print '';
if (GETPOST('withtab','alpha'))
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 5ca60997df9..becbe2bbe03 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -88,6 +88,12 @@ class BlockedLog
public $object_data = null;
+ /**
+ * Array of tracked event codes
+ * @var string[]
+ */
+ public $trackedevents = array();
+
/**
@@ -97,8 +103,49 @@ class BlockedLog
*/
public function __construct(DoliDB $db)
{
+ global $conf;
+
$this->db = $db;
+ $this->trackedevents = array();
+
+ if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='BillValidate';
+ if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='BillDelete';
+ if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='BillSentByEmail';
+ if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BillDownload';
+ if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BillPreview';
+
+ if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='BillPaymentCreate';
+ if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='BillPaymentDelete';
+
+ /* Supplier
+ if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='SupplierBillValidate';
+ if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='SupplierBillDelete';
+ if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='SupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
+ if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='SupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
+ if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='SupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
+
+ if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='SupplierBillPaymentCreate';
+ if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='supplierBillPaymentCreate';
+ */
+
+ if ($conf->don->enabled) $this->trackedevents['DON_CREATE']='DonationCreate';
+ if ($conf->don->enabled) $this->trackedevents['DON_MODIFY']='DonationModify';
+ if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='DonationDelete';
+
+ /*
+ if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='SalaryPaymentCreate';
+ if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='SalaryPaymentCreate';
+ if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='SalaryPaymentCreate';
+ */
+
+ if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION']='MemberSubscription';
+
+ /*
+ $trackedevents['PAYMENT_VARIOUS_CREATE']='VariousPaymentCreate';
+ $trackedevents['PAYMENT_VARIOUS_MODIFY']='VariousPaymentModify';
+ $trackedevents['PAYMENT_VARIOUS_DELETE']='VariousPaymentDelete';
+ */
}
/**
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
index d7e146938ac..64796c79654 100644
--- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -55,10 +55,19 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ $b=new BlockedLog($this->db);
+
+ // Tracked events
+ if (! in_array($action, array_keys($b->trackedevents)))
+ {
+ return 0;
+ }
+
// Event/record is qualified
$qualified = 0;
$amounts = 0;
if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL'
+ || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
|| (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
)
{
@@ -88,13 +97,14 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$amounts= (double) $object->amount;
}
+ // Another protection.
+ // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice
if (! $qualified)
{
return 0; // not implemented action log
}
- $b=new BlockedLog($this->db);
$result = $b->setObjectData($object, $action, $amounts); // Set field date_object, ref_object, fk_object, element, object_data
if ($result < 0)
{
diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang
index 19c919e1d0e..a047b9ff0f0 100644
--- a/htdocs/langs/en_US/blockedlog.lang
+++ b/htdocs/langs/en_US/blockedlog.lang
@@ -25,6 +25,7 @@ logBILL_DELETE=Customer bill deleted
logMODULE_RESET=Module BlockedLog was disabled
logMODULE_SET=Module BlockedLog was enabled
BlockedlogInfoDialog=Log Details
+ListOfTrackedEvents=List of tracked events
Fingerprint=Fingerprint
DownloadLogCSV=Download archive logs (CSV)
logDOC_PREVIEW=Preview of a validated document in order to print or download