29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
31require_once DOL_DOCUMENT_ROOT.
'/datapolicy/lib/datapolicy.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/datapolicy/class/datapolicycron.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/cron/class/cronjob.class.php';
45 trigger_error(
"Langs object was not initialized correctly.", E_USER_ERROR);
49$langs->loadLangs(array(
'admin',
'companies',
'members',
'cron',
'datapolicy',
'recruitment'));
52$action =
GETPOST(
'action',
'aZ09');
53$backtopage =
GETPOST(
'backtopage',
'alpha');
60$arrayofparameters = array();
62$arrayofelem = $dataPolicyCron->getDataPolicies();
63$arrayofparameters = array();
64foreach ($arrayofelem as $key => $val) {
65 $arrayofparameters[$val[
'group']][$key] = array(
66 'label_key' => $val[
'label_key'],
67 'picto' => $val[
'picto'],
68 'config_keys' => array(
69 'anonymize' => $val[
'const_anonymize'],
70 'delete' => $val[
'const_delete']
78 '' => $langs->trans(
'Never'),
79 '6' => $langs->trans(
'NB_MONTHS', 6),
80 '12' => $langs->trans(
'ONE_YEAR'),
81 '24' => $langs->trans(
'NB_YEARS', 2),
82 '36' => $langs->trans(
'NB_YEARS', 3),
83 '48' => $langs->trans(
'NB_YEARS', 4),
84 '60' => $langs->trans(
'NB_YEARS', 5),
85 '120' => $langs->trans(
'NB_YEARS', 10),
86 '180' => $langs->trans(
'NB_YEARS', 15),
87 '240' => $langs->trans(
'NB_YEARS', 20),
102if ($action ==
'update') {
107 foreach ($arrayofparameters as $tab) {
108 foreach ($tab as $logicalKey => $val) {
110 foreach ($val[
'config_keys'] as $actionType => $constKey) {
112 if (GETPOSTISSET($constKey)) {
113 $val_const =
GETPOST($constKey,
'alpha');
114 if (
dolibarr_set_const($db, $constKey, $val_const,
'chaine', 0,
'', $conf->entity) >= 0) {
138$page_name =
"datapolicySetup";
141$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
147print
'<span class="opacitymedium">'.$langs->trans(
"datapolicySetupPage").
'</span>';
148print $form->textwithpicto(
'', $langs->trans(
'DATAPOLICY_Tooltip_SETUP', $langs->transnoentitiesnoconv(
"DATAPOLICYJob"), $langs->transnoentitiesnoconv(
"CronList")));
150 print
info_admin($langs->trans(
"ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv(
"CronList")), 0, 0,
'warning');
153 $tmpjob->fetch(0,
'',
'',
'DATAPOLICYJob');
154 if ($tmpjob->status != $tmpjob::STATUS_ENABLED) {
155 print
info_admin($langs->trans(
"JobMustBeEnabledFirst", $langs->transnoentitiesnoconv(
"DATAPOLICYJob"), $langs->transnoentitiesnoconv(
"CronList")), 0, 0,
'warning');
162print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
163print
'<input type="hidden" name="token" value="'.newToken().
'">';
164print
'<input type="hidden" name="action" value="update">';
165print
'<input type="hidden" name="page_y" value="">';
167print
'<div class="div-table-responsive">';
168print
'<table class="tagtable nobottomiftotal liste">';
171print
'<tr class="liste_titre"><td class="titlefield"></td>';
172print
'<td>'.$langs->trans(
"DelayForAnonymization").
'</td>';
173print
'<td>'.$langs->trans(
"DelayForDeletion").
'</td>';
181foreach ($arrayofparameters as $title => $tab) {
182 print
'<tr class="trforbreak liste_titre"><td class="titlefield trforbreak">'.$langs->trans($title).
'</td>';
188 foreach ($tab as $logicalKey => $val) {
189 print
'<tr class="oddeven"><td>';
191 print $langs->trans($val[
'label_key']);
195 print
'<td class="nowraponall">';
197 if (!empty($val[
'config_keys'][
'anonymize'])) {
200 print
Form::selectarray($val[
'config_keys'][
'anonymize'], $valTab, $selectedvalue, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100');
203 $listoffieldsid =
'';
204 foreach ($arrayofelem[$logicalKey][
'anonymize_fields'] as $tmpkey => $tmpval) {
205 if (is_array($tmpval)) {
208 if ($tmpval ===
'MAKEANONYMOUS') {
209 $listoffieldsid .= ($listoffieldsid ?
', ' :
'').$tmpkey.
' -> '.$tmpkey.
'-anon-ID';
210 } elseif (strpos($tmpval,
'__ID__') !==
false) {
211 $listoffieldsid .= ($listoffieldsid ?
', ' :
'').$tmpkey.
' -> '.$tmpval;
215 foreach ($arrayofelem[$logicalKey][
'anonymize_fields'] as $tmpkey => $tmpval) {
216 if ($tmpval !==
'MAKEANONYMOUS' && strpos((
string) $tmpval,
'__ID__') ===
false) {
217 $otherfields .= ($otherfields ?
', ' :
'').$tmpkey.
' -> '.json_encode($tmpval);
221 $sql = $arrayofelem[$logicalKey][
'sql_template'];
222 $sql = preg_replace(
'/__ENTITY__/', (
string) (
int) $conf->entity, $sql);
223 $sql = preg_replace(
'/__DELAY__/', (
string) (
int) $selectedvalue, $sql);
225 $sql = preg_replace(
'/^SELECT [\w+\s+\._]+ FROM/',
'SELECT COUNT(*) as nb FROM', $sql);
227 $htmltooltip = $langs->transnoentitiesnoconv(
"TheFollowingFieldsAreReplaceWith");
228 $htmltooltip .=
'<br><small class="opacitymedium">'.$listoffieldsid.
'</small>';
229 $htmltooltip .=
'<br><br>'.$langs->transnoentitiesnoconv(
"OtherFieldsAreReplaceWithStaticValues");
230 $htmltooltip .=
'<br><small class="opacitymedium">'.$otherfields.
'</small>';
231 $htmltooltip .=
'<br><br>'.$langs->transnoentitiesnoconv(
"TechnicalInformation").
' - SQL to select record:';
232 $htmltooltip .=
'<br><small class="opacitymedium">'.$sql.
'</small>';
233 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmidde', 1, 3, $val[
'config_keys'][
'anonymize']);
236 if ($action ==
'count' &&
GETPOST(
'group') == $logicalKey) {
237 print
'<span class="opacitymedium valignmiddle">'.$langs->trans(
"QualifiedNumber").
' : </span>';
239 $estimatednumber = 0;
241 $resql = $db->query($sql);
243 $obj = $db->fetch_object($resql);
245 $estimatednumber = $obj->nb;
251 print
'Error, bad definition of the array of data policies profiles';
254 print
'<span class="valignmiddle badge badge-info">'.$estimatednumber.
'</span>';
255 } elseif ($selectedvalue) {
256 print
'<span class="opacitymedium valignmiddle">'.$langs->trans(
"QualifiedNumber").
' : </span>';
258 print
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=count&group='.urlencode($logicalKey).
'">';
259 print $langs->trans(
"Calculate");
267 if (!empty($val[
'config_keys'][
'delete'])) {
271 print
Form::selectarray($val[
'config_keys'][
'delete'], $valTab, $selectedvalue, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100');
273 $sql = $arrayofelem[$logicalKey][
'sql_template_delete'];
274 $sql = preg_replace(
'/__ENTITY__/', (
string) (
int) $conf->entity, $sql);
275 $sql = preg_replace(
'/__DELAY__/', (
string) (
int) $selectedvalue, $sql);
277 $sql = preg_replace(
'/^SELECT [\w+\s+\._]+ FROM/',
'SELECT COUNT(*) as nb FROM', $sql);
279 $htmltooltip = $langs->transnoentitiesnoconv(
"TechnicalInformation").
' - SQL to select record:';
280 $htmltooltip .=
'<br><small class="opacitymedium">'.$sql.
'</small>';
281 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmidde', 1, 3, $val[
'config_keys'][
'delete']);
284 if ($action ==
'countdelete' &&
GETPOST(
'group') == $logicalKey) {
285 print
'<span class="opacitymedium valignmiddle">'.$langs->trans(
"QualifiedNumber").
' : </span>';
287 $estimatednumber = 0;
289 $resql = $db->query($sql);
291 $obj = $db->fetch_object($resql);
293 $estimatednumber = $obj->nb;
299 print
'Error, bad definition of the array of data policies profiles';
302 print
'<span class="valignmiddle badge badge-info">'.$estimatednumber.
'</span>';
303 } elseif ($selectedvalue) {
304 print
'<span class="opacitymedium valignmiddle">'.$langs->trans(
"QualifiedNumber").
' : </span>';
306 print
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=countdelete&group='.urlencode($logicalKey).
'">';
307 print $langs->trans(
"Calculate");
320print $form->buttonsSaveCancel(
"Save",
'', array(),
false,
'reposition');
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage translations.
datapolicyAdminPrepareHead()
Prepare admin pages header.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.