|
dolibarr 23.0.3
|
Class to manage Blocked Log. More...
Public Member Functions | |
| __construct (DoliDB $db) | |
| Constructor. | |
| loadTrackedEvents () | |
| Load list of tracked events into $this->trackedevents. | |
| getObjectLink () | |
| Try to retrieve source object (it it still exists). | |
| getUser () | |
| Try to retrieve user author. | |
| setObjectData (&$object, $action, $amounts, $fuser=null, $amounts_taxexcl=null) | |
| Populate properties of an unalterable log entry from object data. | |
| fetch ($id) | |
| Get object from database. | |
| dolEncodeBlockedData ($data, $mode=0) | |
| Encode data. | |
| dolDecodeBlockedData ($data, $mode=0) | |
| Decode data. | |
| setCertified () | |
| Set block certified by an external authority. | |
| create ($user, $forcesignature='') | |
| Create blocked log in database. | |
| checkSignature ($previoushash='', $returnarray=0) | |
| Check if calculated signature still correct compared to the value in the chain. | |
| buildKeyForSignature () | |
| Return the string for signature (clear data). | |
| getPreviousHash ($withlock=0, $beforeid=0) | |
| Get previous signature/hash in chain. | |
| getLog ($element, $fk_object, $limit=0, $sortfield='', $sortorder='', $search_fk_user=-1, $search_start=-1, $search_end=-1, $search_ref='', $search_amount='', $search_code='', $search_signature='', $search_module_source='') | |
| Return array of log objects (with criteria) | |
| getOrInitFirstSignature () | |
| Return the signature (hash) of the "genesis-block" (Block 0). | |
| alreadyUsed ($ignoresystem=0) | |
| Check if module was already used or not for at least one recording. | |
| canBeEnabled () | |
| Check if module can be enabled. | |
| canBeDisabled () | |
| Check if module can be disabled. | |
Private Member Functions | |
| buildFirstPartOfKeyForSignature () | |
| Return first part of string for signature (clear data) Note: rowid of line not included as it is not a business data and this allow to make backup of a year and restore it into another database with different ids without comprimising checksums. | |
| buildFinalSignatureHash ($clearstring) | |
| Return a hash that is the signature of a line (hash_hmac en SHA256 des données + clé secrète) | |
Class to manage Blocked Log.
Definition at line 28 of file blockedlog.class.php.
| BlockedLog::__construct | ( | DoliDB | $db | ) |
Constructor.
Definition at line 189 of file blockedlog.class.php.
| BlockedLog::alreadyUsed | ( | $ignoresystem = 0 | ) |
Check if module was already used or not for at least one recording.
| int<0,1> | $ignoresystem Ignore system events for the test |
Definition at line 1706 of file blockedlog.class.php.
References isBlockedLogUsed().
|
private |
Return a hash that is the signature of a line (hash_hmac en SHA256 des données + clé secrète)
| string | $clearstring | Data to sign |
Definition at line 1456 of file blockedlog.class.php.
References dol_hash(), dolDecrypt(), and getDolGlobalString().
Referenced by checkSignature(), and create().
|
private |
Return first part of string for signature (clear data) Note: rowid of line not included as it is not a business data and this allow to make backup of a year and restore it into another database with different ids without comprimising checksums.
Definition at line 1413 of file blockedlog.class.php.
Referenced by buildKeyForSignature(), and create().
| BlockedLog::buildKeyForSignature | ( | ) |
Return the string for signature (clear data).
Definition at line 1436 of file blockedlog.class.php.
References buildFirstPartOfKeyForSignature().
Referenced by checkSignature(), and create().
| BlockedLog::canBeDisabled | ( | ) |
Check if module can be disabled.
Definition at line 1737 of file blockedlog.class.php.
References $mysoc, and isALNEQualifiedVersion().
| BlockedLog::canBeEnabled | ( | ) |
Check if module can be enabled.
Definition at line 1718 of file blockedlog.class.php.
References isALNEQualifiedVersion().
| BlockedLog::checkSignature | ( | $previoushash = '', | |
| $returnarray = 0 ) |
Check if calculated signature still correct compared to the value in the chain.
| string | $previoushash | If previous signature hash is known, we can provide it to avoid to make a search of it in database. |
| int<0,2> | $returnarray 1=Return array of details, 2=Return array of details including keyforsignature, 0=Boolean |
Definition at line 1359 of file blockedlog.class.php.
References buildFinalSignatureHash(), buildKeyForSignature(), dol_syslog(), and getPreviousHash().
| BlockedLog::create | ( | $user, | |
| $forcesignature = '' ) |
Create blocked log in database.
| User | $user | Object user that create |
| string | $forcesignature | Force signature (for example '0000000000' when we disabled the module, to force a non valid record, for test purpose for example) |
Definition at line 1185 of file blockedlog.class.php.
References $mysoc, buildFinalSignatureHash(), buildFirstPartOfKeyForSignature(), buildKeyForSignature(), dol_now(), dol_syslog(), dolEncodeBlockedData(), getDolGlobalString(), getPreviousHash(), and isALNERunningVersion().
| BlockedLog::dolDecodeBlockedData | ( | $data, | |
| $mode = 0 ) |
Decode data.
| string | $data | Data to unserialize |
| int | $mode | 0=unserialize, 1=json_decode |
Definition at line 1150 of file blockedlog.class.php.
References jsonOrUnserialize().
Referenced by fetch().
| BlockedLog::dolEncodeBlockedData | ( | $data, | |
| $mode = 0 ) |
Encode data.
| ?stdClass | $data | Data to serialize |
| int<0,1> | $mode 0=serialize, 1=json_encode |
Definition at line 1130 of file blockedlog.class.php.
Referenced by create().
| BlockedLog::fetch | ( | $id | ) |
Get object from database.
| int | $id | Id of object to load |
Definition at line 1060 of file blockedlog.class.php.
References dolDecodeBlockedData().
| BlockedLog::getLog | ( | $element, | |
| $fk_object, | |||
| $limit = 0, | |||
| $sortfield = '', | |||
| $sortorder = '', | |||
| $search_fk_user = -1, | |||
| $search_start = -1, | |||
| $search_end = -1, | |||
| $search_ref = '', | |||
| $search_amount = '', | |||
| $search_code = '', | |||
| $search_signature = '', | |||
| $search_module_source = '' ) |
Return array of log objects (with criteria)
| string | $element | Element to search |
| string | int | $fk_object | Id of object to search. Can be a UFS search criteria. |
| int<0,max> | $limit Max number of element, 0 for all | |
| string | $sortfield | Sort field |
| string | $sortorder | Sort order |
| int | $search_fk_user | Id of user(s) |
| int | $search_start | Start time limit |
| int | $search_end | End time limit |
| string | $search_ref | Search ref |
| string | $search_amount | Search amount |
| string | string[] | $search_code | Search code |
| string | $search_signature | Search signature |
| string | $search_module_source | Search on module source |
Definition at line 1562 of file blockedlog.class.php.
References natural_search().
| BlockedLog::getObjectLink | ( | ) |
Try to retrieve source object (it it still exists).
Definition at line 332 of file blockedlog.class.php.
References $object.
| BlockedLog::getOrInitFirstSignature | ( | ) |
Return the signature (hash) of the "genesis-block" (Block 0).
Definition at line 1675 of file blockedlog.class.php.
References dolibarr_set_const(), and getDolGlobalString().
Referenced by getPreviousHash().
| BlockedLog::getPreviousHash | ( | $withlock = 0, | |
| $beforeid = 0 ) |
Get previous signature/hash in chain.
| int<0,1> | $withlock 1=With a lock | |
| int | $beforeid | ID of a record |
Definition at line 1486 of file blockedlog.class.php.
References dol_print_error(), and getOrInitFirstSignature().
Referenced by checkSignature(), and create().
| BlockedLog::getUser | ( | ) |
| BlockedLog::loadTrackedEvents | ( | ) |
Load list of tracked events into $this->trackedevents.
Definition at line 200 of file blockedlog.class.php.
References getDolGlobalString(), img_picto(), and isModEnabled().
| BlockedLog::setCertified | ( | ) |
Set block certified by an external authority.
Definition at line 1168 of file blockedlog.class.php.
| BlockedLog::setObjectData | ( | & | $object, |
| $action, | |||
| $amounts, | |||
| $fuser = null, | |||
| $amounts_taxexcl = null ) |
Populate properties of an unalterable log entry from object data.
This populates ->object_data but also other fields like ->action, ->module_source, ->amounts_taxexcl, ->amounts and ->linktoref and ->linktype It also populates some debug info like ->element and ->fk_object
| CommonObject | stdClass | $object | Object to store |
| string | $action | Action code ('BILL_VALIDATE', 'BILL_SENTBYMAIL', ...) |
| float | int | $amounts | amounts (incl tax) |
| ?User | $fuser | User object (forced) |
| float | int | null | $amounts_taxexcl | amounts (excl tax or null if not relevant) |
var CashControl $object
Definition at line 490 of file blockedlog.class.php.
References $mysoc, $object, dol_getIdFromCode(), dol_syslog(), dol_trunc(), dolGetFirstLineOfText(), Facture\TYPE_CREDIT_NOTE, and FactureFournisseur\TYPE_CREDIT_NOTE.