Clean code

This commit is contained in:
Laurent Destailleur 2026-06-18 16:37:37 +02:00
parent 765c907d44
commit d0d3c2fa27
2 changed files with 20 additions and 5 deletions

View file

@ -419,8 +419,22 @@ print '<input type="text" class="maxwidth50" name="search_pos_source" value="'.d
print '</td>';
// Actions code
$actioncodetoshowincombo = array();
// Merge the action PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE into PAYMENT_CUSTOMER
foreach ($block_static->trackedevents as $key => $value) {
if ($key === 'PAYMENT_CUSTOMER_DELETE') {
$actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_CREATE']);
unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_DELETE']);
} else {
$actioncodetoshowincombo[$key] = $value;
}
}
$actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
print '<td class="liste_titre">';
print $form->multiselectarray('search_code', $block_static->trackedevents, $search_code, 0, 0, 'maxwidth200', 1);
print $form->multiselectarray('search_code', $actioncodetoshowincombo, $search_code, 0, 0, 'maxwidth200', 1);
print '</td>';
// Ref

View file

@ -1793,10 +1793,6 @@ class BlockedLog
if (!$errormsg && $obfuscationkey) {
$this->saveHMACSecretKey((string) $hmac_secret_key, 'dolobfuscationv1-'.$mysoc->idprof1, $obfuscationkey); // gitleaks:allow
}
/* We must not throw an error here, because the main goal of this function is to get the signature of the line and we got it.
else {
throw new Exception('Error: Failed to convert the old saving mode of HMAC key (crypted by $dolibarr_main_instance_unique_id) into the new saving (crypted by obfuscation key from ping.dolibarr.org). '.$errormsg);
}*/
} elseif (!preg_match('/^dolcrypt/', $hmac_encoded_secret_key)) { // For old versions, we must switch the data saving mode to use the new method.
$this->saveHMACSecretKey((string) $hmac_secret_key, 'dolcrypt'); // gitleaks:allow
}
@ -2226,6 +2222,11 @@ class BlockedLog
}
if (is_array($search_code)) {
if (!empty($search_code)) {
if (in_array('PAYMENT_CUSTOMER', $search_code)) { // If we ask codes PAYMENT_CUSTOMER, it means both PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE
$search_code[] = 'PAYMENT_CUSTOMER_CREATE';
$search_code[] = 'PAYMENT_CUSTOMER_DELETE';
}
$sql .= natural_search("action", implode(',', $search_code), 3);
}
} else {