dolibarr 21.0.0-alpha
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 log 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='')
 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.
 

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 152 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 1240 of file blockedlog.class.php.

References dol_print_error(), and dol_syslog().

◆ 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 id without comprimising checksums

Returns
string Key for signature

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

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 1027 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 900 of file blockedlog.class.php.

References 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 865 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 845 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 781 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 = '' )

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$search_codesearch code
Returns
BlockedLog[]|int<-2,-1> Array of object log or <0 if error

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

References natural_search().

◆ getObjectLink()

BlockedLog::getObjectLink ( )

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

Returns
string URL string of source object

Definition at line 249 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 1083 of file blockedlog.class.php.

References 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 1214 of file blockedlog.class.php.

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

Referenced by getPreviousHash().

◆ getUser()

BlockedLog::getUser ( )

Try to retrieve user author.

Returns
string

Definition at line 371 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 163 of file blockedlog.class.php.

References getDolGlobalString().

◆ setCertified()

BlockedLog::setCertified ( )

Set block certified by authority.

Returns
boolean

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

◆ setObjectData()

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

Populate properties of log from object data.

Parameters
CommonObject$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 402 of file blockedlog.class.php.

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


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