dolibarr 22.0.5
BlockedLog Class Reference

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)
 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 authority.
 
 create ($user, $forcesignature='')
 Create blocked log in database.
 
 checkSignature ($previoushash='', $returnarray=0)
 Check if current signature still correct compared to the value in chain.
 
 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='')
 Return array of log objects (with criteria)
 
 getSignature ()
 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.
 

Private Member Functions

 buildKeyForSignature ()
 Return a string for signature.
 
 buildFirstPartOfKeyForSignature ()
 Return first part of string for signature.
 

Detailed Description

Class to manage Blocked Log.

Definition at line 28 of file blockedlog.class.php.

Constructor & Destructor Documentation

◆ __construct()

BlockedLog::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 157 of file blockedlog.class.php.

Member Function Documentation

◆ alreadyUsed()

BlockedLog::alreadyUsed ( $ignoresystem = 0)

Check if module was already used or not for at least one recording.

Parameters
int<0,1>$ignoresystem Ignore system events for the test
Returns
bool

Definition at line 1308 of file blockedlog.class.php.

References $conf, dol_print_error(), and dol_syslog().

◆ buildFirstPartOfKeyForSignature()

BlockedLog::buildFirstPartOfKeyForSignature ( )
private

Return first part of string for signature.

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

Returns
string First part of key for signature

Definition at line 1102 of file blockedlog.class.php.

Referenced by buildKeyForSignature(), and create().

◆ buildKeyForSignature()

BlockedLog::buildKeyForSignature ( )
private

Return a string for signature.

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

Returns
string Key for signature

Definition at line 1084 of file blockedlog.class.php.

References buildFirstPartOfKeyForSignature().

Referenced by checkSignature(), and create().

◆ checkSignature()

BlockedLog::checkSignature ( $previoushash = '',
$returnarray = 0 )

Check if current signature still correct compared to the value in chain.

Parameters
string$previoushashIf 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
Returns
boolean|array{checkresult:bool,calculatedsignature:string,previoushash:string,keyforsignature?:string} True if OK, False if KO

Definition at line 1045 of file blockedlog.class.php.

References buildKeyForSignature(), dol_hash(), and getPreviousHash().

◆ create()

BlockedLog::create ( $user,
$forcesignature = '' )

Create blocked log in database.

Parameters
User$userObject user that create
string$forcesignatureForce signature (for example '0000000000' when we disabled the module)
Returns
int<-3,-1>|int<1,1> Return integer <0 if KO, >0 if OK

Definition at line 916 of file blockedlog.class.php.

References $conf, buildFirstPartOfKeyForSignature(), buildKeyForSignature(), dol_hash(), dol_now(), dol_syslog(), dolEncodeBlockedData(), and getPreviousHash().

◆ dolDecodeBlockedData()

BlockedLog::dolDecodeBlockedData ( $data,
$mode = 0 )

Decode data.

Parameters
string$dataData to unserialize
int$mode0=unserialize, 1=json_decode
Returns
Object Value unserialized, an object (stdClass)

Definition at line 881 of file blockedlog.class.php.

References jsonOrUnserialize().

Referenced by fetch().

◆ dolEncodeBlockedData()

BlockedLog::dolEncodeBlockedData ( $data,
$mode = 0 )

Encode data.

Parameters
?stdClass$dataData to serialize
int<0,1>$mode 0=serialize, 1=json_encode
Returns
string Value serialized, an object (stdClass)

Definition at line 861 of file blockedlog.class.php.

Referenced by create().

◆ fetch()

BlockedLog::fetch ( $id)

Get object from database.

Parameters
int$idId of object to load
Returns
int<-1,1> >0 if OK, <0 if KO, 0 if not found

Definition at line 797 of file blockedlog.class.php.

References dolDecodeBlockedData().

◆ getLog()

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 = '' )

Return array of log objects (with criteria)

Parameters
string$elementElement to search
int$fk_objectId of object to search
int<0,max>$limit Max number of element, 0 for all
string$sortfieldSort field
string$sortorderSort order
int$search_fk_userId of user(s)
int$search_startStart time limit
int$search_endEnd time limit
string$search_refSearch ref
string$search_amountSearch amount
string | string[]$search_codeSearch code
string$search_signatureSearch signature
Returns
BlockedLog[]|int<-2,-1> Array of object log or <0 if error

Definition at line 1191 of file blockedlog.class.php.

References $conf, and natural_search().

◆ getObjectLink()

BlockedLog::getObjectLink ( )

Try to retrieve source object (it it still exists).

Returns
string URL string of source object

Definition at line 256 of file blockedlog.class.php.

References $object.

◆ getPreviousHash()

BlockedLog::getPreviousHash ( $withlock = 0,
$beforeid = 0 )

Get previous signature/hash in chain.

Parameters
int<0,1>$withlock 1=With a lock
int$beforeidID of a record
Returns
string Hash of previous record (if beforeid is defined) or hash of last record (if beforeid is 0)

Definition at line 1117 of file blockedlog.class.php.

References $conf, dol_print_error(), and getSignature().

Referenced by checkSignature(), and create().

◆ getSignature()

BlockedLog::getSignature ( )

Return the signature (hash) of the "genesis-block" (Block 0).

Returns
string Signature of genesis-block for current conf->entity

Definition at line 1282 of file blockedlog.class.php.

References $conf, dol_hash(), dolibarr_set_const(), getDolGlobalString(), and getRandomPassword().

Referenced by getPreviousHash().

◆ getUser()

BlockedLog::getUser ( )

Try to retrieve user author.

Returns
string

Definition at line 380 of file blockedlog.class.php.

◆ loadTrackedEvents()

BlockedLog::loadTrackedEvents ( )

Load list of tracked events into $this->trackedevents.

Returns
int<1,1> Always 1

Definition at line 168 of file blockedlog.class.php.

References getDolGlobalString(), and img_picto().

◆ setCertified()

BlockedLog::setCertified ( )

Set block certified by authority.

Returns
boolean

Definition at line 899 of file blockedlog.class.php.

◆ setObjectData()

BlockedLog::setObjectData ( & $object,
$action,
$amounts,
$fuser = null )

Populate properties of an unalterable log entry from object data.

Parameters
CommonObject | stdClass$objectobject to store
string$actionaction
float | int$amountsamounts
?User$fuserUser object (forced)
Returns
int<-1,-1>|int<1,1> >0 if OK, <0 if KO

Definition at line 411 of file blockedlog.class.php.

References $object, dol_getIdFromCode(), and dol_syslog().


The documentation for this class was generated from the following file: