67 global
$conf, $langs, $user;
69 $langs->load(
'datapolicy@datapolicy');
73 $nbupdated = $nbdeleted = 0;
76 $arrayofparameters = array(
77 'DATAPOLICY_TIERS_CLIENT' => array(
79 SELECT s.rowid FROM ".MAIN_DB_PREFIX.
"societe as s
83 AND s.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
85 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
88 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
92 "file" => DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php',
93 'fields_anonym' => array(
94 'name' =>
'MAKEANONYMOUS',
107 'socialnetworks' => [],
111 'DATAPOLICY_TIERS_PROSPECT' => array(
113 SELECT s.rowid FROM ".MAIN_DB_PREFIX.
"societe as s
116 AND s.fournisseur = 0
117 AND s.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
119 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
122 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
125 "class" =>
"Societe",
126 "file" => DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php',
127 'fields_anonym' => array(
128 'name' =>
'MAKEANONYMOUS',
141 'socialnetworks' => [],
145 'DATAPOLICY_TIERS_PROSPECT_CLIENT' => array(
147 SELECT s.rowid FROM ".MAIN_DB_PREFIX.
"societe as s
150 AND s.fournisseur = 0
151 AND s.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
153 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
156 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
159 "class" =>
"Societe",
160 "file" => DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php',
161 'fields_anonym' => array(
162 'name' =>
'MAKEANONYMOUS',
175 'socialnetworks' => [],
179 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT' => array(
181 SELECT s.rowid FROM ".MAIN_DB_PREFIX.
"societe as s
184 AND s.fournisseur = 0
185 AND s.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
187 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
190 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
193 "class" =>
"Societe",
194 "file" => DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php',
195 'fields_anonym' => array(
196 'name' =>
'MAKEANONYMOUS',
209 'socialnetworks' => [],
213 'DATAPOLICY_TIERS_FOURNISSEUR' => array(
215 SELECT s.rowid FROM ".MAIN_DB_PREFIX.
"societe as s
217 AND s.fournisseur = 1
218 AND s.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
220 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_soc = s.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
223 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
226 "class" =>
"Societe",
227 "file" => DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php',
228 'fields_anonym' => array(
229 'name' =>
'MAKEANONYMOUS',
242 'socialnetworks' => [],
246 'DATAPOLICY_CONTACT_CLIENT' => array(
248 SELECT c.rowid FROM ".MAIN_DB_PREFIX.
"socpeople as c
249 INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = c.fk_soc
251 AND c.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
253 AND s.fournisseur = 0
255 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
258 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
261 "class" =>
"Contact",
262 "file" => DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php',
263 'fields_anonym' => array(
264 'lastname' =>
'MAKEANONYMOUS',
273 'phone_mobile' =>
'',
280 'socialnetworks' => [],
284 'DATAPOLICY_CONTACT_PROSPECT' => array(
286 SELECT c.rowid FROM ".MAIN_DB_PREFIX.
"socpeople as c
287 INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = c.fk_soc
289 AND c.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
291 AND s.fournisseur = 0
293 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
296 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
299 "class" =>
"Contact",
300 "file" => DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php',
301 'fields_anonym' => array(
302 'lastname' =>
'MAKEANONYMOUS',
311 'phone_mobile' =>
'',
318 'socialnetworks' => [],
322 'DATAPOLICY_CONTACT_PROSPECT_CLIENT' => array(
324 SELECT c.rowid FROM ".MAIN_DB_PREFIX.
"socpeople as c
325 INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = c.fk_soc
327 AND c.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
329 AND s.fournisseur = 0
331 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
334 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
337 "class" =>
"Contact",
338 "file" => DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php',
339 'fields_anonym' => array(
340 'lastname' =>
'MAKEANONYMOUS',
349 'phone_mobile' =>
'',
356 'socialnetworks' => [],
360 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT' => array(
362 SELECT c.rowid FROM ".MAIN_DB_PREFIX.
"socpeople as c
363 INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = c.fk_soc
365 AND c.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
367 AND s.fournisseur = 0
369 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
372 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
375 "class" =>
"Contact",
376 "file" => DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php',
377 'fields_anonym' => array(
378 'lastname' =>
'MAKEANONYMOUS',
387 'phone_mobile' =>
'',
394 'socialnetworks' => [],
398 'DATAPOLICY_CONTACT_FOURNISSEUR' => array(
400 SELECT c.rowid FROM ".MAIN_DB_PREFIX.
"socpeople as c
401 INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = c.fk_soc
403 AND c.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
404 AND s.fournisseur = 1
406 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_contact = c.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
409 SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.fk_soc = s.rowid
412 "class" =>
"Contact",
413 "file" => DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php',
414 'fields_anonym' => array(
415 'lastname' =>
'MAKEANONYMOUS',
424 'phone_mobile' =>
'',
431 'socialnetworks' => [],
435 'DATAPOLICY_ADHERENT' => array(
437 SELECT a.rowid FROM ".MAIN_DB_PREFIX.
"adherent as a
439 AND a.tms < DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH)
441 SELECT id FROM ".MAIN_DB_PREFIX.
"actioncomm as a WHERE a.fk_element = a.rowid AND a.tms > DATE_SUB('".$this->db->idate(
dol_now()).
"', INTERVAL %d MONTH) AND a.elementtype LIKE 'member'
444 "class" =>
"Adherent",
445 "file" => DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php',
446 'fields_anonym' => array(
447 'lastname' =>
'MAKEANONYMOUS',
448 'firstname' =>
'MAKEANONYMOUS',
456 'phone_mobile' =>
'',
463 'socialnetworks' => [],
471 foreach ($arrayofparameters as $key => $params) {
476 $resql = $this->db->query($sql);
478 if ($resql && $this->db->num_rows($resql) > 0) {
479 $num = $this->db->num_rows($resql);
482 require_once $params[
'file'];
483 $object =
new $params[
'class']($this->db);
485 while ($i < $num && !$error) {
486 $obj = $this->db->fetch_object($resql);
491 $action =
'anonymize';
493 if ($action ==
'anonymize') {
494 if (
$object->isObjectUsed($obj->rowid) == 0) {
495 foreach ($params[
'fields_anonym'] as $field => $val) {
496 if ($val ==
'MAKEANONYMOUS') {
497 $object->$field = $field.
'-anonymous-'.$obj->rowid;
502 $result =
$object->update($obj->rowid, $user);
511 if ($action ==
'delete') {
512 $result =
$object->delete($user);
530 $this->output = $nbupdated.
' record updated, '.$nbdeleted.
' record deleted';
532 $this->error = $errormsg;