fix : datapolicy use datefin, add missing notes and force statut=0 when anonymizing members (#38157)

* fix : datapolicy use datefin and force statut=0 when anonymizing members

* unneeded change

* Fix missing note_private and note_public anonymization for members
This commit is contained in:
daraelmin 2026-05-10 23:07:20 +02:00 committed by GitHub
parent c293cf40d8
commit 6f70277b9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -220,8 +220,8 @@ class DataPolicyCron
)
);
if (isModEnabled('member')) {
// --- Members ---
$sqltemplate = "SELECT a.rowid FROM ".$prefix."adherent as a WHERE a.entity = __ENTITY__ AND a.tms < DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH)";
// --- Members --- Reference date: datefin (end of membership validity). tms (last modification) is intentionally NOT used here.
$sqltemplate = "SELECT a.rowid FROM ".$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 ".$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 ".$prefix."subscription as s WHERE s.fk_adherent = a.rowid AND s.tms > DATE_SUB(__NOW__, INTERVAL __DELAY__ MONTH))";
@ -234,7 +234,7 @@ class DataPolicyCron
'sql_template' => $sqltemplate,
'class' => 'Adherent',
'file' => DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php',
'anonymize_fields' => array('lastname' => 'MAKEANONYMOUS', 'firstname' => 'MAKEANONYMOUS', 'societe' => '---', 'address' => '---', 'town' => '---', 'zip' => '---', 'phone' => '---', 'phone_perso' => '---', 'phone_mobile' => '---', 'email' => 'anonymous+__ID__@example.com', 'birth' => '1900-01-01', 'photo' => '', 'url' => '---', 'fax' => '---', 'socialnetworks' => [], 'ip' => '0.0.0.0'),
'anonymize_fields' => array('lastname' => 'MAKEANONYMOUS', 'firstname' => 'MAKEANONYMOUS', 'societe' => '---', 'address' => '---', 'town' => '---', 'zip' => '---', 'phone' => '---', 'phone_perso' => '---', 'phone_mobile' => '---', 'email' => 'anonymous+__ID__@example.com', 'birth' => '1900-01-01', 'photo' => '', 'url' => '---', 'fax' => '---', 'socialnetworks' => [], 'ip' => '0.0.0.0', 'note_private' => '---', 'note_public' => '---', 'statut' => 0), // Force status to "canceled / résilié"
'call_params' => array(
'delete' => array('user'), // $object->delete($user)
'update' => array('user') // $object->update($user)