From 4954e84d560923b3a54d19b5d10dd15a96483101 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 30 Dec 2024 04:53:07 +0100 Subject: [PATCH] Debug v21 --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/datapolicy/admin/setup.php | 37 +++++++++++++++---- htdocs/datapolicy/class/datapolicy.class.php | 25 +++++++------ .../datapolicy/class/datapolicycron.class.php | 11 +++++- htdocs/langs/en_US/datapolicy.lang | 6 ++- 5 files changed, 57 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0b3d5c1ef13..933a07f6d22 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1429,7 +1429,7 @@ function dol_include_once($relpath, $classname = '') * @param int $type 0=Used for a Filesystem path, * 1=Used for an URL path (output relative), * 2=Used for an URL path (output full path using same host that current url), - * 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) + * 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file, for an access from internet) * @param int $returnemptyifnotfound 0:If $type==0 and if file was not found into alternate dir, return default path into main dir (no test on it) * 1:If $type==0 and if file was not found into alternate dir, return empty string * 2:If $type==0 and if file was not found into alternate dir, test into main dir, return default path if found, empty string if not found diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php index ea3ae94a6d5..5351f256011 100644 --- a/htdocs/datapolicy/admin/setup.php +++ b/htdocs/datapolicy/admin/setup.php @@ -156,21 +156,37 @@ $head = datapolicyAdminPrepareHead(); print dol_get_fiche_head($head, 'settings', '', -1, ''); // Setup page goes here -print ''.$langs->trans("datapolicySetupPage").'
'; -// print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP')); +print ''.$langs->trans("datapolicySetupPage").''; +print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP', $langs->trans("DATAPOLICYJob"), $langs->transnoentities("CronList"))); +print '
'; +print '
'; print '
'; +// TODO Show the last date of execution of the job DATAPOLICYJob if ($action == 'edit') { print '
'; print ''; print ''; - print ''; - //print ''; + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table + print '
'.$langs->trans("Parameter").'
'; + + print ''; + print ''; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + print ''; + } + print ''; foreach ($arrayofparameters as $title => $tab) { - print ''; + print ''; + print ''; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + print ''; + } + print ''; + foreach ($tab as $key => $val) { print ''; + print ''; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + print ''; + } + + print ''; } } print '
'.$langs->trans("DelayForAnonymization").''.$langs->trans("DelayForDeletion").'
'.$langs->trans($title).'
'.$langs->trans($title).'
'; print $val['picto']; @@ -184,11 +200,19 @@ if ($action == 'edit') { } print ''; print ajax_combobox($key); - print '
'; + print $langs->trans("FeatureNotYetAvailable"); + print '
'; + print ''; print $form->buttonsSaveCancel("Save", ''); @@ -196,7 +220,6 @@ if ($action == 'edit') { print '
'; } else { print ''; - //print ''; foreach ($arrayofparameters as $title => $tab) { print ''; diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index 8421b84c924..21a19ae7ec6 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -21,6 +21,7 @@ * \file datapolicy/class/datapolicy.class.php * \ingroup datapolicy * \brief Class to manage feature of Data Policy module. + * This class file is not used. */ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -61,7 +62,7 @@ class DataPolicy */ public function getAllContactNotInformed() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db; $langs->load("companies"); @@ -69,9 +70,9 @@ class DataPolicy $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as spe ON spe.fk_object = c.rowid"; - $sql .= " WHERE (c.statut=1 AND c.no_email=0 AND (spe.datapolicy_consentement=0 OR spe.datapolicy_consentement IS NULL) AND (spe.datapolicy_opposition_traitement=0 OR spe.datapolicy_opposition_traitement IS NULL) AND (spe.datapolicy_opposition_prospection=0 OR spe.datapolicy_opposition_prospection IS NULL))"; + $sql .= " WHERE (c.statut = 1 AND c.no_email = 0 AND (spe.datapolicy_consentement = 0 OR spe.datapolicy_consentement IS NULL) AND (spe.datapolicy_opposition_traitement = 0 OR spe.datapolicy_opposition_traitement IS NULL) AND (spe.datapolicy_opposition_prospection = 0 OR spe.datapolicy_opposition_prospection IS NULL))"; $sql .= " AND spe.datapolicy_send IS NULL"; - $sql .= " AND c.entity=".$conf->entity; + $sql .= " AND c.entity = ".((int) $conf->entity); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -99,16 +100,16 @@ class DataPolicy */ public function getAllCompaniesNotInformed() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db; $langs->load("companies"); $sql = "SELECT s.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as se ON se.fk_object = s.rowid"; - $sql .= " WHERE s.statut=0 AND (se.datapolicy_consentement=0 OR se.datapolicy_consentement IS NULL) AND (se.datapolicy_opposition_traitement=0 OR se.datapolicy_opposition_traitement IS NULL) AND (se.datapolicy_opposition_prospection=0 OR se.datapolicy_opposition_prospection IS NULL)"; + $sql .= " WHERE s.statut = 0 AND (se.datapolicy_consentement = 0 OR se.datapolicy_consentement IS NULL) AND (se.datapolicy_opposition_traitement = 0 OR se.datapolicy_opposition_traitement IS NULL) AND (se.datapolicy_opposition_prospection = 0 OR se.datapolicy_opposition_prospection IS NULL)"; $sql .= " AND se.datapolicy_send IS NULL"; - $sql .= " AND s.entity=".$conf->entity; + $sql .= " AND s.entity = ".((int) $conf->entity); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -136,16 +137,16 @@ class DataPolicy */ public function getAllAdherentsNotInformed() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db; $langs->load("adherent"); $sql = "SELECT a.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ae ON ae.fk_object = a.rowid"; - $sql .= " WHERE a.statut=0 AND (ae.datapolicy_consentement=0 OR ae.datapolicy_consentement IS NULL) AND (ae.datapolicy_opposition_traitement=0 OR ae.datapolicy_opposition_traitement IS NULL) AND (ae.datapolicy_opposition_prospection=0 OR ae.datapolicy_opposition_prospection IS NULL)"; + $sql .= " WHERE a.statut = 0 AND (ae.datapolicy_consentement = 0 OR ae.datapolicy_consentement IS NULL) AND (ae.datapolicy_opposition_traitement=0 OR ae.datapolicy_opposition_traitement IS NULL) AND (ae.datapolicy_opposition_prospection=0 OR ae.datapolicy_opposition_prospection IS NULL)"; $sql .= " AND ae.datapolicy_send IS NULL"; - $sql .= " AND a.entity=".$conf->entity; + $sql .= " AND a.entity = ".((int) $conf->entity); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -174,7 +175,7 @@ class DataPolicy */ public static function sendMailDataPolicyContact($contact) { - global $langs, $conf, $db, $user; + global $langs, $db, $user; $error = 0; @@ -252,7 +253,7 @@ class DataPolicy */ public static function sendMailDataPolicyCompany($societe) { - global $langs, $conf, $db, $user; + global $langs, $db, $user; $error = 0; @@ -327,7 +328,7 @@ class DataPolicy */ public static function sendMailDataPolicyAdherent($adherent) { - global $langs, $conf, $db, $user; + global $langs, $db, $user; $error = 0; diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index d2b8d88a1fa..6b588eda92c 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -468,6 +468,7 @@ class DataPolicyCron $this->db->begin(); + // Loop on each type of data foreach ($arrayofparameters as $key => $params) { if (getDolGlobalInt($key) > 0) { // @phan-suppress-next-line PhanPluginPrintfVariableFormatString @@ -488,10 +489,12 @@ class DataPolicyCron $object->fetch($obj->rowid); $object->id = $obj->rowid; - $action = 'anonymize'; // TODO Offer also action "delete" in setup of module + $action = 'anonymize'; // TODO Offer also action "delete" in the setup of the module + // Manage action 'anonymize' if ($action == 'anonymize') { - if ($object->isObjectUsed($obj->rowid) == 0) { // If object to clean is used + if ($object->isObjectUsed($obj->rowid) == 0) { // If object to clean is not used + // Loop on each field to anonymize foreach ($params['fields_anonym'] as $field => $val) { if ($val == 'MAKEANONYMOUS') { $object->$field = $field.'-anonymous-'.$obj->rowid; // @phpstan-ignore-line @@ -499,7 +502,10 @@ class DataPolicyCron $object->$field = $val; } } + + // Update record $result = $object->update($obj->rowid, $user); + if ($result > 0) { $errormsg = $object->error; $error++; @@ -508,6 +514,7 @@ class DataPolicyCron } } + // Manage action 'deletion' if ($action == 'delete') { // If object to clean is not used $result = $object->delete($user); if ($result < 0) { diff --git a/htdocs/langs/en_US/datapolicy.lang b/htdocs/langs/en_US/datapolicy.lang index 7cbc85b7475..73c23f457ee 100644 --- a/htdocs/langs/en_US/datapolicy.lang +++ b/htdocs/langs/en_US/datapolicy.lang @@ -18,7 +18,7 @@ Module4100Desc = Module to manage Data Privacy (Conformity with the GDPR) # Administration page datapolicySetup = Module Data Privacy Policy Setup Deletion = Deletion of data -datapolicySetupPage = Depending on the laws of your countries (Example Article 5 of the GDPR), personal data must be kept for a period not exceeding the duration the data is needed for the purpose for which it was collected, except for archival purposes.
The deletion will be done automatically after a certain duration without events (the duration which you will have indicated below). +datapolicySetupPage = Depending on the laws of your countries (Example Article 5 of the GDPR), personal data must be kept for a period not exceeding the duration the data is needed for the purpose for which it was collected, except for archival purposes.
This module will make an anonymization automatically after a certain duration without events (the duration which you will have indicated below) and if the object has no existing business object children. NB_MONTHS = %s months ONE_YEAR = 1 year NB_YEARS = %s years @@ -33,12 +33,14 @@ DATAPOLICY_CONTACT_PROSPECT_CLIENT = Prospect/Customer DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT = Nor prospect/Nor customer DATAPOLICY_CONTACT_FOURNISSEUR = Supplier DATAPOLICY_ADHERENT = Member -DATAPOLICY_Tooltip_SETUP=Define the delay with no interaction after which you want the record to be automatically purged. +DATAPOLICY_Tooltip_SETUP=The anonymization is done by the scheduled job "%s" ran by the module "%s", so this module must be enabled and working correctly. SendAgreementText = You can send a GDPR email to all your relevant contacts (who have not yet received an email and for which you have not registered anything about their GDPR agreement). To do this, use the following button. SendAgreement = Send emails AllAgreementSend = All emails have been sent TXTLINKDATAPOLICYACCEPT = Text for the link "agreement" TXTLINKDATAPOLICYREFUSE = Text for the link "disagreement" +DelayForAnonymization=Delay for anonymization +DelayForDeletion=Delay for deletion # Extrafields DATAPOLICY_BLOCKCHECKBOX = GDPR : Processing of personal data DATAPOLICY_consentement = Consent obtained for the processing of personal data
'.$langs->trans("Parameter").'
'.$langs->trans($title).'