2018-10-06 00:51:47 +00:00
< ? php
2019-02-24 13:30:02 +00:00
/* Copyright ( C ) 2018 Nicolas ZABOURI < info @ inovea - conseil . com >
2026-06-28 11:15:24 +00:00
* Copyright ( C ) 2018 - 2026 Frédéric France < frederic . france @ free . fr >
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Copyright ( C ) 2024 William Mead < william . mead @ manchenumerique . fr >
2026-07-19 15:32:14 +00:00
* Copyright ( C ) 2024 - 2026 MDW < mdeweerd @ users . noreply . github . com >
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Copyright ( C ) 2025 Quentin VIAL -- GOUTEYRON < quentin . vial - gouteyron @ atm - consulting . fr >
2026-05-13 12:37:14 +00:00
* Copyright ( C ) 2025 Waël Almoman < info @ almoman . com >
2018-10-06 01:13:03 +00:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-10-06 01:13:03 +00:00
*/
2018-10-06 00:51:47 +00:00
2018-10-06 01:13:03 +00:00
/**
2019-02-24 13:30:02 +00:00
* \file htdocs / datapolicy / class / datapolicycron . class . php
2018-10-15 12:04:42 +00:00
* \ingroup datapolicy
2019-09-06 17:56:00 +00:00
* \brief File for cron task of module DataPolicy
2018-10-06 01:13:03 +00:00
*/
2018-10-06 00:51:47 +00:00
2018-10-06 01:13:03 +00:00
/**
2018-10-15 12:04:42 +00:00
* Class DataPolicyCron
2018-10-06 01:13:03 +00:00
*/
2018-10-15 12:04:42 +00:00
class DataPolicyCron
2018-10-06 01:13:03 +00:00
{
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
/** @var DoliDB Database handler. */
public $db ;
/** @var string Final error message if any. */
public $error ;
/** @var string Final output message on success. */
public $output ;
/** @var int Counter for updated records. */
private $nbupdated = 0 ;
/** @var int Counter for deleted records. */
private $ nbdeleted = 0 ;
/** @var int Counter for errors. */
private $errorCount = 0 ;
/** @var string[] Array to store detailed error messages. */
private $errorMessages = array ();
2023-02-22 19:58:55 +00:00
/**
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Constructor
* @ param DoliDB $db Database handler
2023-02-22 19:58:55 +00:00
*/
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
public function __construct ( DoliDB $db )
{
$this -> db = $db ;
}
2023-02-22 19:58:55 +00:00
2025-07-24 12:42:45 +00:00
/**
* Defines and returns the centralized data policy configuration .
* Separating this makes the main method cleaner .
*
* @ return array < string , array < string , mixed >> The array of all data policies .
*/
public function getDataPolicies ()
{
2026-07-19 15:32:14 +00:00
$sanitized_prefix = $this -> db -> prefix ();
2025-07-24 12:42:45 +00:00
2025-08-15 15:20:28 +00:00
$arrayofpolicies = array (
2025-07-24 12:42:45 +00:00
// --- Third Parties ---
'tiers_client' => array (
'group' => 'ThirdParty' ,
'label_key' => 'DATAPOLICY_TIERS_CLIENT' ,
'picto' => img_picto ( '' , 'company' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_TIERS_CLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.client = " . Societe :: CUSTOMER . " AND s.fournisseur = 0 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Societe' ,
'file' => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'name' => 'MAKEANONYMOUS' , 'name_alias' => 'MAKEANONYMOUS' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'url' => '---' , 'fax' => '---' , 'siret' => '---' , 'siren' => '---' , 'ape' => '---' , 'idprof4' => '---' , 'idprof5' => '---' , 'idprof6' => '---' , 'tva_intra' => '---' , 'capital' => 0 , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'id' , 'user' ), // $object->delete($id, $user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'tiers_prospect' => array (
'group' => 'ThirdParty' ,
'label_key' => 'DATAPOLICY_TIERS_PROSPECT' ,
'picto' => img_picto ( '' , 'company' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_TIERS_PROSPECT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.client = " . Societe :: PROSPECT . " AND s.fournisseur = 0 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Societe' ,
'file' => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'name' => 'MAKEANONYMOUS' , 'name_alias' => 'MAKEANONYMOUS' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'url' => '---' , 'fax' => '---' , 'siret' => '---' , 'siren' => '---' , 'ape' => '---' , 'idprof4' => '---' , 'idprof5' => '---' , 'idprof6' => '---' , 'tva_intra' => '---' , 'capital' => 0 , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'id' , 'user' ), // $object->delete($id, $user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'tiers_prospect_client' => array (
'group' => 'ThirdParty' ,
'label_key' => 'DATAPOLICY_TIERS_PROSPECT_CLIENT' ,
'picto' => img_picto ( '' , 'company' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_TIERS_PROSPECT_CLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.client = " . Societe :: CUSTOMER_AND_PROSPECT . " AND s.fournisseur = 0 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Societe' ,
'file' => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'name' => 'MAKEANONYMOUS' , 'name_alias' => 'MAKEANONYMOUS' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'url' => '---' , 'fax' => '---' , 'siret' => '---' , 'siren' => '---' , 'ape' => '---' , 'idprof4' => '---' , 'idprof5' => '---' , 'idprof6' => '---' , 'tva_intra' => '---' , 'capital' => 0 , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'id' , 'user' ), // $object->delete($id, $user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'tiers_niprosp_niclient' => array (
'group' => 'ThirdParty' ,
'label_key' => 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT' ,
'picto' => img_picto ( '' , 'company' , 'class="pictofixedwidth"' ),
'const_delete' => 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT_DELETE_DELAY' ,
'const_anonymize' => 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.client = " . Societe :: NO_CUSTOMER . " AND s.fournisseur = 0 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
'sql_template_delete' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.client = " . Societe :: NO_CUSTOMER . " AND s.fournisseur = 0 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Societe' ,
'file' => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'name' => 'MAKEANONYMOUS' , 'name_alias' => 'MAKEANONYMOUS' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'url' => '---' , 'fax' => '---' , 'siret' => '---' , 'siren' => '---' , 'ape' => '---' , 'idprof4' => '---' , 'idprof5' => '---' , 'idprof6' => '---' , 'tva_intra' => '---' , 'capital' => 0 , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'id' , 'user' ), // $object->delete($id, $user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'tiers_fournisseur' => array (
'group' => 'ThirdParty' ,
'label_key' => 'DATAPOLICY_TIERS_FOURNISSEUR' ,
'picto' => img_picto ( '' , 'supplier' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_TIERS_FOURNISSEUR_ANONYMIZE_DELAY' ,
2026-06-13 16:54:33 +00:00
// Suppliers must be checked against llx_facture_fourn (purchase invoices),
// not llx_facture (sales invoices). A pure supplier with no sales would
// otherwise always pass the filter and get anonymized regardless of
// purchase history (#38788).
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT s.rowid FROM " . $sanitized_prefix . " societe as s WHERE s.entity = __ENTITY__ AND s.fournisseur = 1 AND s.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture_fourn as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Societe' ,
'file' => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'name' => 'MAKEANONYMOUS' , 'name_alias' => 'MAKEANONYMOUS' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'url' => '---' , 'fax' => '---' , 'siret' => '---' , 'siren' => '---' , 'ape' => '---' , 'idprof4' => '---' , 'idprof5' => '---' , 'idprof6' => '---' , 'tva_intra' => '---' , 'capital' => 0 , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'id' , 'user' ), // $object->delete($id, $user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
// --- Contacts ---
'contact_client' => array (
'group' => 'Contact' ,
'label_key' => 'DATAPOLICY_CONTACT_CLIENT' ,
'picto' => img_picto ( '' , 'contact' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_CONTACT_CLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT c.rowid FROM " . $sanitized_prefix . " socpeople as c INNER JOIN " . $sanitized_prefix . " societe as s ON s.rowid = c.fk_soc WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND s.client = " . Societe :: CUSTOMER . " AND s.fournisseur = 0 AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Contact' ,
'file' => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'poste' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone_pro' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'contact_prospect' => array (
'group' => 'Contact' ,
'label_key' => 'DATAPOLICY_CONTACT_PROSPECT' ,
'picto' => img_picto ( '' , 'contact' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_CONTACT_PROSPECT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT c.rowid FROM " . $sanitized_prefix . " socpeople as c INNER JOIN " . $sanitized_prefix . " societe as s ON s.rowid = c.fk_soc WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND s.client = " . Societe :: PROSPECT . " AND s.fournisseur = 0 AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Contact' ,
'file' => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'poste' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone_pro' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'contact_prospect_client' => array (
'group' => 'Contact' ,
'label_key' => 'DATAPOLICY_CONTACT_PROSPECT_CLIENT' ,
'picto' => img_picto ( '' , 'contact' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_CONTACT_PROSPECT_CLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT c.rowid FROM " . $sanitized_prefix . " socpeople as c INNER JOIN " . $sanitized_prefix . " societe as s ON s.rowid = c.fk_soc WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND s.client = " . Societe :: CUSTOMER_AND_PROSPECT . " AND s.fournisseur = 0 AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Contact' ,
'file' => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'poste' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone_pro' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'contact_niprosp_niclient' => array (
'group' => 'Contact' ,
'label_key' => 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT' ,
'picto' => img_picto ( '' , 'contact' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT_ANONYMIZE_DELAY' ,
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT c.rowid FROM " . $sanitized_prefix . " socpeople as c INNER JOIN " . $sanitized_prefix . " societe as s ON s.rowid = c.fk_soc WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND s.client = " . Societe :: NO_CUSTOMER . " AND s.fournisseur = 0 AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Contact' ,
'file' => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'poste' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone_pro' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
),
'contact_fournisseur' => array (
'group' => 'Contact' ,
'label_key' => 'DATAPOLICY_CONTACT_FOURNISSEUR' ,
'picto' => img_picto ( '' , 'contact' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_CONTACT_FOURNISSEUR_ANONYMIZE_DELAY' ,
2026-06-13 16:54:33 +00:00
// Same as tiers_fournisseur above: a contact attached to a pure supplier
// must be checked against llx_facture_fourn, not llx_facture (#38788).
2026-07-19 15:32:14 +00:00
'sql_template' => " SELECT c.rowid FROM " . $sanitized_prefix . " socpeople as c INNER JOIN " . $sanitized_prefix . " societe as s ON s.rowid = c.fk_soc WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND s.fournisseur = 1 AND NOT EXISTS (SELECT a.id FROM " . $sanitized_prefix . " actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) AND NOT EXISTS (SELECT f.rowid FROM " . $sanitized_prefix . " facture_fourn as f WHERE f.fk_soc = s.rowid) " ,
2025-07-24 12:42:45 +00:00
'class' => 'Contact' ,
'file' => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ,
2025-09-17 12:03:09 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'poste' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone_pro' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'geolat' => 0 , 'geolong' => 0 , 'ip' => '0.0.0.0' ),
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'id' , 'user' ) // $object->update($id, $user)
)
2025-08-15 15:20:28 +00:00
)
);
if ( isModEnabled ( 'member' )) {
2026-05-10 21:07:20 +00:00
// --- Members --- Reference date: datefin (end of membership validity). tms (last modification) is intentionally NOT used here.
2026-07-19 15:32:14 +00:00
$sqltemplate = " SELECT a.rowid FROM " . $sanitized_prefix . " adherent as a WHERE a.entity = __ENTITY__ AND a.datefin < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) " ;
$sqltemplate .= " AND NOT EXISTS (SELECT ac.id FROM " . $sanitized_prefix . " actioncomm as ac WHERE ac.fk_element = a.rowid AND ac.elementtype = 'member' AND ac.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) " ;
$sqltemplate .= " AND NOT EXISTS (SELECT s.rowid FROM " . $sanitized_prefix . " subscription as s WHERE s.fk_adherent = a.rowid AND s.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) " ;
2025-08-15 15:20:28 +00:00
$arrayofpolicies [ 'adherent' ] = array (
2025-07-24 12:42:45 +00:00
'group' => 'Member' ,
'label_key' => 'DATAPOLICY_ADHERENT' ,
'picto' => img_picto ( '' , 'member' , 'class="pictofixedwidth"' ),
2025-08-15 15:20:28 +00:00
'const_delete' => '' ,
2025-07-24 12:42:45 +00:00
'const_anonymize' => 'DATAPOLICY_ADHERENT_ANONYMIZE_DELAY' ,
2025-08-15 15:20:28 +00:00
'sql_template' => $sqltemplate ,
2025-07-24 12:42:45 +00:00
'class' => 'Adherent' ,
'file' => DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ,
2026-06-28 11:15:24 +00:00
'anonymize_fields' => array ( 'lastname' => 'MAKEANONYMOUS' , 'firstname' => 'MAKEANONYMOUS' , 'societe' => '---' , 'address' => '---' , 'town' => '---' , 'zip' => '---' , 'phone' => '---' , 'phone_perso' => '---' , 'phone_mobile' => '---' , 'email' => 'anonymous+__ID__@example.com' , 'birth' => dol_mktime ( 0 , 0 , 0 , 1 , 1 , 1900 ), 'photo' => '' , 'url' => '---' , 'fax' => '---' , 'socialnetworks' => [], 'ip' => '0.0.0.0' , 'note_private' => '---' , 'note_public' => '---' , 'statut' => 0 ), // Force status to "canceled"
2025-07-24 12:42:45 +00:00
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'user' ) // $object->update($user)
)
2025-08-15 15:20:28 +00:00
);
}
if ( isModEnabled ( 'recruitment' )) {
2025-07-24 12:42:45 +00:00
// --- Recruitment ---
2025-08-15 15:20:28 +00:00
$arrayofpolicies [ 'recruitment_candidature' ] = array (
2025-07-24 12:42:45 +00:00
'group' => 'Recruitment' ,
'label_key' => 'DATAPOLICY_RECRUITMENT_CANDIDATURE' ,
'picto' => img_picto ( '' , 'recruitmentcandidature' , 'class="pictofixedwidth"' ),
'const_delete' => 'DATAPOLICY_RECRUITMENT_CANDIDATURE_DELETE_DELAY' ,
'const_anonymize' => '' , // Anonymization not applicable
2026-07-19 15:32:14 +00:00
'sql_template_delete' => " SELECT c.rowid FROM " . $sanitized_prefix . " recruitment_recruitmentcandidature as c WHERE c.entity = __ENTITY__ AND c.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH) AND NOT EXISTS (SELECT ac.id FROM " . $sanitized_prefix . " actioncomm as ac WHERE ac.elementtype = 'recruitmentcandidature@recruitment' AND ac.fk_element = c.rowid AND ac.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)) " ,
2025-07-24 12:42:45 +00:00
'class' => 'RecruitmentCandidature' ,
'file' => DOL_DOCUMENT_ROOT . '/recruitment/class/recruitmentcandidature.class.php' ,
'anonymize_fields' => array (),
'call_params' => array (
'delete' => array ( 'user' ), // $object->delete($user)
'update' => array ( 'user' ) // $object->update($user)
)
2025-08-15 15:20:28 +00:00
);
}
// TODO Allow an external module to add an entry into the array
return $arrayofpolicies ;
2025-07-24 12:42:45 +00:00
}
2024-11-06 19:15:15 +00:00
/**
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Main cron task execution method .
* Orchestrates the data cleaning process by iterating through all defined policies .
2025-07-24 12:42:45 +00:00
*
* @ return int Returns 0 for success , 1 for failure , as required for cron jobs .
2024-11-06 19:15:15 +00:00
*/
2025-09-28 11:55:39 +00:00
public function cleanDataForDataPolicy () : int
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
{
global $conf , $user ;
// Reset state properties for this specific execution run.
$this -> nbupdated = 0 ;
$this -> nbdeleted = 0 ;
$this -> errorCount = 0 ;
$this -> errorMessages = array ();
// Tracks record IDs that have been processed in this run to prevent duplicate actions (e.g., anonymizing a just-deleted record).
$processedIds = array ();
// Caches object instances to avoid redundant 'new Class()' calls, improving performance.
$objectInstances = array ();
// Retrieve the master list of all data policies. This separates configuration from execution.
2025-07-24 12:42:45 +00:00
$dataPolicies = $this -> getDataPolicies ();
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$this -> db -> begin ();
// Iterate through each defined policy to apply its rules.
foreach ( $dataPolicies as $policy ) {
// Instantiate object only once per class type for efficiency.
if ( ! isset ( $objectInstances [ $policy [ 'class' ]])) {
require_once $policy [ 'file' ];
2025-07-24 12:42:45 +00:00
$classtoinit = $policy [ 'class' ];
$objectInstances [ $policy [ 'class' ]] = new $classtoinit ( $this -> db );
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
}
$object = $objectInstances [ $policy [ 'class' ]];
2025-07-24 12:42:45 +00:00
// Process actions.
// ->errorCount, ->nbupdated and ->nbdelete will be set after that.
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
// The order of operations is critical: deletion is always processed before anonymization.
2025-07-24 12:42:45 +00:00
// This ensures that if a record meets criteria for both, it is deleted as the first and final action.
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$this -> _processPolicyAction ( $policy , 'delete' , $object , $processedIds , $conf , $user );
2025-07-24 12:42:45 +00:00
// Now process anonymization
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$this -> _processPolicyAction ( $policy , 'anonymize' , $object , $processedIds , $conf , $user );
}
// Finalize the transaction based on the outcome of all operations.
if ( ! $this -> errorCount ) {
$this -> db -> commit ();
$this -> output = $this -> nbupdated . ' record(s) anonymized, ' . $this -> nbdeleted . ' record(s) deleted.' ;
} else {
$this -> db -> rollback ();
$this -> error = implode ( " \n " , $this -> errorMessages );
}
return $this -> errorCount ? 1 : 0 ;
}
2023-08-05 20:57:12 +00:00
2024-11-06 19:15:15 +00:00
/**
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Processes a specific action ( delete or anonymize ) for a given policy .
* This method orchestrates the process by delegating to specialized handlers .
*
* @ param array < string , mixed > $policy The policy definition array .
* @ param string $action The action to perform : 'delete' or 'anonymize' .
* @ param CommonObject $object The instantiated Dolibarr object .
* @ param int [] $processedIds Reference to the array of processed IDs .
* @ param object $conf The global conf object .
* @ param User $user The user object for history tracking .
* @ return void
2024-11-06 19:15:15 +00:00
*/
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
private function _processPolicyAction ( $policy , $action , $object , & $processedIds , $conf , $user )
{
$constName = $policy [ 'const_' . $action ] ? ? null ;
$delay = $constName ? getDolGlobalInt ( $constName ) : 0 ;
if ( $delay <= 0 ) {
return ;
}
// Prepare SQL query
$sqlPlaceholders = array (
2026-07-19 15:32:14 +00:00
'__ENTITY__' => ( string ) (( int ) $conf -> entity ),
'__DELAY__' => ( string ) (( int ) $delay ),
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
'__NOW__' => " ' " . $this -> db -> idate ( dol_now ()) . " ' "
);
2026-07-19 15:32:14 +00:00
$sql = str_replace ( array_keys ( $sqlPlaceholders ), array_values ( $sqlPlaceholders ), $policy [ 'sql_template' . ( $action == 'delete' ? '_delete' : '' )]); // @phan-suppress-current-line SqlInjection
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$resql = $this -> db -> query ( $sql );
if ( ! $resql ) {
$this -> errorCount ++ ;
$this -> errorMessages [] = 'Error executing ' . $action . ' query for policy ' . $constName . ': ' . $this -> db -> lasterror ();
return ;
}
// Define the handler method for the action
$handlerMethod = '_handle' . ucfirst ( $action );
// Process the records found by the query
while ( $obj = $this -> db -> fetch_object ( $resql )) {
if ( in_array ( $obj -> rowid , $processedIds ) || ! method_exists ( $this , $handlerMethod )) {
continue ;
}
/** @var CommonObject $object */
$object = clone $object ;
$object -> fetch ( $obj -> rowid );
2026-06-13 23:53:19 +00:00
// isObjectUsed() is a referential-integrity guard for deletion (cannot drop a
// thirdparty that still has quotes/orders/contracts pointing at it). Anonymization
// must still be allowed: personal data has to be erasable even when commercial
// documents from the retention period are kept (#38786).
if ( $action === 'delete' && ! empty ( $object -> childtables ) && method_exists ( $object , 'isObjectUsed' ) && $object -> isObjectUsed () != 0 ) {
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
continue ; // Not an error, just skipping.
}
// Dynamically call the appropriate handler (_handleDelete or _handleAnonymize)
$result = $this -> $handlerMethod ( $object , $user , $policy );
2023-08-05 20:57:12 +00:00
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
// Record the outcome and add to processed list on success
$this -> _recordActionResult ( $result , $object , $action );
$processedIds [] = $obj -> rowid ;
}
}
2023-08-05 20:57:12 +00:00
2019-09-06 17:41:15 +00:00
/**
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Handles the specific logic for deleting an object .
2019-09-06 17:41:15 +00:00
*
2025-07-24 12:42:45 +00:00
* @ param CommonObject $object The object to delete .
* @ param User $user The user performing the action .
* @ param array < string , mixed > $policy The policy configuration .
* @ return int The result of the delete operation .
2019-09-06 17:41:15 +00:00
*/
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
private function _handleDelete ( $object , $user , $policy ) : int
2019-09-06 17:41:15 +00:00
{
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$callArgs = $this -> _buildCallArguments ( $object , $user , $policy , 'delete' );
return $object -> delete ( ... $callArgs );
2019-09-06 17:41:15 +00:00
}
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
/**
* Handles the specific logic for anonymizing an object .
*
2025-07-24 12:42:45 +00:00
* @ param CommonObject $object The object to anonymize .
* @ param User $user The user performing the action .
* @ param array < string , mixed > $policy The policy configuration .
* @ return int The result of the update operation , or 0 if skipped .
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
*/
2025-09-28 11:55:39 +00:00
private function _handleAnonymize ( $object , $user , $policy ) : int
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
{
foreach ( $policy [ 'anonymize_fields' ] as $field => $val ) {
2025-07-24 12:42:45 +00:00
if ( $val == 'MAKEANONYMOUS' ) {
// For each field with rule "MAKEANONYMOUS, set the new value, keeping the ID.
2025-08-15 14:05:05 +00:00
$object -> $field = $field . '-anon-' . $object -> id ;
2025-07-24 12:42:45 +00:00
} else {
// For others, force the value, but only if not already empty.
if ( ! empty ( $object -> $field )) {
2025-09-17 12:22:53 +00:00
$newval = str_replace ( '__ID__' , $object -> id ? ( string ) $object -> id : '0' , $val );
2025-09-17 12:03:09 +00:00
$object -> $field = $newval ;
2025-07-24 12:42:45 +00:00
}
}
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
}
2026-05-13 12:37:14 +00:00
$this -> _anonymizeExtraFields ( $object );
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$callArgs = $this -> _buildCallArguments ( $object , $user , $policy , 'update' );
2026-05-13 12:37:14 +00:00
$result = $object -> update ( ... $callArgs );
if ( $result > 0 ) {
$object -> insertExtraFields ();
}
return $result ;
}
/**
* 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
*
* @ param CommonObject $object The object whose extra fields must be anonymized .
* @ return void
*/
private function _anonymizeExtraFields ( $object )
{
if ( empty ( $object -> table_element )) {
return ;
}
// Retrieve extra fields definitions flagged as personal data for this object type
$sql = " SELECT ef.name, ef.type " ;
$sql .= " FROM " . $this -> db -> prefix () . " extrafields as ef " ;
$sql .= " WHERE ef.elementtype = ' " . $this -> db -> escape ( $object -> table_element ) . " ' " ;
$sql .= " AND ef.personal_data = 1 " ;
$sql .= " AND ef.entity IN (0, " . ( int ) ( isset ( $GLOBALS [ 'conf' ]) ? $GLOBALS [ 'conf' ] -> entity : 1 ) . " ) " ;
$resql = $this -> db -> query ( $sql );
if ( ! $resql ) {
$this -> errorCount ++ ;
$this -> errorMessages [] = 'Error fetching personal extra fields for ' . $object -> table_element . ': ' . $this -> db -> lasterror ();
return ;
}
while ( $efObj = $this -> db -> fetch_object ( $resql )) {
$fieldName = $efObj -> name ;
$fieldType = $efObj -> type ;
// Extra field values are stored in $object->array_options with key 'options_<name>'
$optionKey = 'options_' . $fieldName ;
if ( ! isset ( $object -> array_options [ $optionKey ])) {
continue ;
}
if ( empty ( $object -> array_options [ $optionKey ])) {
continue ;
}
if ( in_array ( $fieldType , array ( 'multiselect' , 'checkbox' ))) {
$object -> array_options [ $optionKey ] = array (); // Default: treat as array
} elseif ( in_array ( $fieldType , array ( 'boolean' , 'radio' ))) {
$object -> array_options [ $optionKey ] = '0' ; // Default: treat as boolean
} elseif ( in_array ( $fieldType , array ( 'date' , 'datetime' , 'timestamp' ))) {
$object -> array_options [ $optionKey ] = dol_mktime ( 0 , 0 , 0 , 1 , 1 , 1900 ); // Default: treat as timestamp
} elseif ( in_array ( $fieldType , array ( 'int' , 'double' , 'price' , 'stars' ))) {
$object -> array_options [ $optionKey ] = 0 ; // Default: treat as numeric
} else {
$object -> array_options [ $optionKey ] = '---' ; // Default: treat as varchar/text
}
}
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
}
/**
* Builds the dynamic argument list for method calls based on policy configuration .
*
* @ param CommonObject $object The target object .
* @ param User $user The user object .
* @ param array < string , mixed > $policy The policy configuration .
2025-09-28 11:55:39 +00:00
* @ param 'delete' | 'update' $method The method key ( 'delete' or 'update' ) .
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* @ return mixed [] The list of arguments for the call .
*/
private function _buildCallArguments ( $object , $user , $policy , $method )
{
$availableArgs = array (
'id' => $object -> id ,
'user' => $user
);
$paramConfig = $policy [ 'call_params' ][ $method ] ? ? [];
2025-09-28 11:55:39 +00:00
return array_map (
/**
* @ param string $paramName Name of parameter to get
* @ return mixed Parameter value
*/
static function ( string $paramName ) use ( $availableArgs ) {
return $availableArgs [ $paramName ];
},
$paramConfig
);
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
}
2019-09-06 17:41:15 +00:00
2020-10-31 13:32:18 +00:00
/**
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* Records the result of an action , updating counters and error messages .
2020-10-31 13:32:18 +00:00
*
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
* @ param int $result The result code from the action ( < 0 for error ) .
* @ param CommonObject $object The processed object .
* @ param string $action The action that was performed ( 'delete' or 'anonymize' ) .
* @ return void
2020-10-31 13:32:18 +00:00
*/
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
private function _recordActionResult ( $result , $object , $action )
2020-10-31 13:32:18 +00:00
{
2026-05-22 19:46:09 +00:00
if ( $result < 0 ) {
NEW : Major overhaul of DataPolicyCron and add Recruitment policy (#34704)
* refactor(datapolicy): redesign setup and logic for GDPR compliance
- Introduced a data-driven configuration structure for setup.php.
- Added support for a new "recruitment" GDPR datapolicy configuration.
- Streamlined code for managing anonymization and deletion delays.
- Enhanced dropdown generation logic to improve maintainability.
- Simplified data anonymization and deletion methods in cron execution.
This change provides more flexibility and modularity while ensuring compliance with GDPR standards.
* refactor(datapolicy): enhance data cleaning logic and add modular handlers
- Refactored `cleanDataForDataPolicy` method for better readability and efficiency.
- Implemented modular handlers for deletion and anonymization (_handleDelete and _handleAnonymize).
- Added dynamic argument building for method calls based on policy configurations.
- Improved SQL query preparation with placeholders for better database compatibility.
- Enhanced error handling and outcome recording in data processing.
This update simplifies extensibility and ensures robust handling of datapolicies.
* fix precommit
* fix
* fix(datapolicy): resolve uninitialized langs object and improve type hints
- Added a check to ensure `$langs` object is properly initialized, preventing runtime errors.
- Improved type hints in `datapolicycron.class.php` for stronger type checking and clarity.
- Replaced `empty` checks with `isset` for better null safety in setup.php dropdown logic.
- Adjusted SQL placeholders to cast values as strings for compatibility.
These changes enhance code robustness, type safety, and error handling.
* fix(datapolicy): improve type hints and streamline dropdown logic
- Added precise type hints (`string`, `array`) to enhance code clarity and type safety.
- Removed redundant condition in dropdown generation for improved maintainability.
- Added type specification for `$paramName` in `array_map` to strengthen type checking.
- Inserted missing class docblock for `CommonObject` in `datapolicycron.class.php`.
These updates lead to cleaner, safer, and more robust code.
* fix(datapolicy): improve type hints and streamline form submission logic
- Added return type hints (`: int`, `: void`, `: array`) in `datapolicycron.class.php` for better type safety and clarity.
- Simplified loop structures in `setup.php` by removing unnecessary variables.
- Revised `buttonsSaveCancel` method usage to eliminate redundant cancel parameter logic.
- Enhanced maintainability through refactoring `_processPolicyAction`, `_handleDelete`, and `_handleAnonymize` methods.
These refinements improve code readability, maintainability, and robustness.
* refactor(datapolicy): replace custom dropdown generation with `Form::selectarray`
- Removed the custom `$generateSelectHtml` function, simplifying code by using the existing `Form::selectarray` method.
- Updated dropdown generation for 'anonymize' and 'delete' actions to align with Dolibarr's standard practices.
- Enhances maintainability by leveraging built-in utilities and reducing custom logic.
* Update datapolicycron.class.php
* Try to fix CI
* Update datapolicycron.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-24 09:41:05 +00:00
$this -> errorCount ++ ;
$this -> errorMessages [] = 'Failed to ' . $action . ' record ID ' . $object -> id . ' from class ' . get_class ( $object ) . '. Error: ' . $object -> errorsToString ();
} else {
if ( $action === 'delete' ) {
$this -> nbdeleted ++ ;
} elseif ( $action === 'anonymize' ) {
// Only count as updated if the update method returns a positive result
$this -> nbupdated ++ ;
}
}
}
2019-02-03 14:21:21 +00:00
}