NEW Show list of tracked events into the module config page.
This commit is contained in:
parent
9f2a42b67d
commit
d895e1be9f
@ -96,7 +96,7 @@ if (GETPOST('withtab','alpha'))
|
||||
}
|
||||
|
||||
|
||||
print $langs->trans("BlockedLogDesc")."<br>\n";
|
||||
print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
|
||||
|
||||
print '<br>';
|
||||
|
||||
@ -152,8 +152,23 @@ $seledted = empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) ? a
|
||||
print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="titlefield">';
|
||||
print $langs->trans("ListOfTrackedEvents").'</td><td>';
|
||||
$arrayoftrackedevents=$block_static->trackedevents;
|
||||
foreach($arrayoftrackedevents as $key => $val)
|
||||
{
|
||||
print $key.'-'.$val.'<br>';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
if (GETPOST('withtab','alpha'))
|
||||
|
||||
@ -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';
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user