dolibarr 24.0.0-beta
DataPolicyCron Class Reference

Class DataPolicyCron. More...

Public Member Functions

 __construct (DoliDB $db)
 Constructor.
 
 getDataPolicies ()
 Defines and returns the centralized data policy configuration.
 
 cleanDataForDataPolicy ()
 Main cron task execution method.
 

Private Member Functions

 _handleDelete ($object, $user, $policy)
 Handles the specific logic for deleting an object.
 
 _handleAnonymize ($object, $user, $policy)
 Handles the specific logic for anonymizing an object.
 
 _anonymizeExtraFields ($object)
 Anonymizes extra fields flagged as personal data (personal_data = 1) for a given object.
 
 _buildCallArguments ($object, $user, $policy, $method)
 Builds the dynamic argument list for method calls based on policy configuration.
 
 _recordActionResult ($result, $object, $action)
 Records the result of an action, updating counters and error messages.
 

Detailed Description

Class DataPolicyCron.

Definition at line 32 of file datapolicycron.class.php.

Constructor & Destructor Documentation

◆ __construct()

DataPolicyCron::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 53 of file datapolicycron.class.php.

References $db.

Member Function Documentation

◆ _anonymizeExtraFields()

DataPolicyCron::_anonymizeExtraFields ( $object)
private

Anonymizes extra fields flagged as personal data (personal_data = 1) for a given object.

Rules applied:

  • varchar/text types: replaced by '—' if not empty
  • numeric types (int, double, price...): replaced by 0 if not empty
  • date types: replaced by '1900-01-01 00:00:00' if not empty
Parameters
CommonObject$objectThe object whose extra fields must be anonymized.
Returns
void

Definition at line 463 of file datapolicycron.class.php.

References $object, and dol_mktime().

Referenced by _handleAnonymize().

◆ _buildCallArguments()

DataPolicyCron::_buildCallArguments ( $object,
$user,
$policy,
$method )
private

Builds the dynamic argument list for method calls based on policy configuration.

Parameters
CommonObject$objectThe target object.
User$userThe user object.
array<string,mixed>$policy The policy configuration.
'delete'|'update'$method The method key ('delete' or 'update').
Returns
mixed[] The list of arguments for the call.
Parameters
string$paramNameName of parameter to get
Returns
mixed Parameter value

Definition at line 522 of file datapolicycron.class.php.

References $object.

Referenced by _handleAnonymize(), and _handleDelete().

◆ _handleAnonymize()

DataPolicyCron::_handleAnonymize ( $object,
$user,
$policy )
private

Handles the specific logic for anonymizing an object.

Parameters
CommonObject$objectThe object to anonymize.
User$userThe user performing the action.
array<string,mixed>$policy The policy configuration.
Returns
int The result of the update operation, or 0 if skipped.

Definition at line 425 of file datapolicycron.class.php.

References $object, _anonymizeExtraFields(), and _buildCallArguments().

◆ _handleDelete()

DataPolicyCron::_handleDelete ( $object,
$user,
$policy )
private

Handles the specific logic for deleting an object.

Parameters
CommonObject$objectThe object to delete.
User$userThe user performing the action.
array<string,mixed>$policy The policy configuration.
Returns
int The result of the delete operation.

Definition at line 410 of file datapolicycron.class.php.

References $object, and _buildCallArguments().

◆ _recordActionResult()

DataPolicyCron::_recordActionResult ( $result,
$object,
$action )
private

Records the result of an action, updating counters and error messages.

Parameters
int$resultThe result code from the action (<0 for error).
CommonObject$objectThe processed object.
string$actionThe action that was performed ('delete' or 'anonymize').
Returns
void

Definition at line 551 of file datapolicycron.class.php.

References $object.

◆ cleanDataForDataPolicy()

DataPolicyCron::cleanDataForDataPolicy ( )

Main cron task execution method.

Orchestrates the data cleaning process by iterating through all defined policies.

Returns
int Returns 0 for success, 1 for failure, as required for cron jobs.

Definition at line 283 of file datapolicycron.class.php.

References $conf, $object, and getDataPolicies().

◆ getDataPolicies()

DataPolicyCron::getDataPolicies ( )

Defines and returns the centralized data policy configuration.

Separating this makes the main method cleaner.

Returns
array<string, array<string, mixed>> The array of all data policies.

Definition at line 64 of file datapolicycron.class.php.

References Societe\CUSTOMER, Societe\CUSTOMER_AND_PROSPECT, dol_mktime(), img_picto(), isModEnabled(), Societe\NO_CUSTOMER, and Societe\PROSPECT.

Referenced by cleanDataForDataPolicy().


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