dolibarr 18.0.6
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 criterias)
 
 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 26 of file blockedlog.class.php.

Constructor & Destructor Documentation

◆ __construct()

BlockedLog::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 126 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 1195 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 wihtout comprimising checksums

Returns
string Key for signature

Definition at line 1020 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 982 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
int$forcesignatureForce signature (for example '0000000000' when we disabled the module)
Returns
int <0 if KO, >0 if OK

Definition at line 855 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
string$mode0=unserialize, 1=json_decode
Returns
object Value unserialized, an object (stdClass)

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

References jsonOrUnserialize().

Referenced by fetch().

◆ dolEncodeBlockedData()

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

Encode data.

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

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

References dolDecodeBlockedData(), and ref.

◆ 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 criterias)

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
array|int Array of object log or <0 if error

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

◆ 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 1038 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 1169 of file blockedlog.class.php.

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

Referenced by getPreviousHash().

◆ getUser()

BlockedLog::getUser ( )
 try to retrieve user author
Returns
string

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

◆ loadTrackedEvents()

BlockedLog::loadTrackedEvents ( )

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

Returns
int Always 1

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

◆ setCertified()

BlockedLog::setCertified ( )

Set block certified by authority.

Returns
boolean

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

◆ setObjectData()

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

Populate properties of log from object data.

Parameters
Object$objectobject to store
string$actionaction
string$amountsamounts
User$fuserUser object (forced)
Returns
int >0 if OK, <0 if KO

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

References dol_getIdFromCode(), and dol_syslog().


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