Debug v21

This commit is contained in:
Laurent Destailleur (aka Eldy) 2024-12-30 04:53:07 +01:00
parent c4889d3a09
commit 4954e84d56
5 changed files with 57 additions and 24 deletions

View File

@ -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

View File

@ -156,21 +156,37 @@ $head = datapolicyAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', '', -1, '');
// Setup page goes here
print '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span><br>';
// print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP'));
print '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span>';
print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP', $langs->trans("DATAPOLICYJob"), $langs->transnoentities("CronList")));
print '<br>';
print '<br>';
print '<br>';
// TODO Show the last date of execution of the job DATAPOLICYJob
if ($action == 'edit') {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">';
//print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="tagtable nobottomiftotal liste">';
print '<tr class="liste_titre"><td class="titlefield"></td>';
print '<td>'.$langs->trans("DelayForAnonymization").'</td>';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<td>'.$langs->trans("DelayForDeletion").'</td>';
}
print '</tr>';
foreach ($arrayofparameters as $title => $tab) {
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
print '<tr class="trforbreak liste_titre"><td class="titlefield trforbreak">'.$langs->trans($title).'</td>';
print '<td></td>';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<td></td>';
}
print '</tr>';
foreach ($tab as $key => $val) {
print '<tr class="oddeven"><td>';
print $val['picto'];
@ -184,11 +200,19 @@ if ($action == 'edit') {
}
print '</select>';
print ajax_combobox($key);
print '</td></tr>';
print '</td>';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<td>';
print $langs->trans("FeatureNotYetAvailable");
print '</td>';
}
print '</tr>';
}
}
print '</table>';
print '</div>';
print $form->buttonsSaveCancel("Save", '');
@ -196,7 +220,6 @@ if ($action == 'edit') {
print '<br>';
} else {
print '<table class="noborder centpercent">';
//print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
foreach ($arrayofparameters as $title => $tab) {
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';

View File

@ -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;

View File

@ -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) {

View File

@ -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 <a href="http://www.privacy-regulation.eu/en/5.htm" target="_blank" rel="noopener noreferrer external">Article 5</a> 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.<br>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 <a href="http://www.privacy-regulation.eu/en/5.htm" target="_blank" rel="noopener noreferrer external">Article 5</a> 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.<br>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