dolibarr 20.0.0
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 ()
 
 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 27 of file blockedlog.class.php.

Constructor & Destructor Documentation

◆ __construct()

BlockedLog::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 132 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$ignoresystemIgnore system events for the test
Returns
bool

Definition at line 1208 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 1033 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$returnarray1=Return array of details, 2=Return array of details including keyforsignature, 0=Boolean
Returns
boolean|array True if OK, False if KO

Definition at line 995 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 Return integer <0 if KO, >0 if OK

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

References jsonOrUnserialize().

Referenced by fetch().

◆ dolEncodeBlockedData()

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

Encode data.

Parameters
string$dataData to serialize
int$mode0=serialize, 1=json_encode
Returns
string Value serialized, an object (stdClass)

Definition at line 813 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 >0 if OK, <0 if KO, 0 if not found

Definition at line 749 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$limitmax 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 1100 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 229 of file blockedlog.class.php.

References $object.

◆ getPreviousHash()

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

Get previous signature/hash in chain.

Parameters
int$withlock1=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 1051 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 1182 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 350 of file blockedlog.class.php.

◆ loadTrackedEvents()

BlockedLog::loadTrackedEvents ( )

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

Returns
int Always 1

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

References getDolGlobalString().

◆ setCertified()

BlockedLog::setCertified ( )

Set block certified by authority.

Returns
boolean

Definition at line 851 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
string$amountsamounts
?User$fuserUser object (forced)
Returns
int >0 if OK, <0 if KO

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

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


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