dolibarr  17.0.4
Public Member Functions | Private Member Functions | List of all members
BlockedLog Class Reference

Class to manage Blocked Log. More...

Public Member Functions

 __construct (DoliDB $db)
 Constructor. More...
 
 loadTrackedEvents ()
 Load list of tracked events into $this->trackedevents. More...
 
 getObjectLink ()
 Try to retrieve source object (it it still exists). More...
 
 getUser ()
 
 setObjectData (&$object, $action, $amounts, $fuser=null)
 Populate properties of log from object data. More...
 
 fetch ($id)
 Get object from database. More...
 
 dolDecodeBlockedData ($data, $mode=0)
 Decode data. More...
 
 setCertified ()
 Set block certified by authority. More...
 
 create ($user, $forcesignature='')
 Create blocked log in database. More...
 
 checkSignature ($previoushash='', $returnarray=0)
 Check if current signature still correct compared to the value in chain. More...
 
 getPreviousHash ($withlock=0, $beforeid=0)
 Get previous signature/hash in chain. More...
 
 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) More...
 
 getSignature ()
 Return the signature (hash) of the "genesis-block" (Block 0). More...
 
 alreadyUsed ($ignoresystem=0)
 Check if module was already used or not for at least one recording. More...
 

Private Member Functions

 buildKeyForSignature ()
 Return a string for signature. More...
 

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

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

Referenced by checkSignature().

◆ 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 946 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 830 of file blockedlog.class.php.

◆ dolDecodeBlockedData()

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

Decode data.

Parameters
string$dataData to unserialize
string$mode0=unserialize, 1=json_decode
Returns
string Value unserialized

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

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

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

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

Referenced by checkSignature().

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

◆ 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 812 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.


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