dolibarr  13.0.2
index.php
1 <?php
2 
3 /* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 if (!defined('NOLOGIN'))
26  define("NOLOGIN", 1); // This means this output page does not require to be logged.
27 if (!defined('NOCSRFCHECK'))
28  define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
29 if (!defined('NOREQUIREMENU'))
30  define('NOREQUIREMENU', '1');
31 
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 
39 $idc = GETPOST('c', 'int');
40 $ids = GETPOST('s', 'int');
41 $ida = GETPOST('a', 'int');
42 $action = GETPOST('action', 'aZ09');
43 $lang = GETPOST('l', 'alpha');
44 $code = GETPOST('key', 'alpha');
45 
46 $acc = "DATAPOLICIESACCEPT_".$lang;
47 $ref = "DATAPOLICIESREFUSE_".$lang;
48 $langs->load('datapolicy@datapolicy', 0, 0, $lang);
49 
50 if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
51  return 0;
52 } elseif (!empty($idc)) {
53  $contact = new Contact($db);
54  $contact->fetch($idc);
55  $check = md5($contact->email);
56  if ($check != $code) {
57  $return = $langs->trans('ErrorEmailDATAPOLICIES');
58  } elseif ($action == 1) {
59  $contact->array_options['options_datapolicy_consentement'] = 1;
60  $contact->array_options['options_datapolicy_opposition_traitement'] = 0;
61  $contact->array_options['options_datapolicy_opposition_prospection'] = 0;
62  $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
63 
64  $return = $conf->global->$acc;
65  } elseif ($action == 2) {
66  $contact->no_email = 1;
67  $contact->array_options['options_datapolicy_consentement'] = 0;
68  $contact->array_options['options_datapolicy_opposition_traitement'] = 1;
69  $contact->array_options['options_datapolicy_opposition_prospection'] = 1;
70  $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
71 
72  $return = $conf->global->$ref;
73  }
74  $contact->update($idc);
75 } elseif (!empty($ids)) {
76  $societe = new Societe($db);
77  $societe->fetch($ids);
78  $check = md5($societe->email);
79  if ($check != $code) {
80  $return = $langs->trans('ErrorEmailDATAPOLICIES');
81  } elseif ($action == 1) {
82  $societe->array_options['options_datapolicy_consentement'] = 1;
83  $societe->array_options['options_datapolicy_opposition_traitement'] = 0;
84  $societe->array_options['options_datapolicy_opposition_prospection'] = 0;
85  $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
86  $return = $conf->global->$acc;
87  } elseif ($action == 2) {
88  $societe->array_options['options_datapolicy_consentement'] = 0;
89  $societe->array_options['options_datapolicy_opposition_traitement'] = 1;
90  $societe->array_options['options_datapolicy_opposition_prospection'] = 1;
91  $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
92 
93  $return = $conf->global->$ref;
94  }
95  $societe->update($ids);
96 } elseif (!empty($ida)) {
97  $adherent = new Adherent($db);
98  $adherent->fetch($ida);
99  $check = md5($adherent->email);
100  if ($check != $code) {
101  $return = $langs->trans('ErrorEmailDATAPOLICIES');
102  } elseif ($action == 1) {
103  $adherent->array_options['options_datapolicy_consentement'] = 1;
104  $adherent->array_options['options_datapolicy_opposition_traitement'] = 0;
105  $adherent->array_options['options_datapolicy_opposition_prospection'] = 0;
106  //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
107  $return = $conf->global->$acc;
108  } elseif ($action == 2) {
109  $adherent->array_options['options_datapolicy_consentement'] = 0;
110  $adherent->array_options['options_datapolicy_opposition_traitement'] = 1;
111  $adherent->array_options['options_datapolicy_opposition_prospection'] = 1;
112  //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
113 
114  $return = $conf->global->$ref;
115  }
116  $newuser = new User($db);
117  $adherent->update($newuser);
118 }
119 
120 header("Content-type: text/html; charset=".$conf->file->character_set_client);
121 
122 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
123 print "\n";
124 print "<html>\n";
125 print "<head>\n";
126 print '<meta name="robots" content="noindex,nofollow">'."\n";
127 print '<meta name="keywords" content="dolibarr">'."\n";
128 print '<meta name="description" content="Dolibarr DATAPOLICIES">'."\n";
129 print "<title>".$langs->trans("DATAPOLICIESReturn")."</title>\n";
130 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$lang.'">'."\n";
131 print '<style type="text/css">';
132 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;}';
133 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;}';
134 print '</style>';
135 
136 print "</head>\n";
137 print '<body style="margin: 10% 40%">'."\n";
138 print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
139 print $return."<br>\n";
140 print '</td></tr></table>';
141 print "</body>\n";
142 print "</html>\n";
143 
144 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage contact/addresses.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage members of a foundation.
print
Draft customers invoices.
Definition: index.php:89