dolibarr  19.0.0-dev
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 if (!defined('NOLOGIN')) {
25  define("NOLOGIN", 1); // This means this output page does not require to be logged.
26 }
27 if (!defined('NOREQUIREMENU')) {
28  define('NOREQUIREMENU', '1');
29 }
30 
31 // Load Dolibarr environment
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
39 
40 $idc = GETPOST('c', 'int');
41 $ids = GETPOST('s', 'int');
42 $ida = GETPOST('a', 'int');
43 $action = GETPOST('action', 'aZ09'); // 1 or 2
44 $l = GETPOST('l', 'alpha');
45 $securitykey = GETPOST('key', 'alpha');
46 
47 $acc = "DATAPOLICIESACCEPT_".$l;
48 $ref = "DATAPOLICIESREFUSE_".$l;
49 $langs->load('datapolicy', 0, 0, $l);
50 
51 
52 /*
53  * Actions
54  */
55 
56 if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
57  print 'Missing paramater s, c or a';
58  return 0;
59 } elseif (!empty($idc)) {
60  $contact = new Contact($db);
61  $contact->fetch($idc);
62  $check = dol_hash($contact->email, 'md5');
63  if ($check != $securitykey) {
64  $return = $langs->trans('Bad value for key.');
65  } elseif ($action == 1) {
66  $contact->array_options['options_datapolicy_consentement'] = 1;
67  $contact->array_options['options_datapolicy_opposition_traitement'] = 0;
68  $contact->array_options['options_datapolicy_opposition_prospection'] = 0;
69  $contact->array_options['options_datapolicy_date'] = dol_now();
70 
71  $return = getDolGlobalString($acc);
72  } elseif ($action == 2) {
73  $contact->no_email = 1;
74  $contact->array_options['options_datapolicy_consentement'] = 0;
75  $contact->array_options['options_datapolicy_opposition_traitement'] = 1;
76  $contact->array_options['options_datapolicy_opposition_prospection'] = 1;
77  $contact->array_options['options_datapolicy_date'] = dol_now();
78 
79  $return = getDolGlobalString($ref);
80  }
81  $contact->update($idc);
82 } elseif (!empty($ids)) {
83  $societe = new Societe($db);
84  $societe->fetch($ids);
85  $check = dol_hash($societe->email, 'md5');
86  if ($check != $securitykey) {
87  $return = $langs->trans('Bad value for key.');
88  } elseif ($action == 1) {
89  $societe->array_options['options_datapolicy_consentement'] = 1;
90  $societe->array_options['options_datapolicy_opposition_traitement'] = 0;
91  $societe->array_options['options_datapolicy_opposition_prospection'] = 0;
92  $societe->array_options['options_datapolicy_date'] = dol_now();
93 
94  $return = getDolGlobalString($acc);
95  } elseif ($action == 2) {
96  $societe->array_options['options_datapolicy_consentement'] = 0;
97  $societe->array_options['options_datapolicy_opposition_traitement'] = 1;
98  $societe->array_options['options_datapolicy_opposition_prospection'] = 1;
99  $societe->array_options['options_datapolicy_date'] = dol_now();
100 
101  $return = getDolGlobalString($ref);
102  }
103  $societe->update($ids);
104 } elseif (!empty($ida)) {
105  $adherent = new Adherent($db);
106  $adherent->fetch($ida);
107  $check = dol_hash($adherent->email, 'md5');
108  if ($check != $securitykey) {
109  $return = $langs->trans('Bad value for key.');
110  } elseif ($action == 1) {
111  $adherent->array_options['options_datapolicy_consentement'] = 1;
112  $adherent->array_options['options_datapolicy_opposition_traitement'] = 0;
113  $adherent->array_options['options_datapolicy_opposition_prospection'] = 0;
114  //$adherent->array_options['options_datapolicy_date'] = dol_now();
115 
116  $return = getDolGlobalString($acc);
117  } elseif ($action == 2) {
118  $adherent->array_options['options_datapolicy_consentement'] = 0;
119  $adherent->array_options['options_datapolicy_opposition_traitement'] = 1;
120  $adherent->array_options['options_datapolicy_opposition_prospection'] = 1;
121  //$adherent->array_options['options_datapolicy_date'] = dol_now();
122 
123  $return = getDolGlobalString($ref);
124  }
125  $newuser = new User($db);
126  $adherent->update($newuser);
127 }
128 
129 
130 /*
131  * View
132  */
133 
134 top_httphead();
135 
136 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
137 print "\n";
138 print "<html>\n";
139 print "<head>\n";
140 print '<meta name="robots" content="noindex,nofollow">'."\n";
141 print '<meta name="keywords" content="dolibarr">'."\n";
142 print '<meta name="description" content="Dolibarr DATAPOLICIES">'."\n";
143 print "<title>".$langs->trans("DATAPOLICIESReturn")."</title>\n";
144 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$lang.'">'."\n";
145 print '<style type="text/css">';
146 print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
147 print '.CTableRow2 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #FFFFFF; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
148 print '</style>';
149 
150 print "</head>\n";
151 print '<body style="margin: 10% 40%">'."\n";
152 print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
153 print $return."<br>\n";
154 print '</td></tr></table>';
155 print "</body>\n";
156 print "</html>\n";
157 
158 $db->close();
Class to manage members of a foundation.
Class to manage contact/addresses.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Definition: user.class.php:48
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1494
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.