dolibarr  16.0.5
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 }
28 if (!defined('NOCSRFCHECK')) {
29  define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
30 }
31 if (!defined('NOREQUIREMENU')) {
32  define('NOREQUIREMENU', '1');
33 }
34 
35 require '../../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php';
41 
42 $idc = GETPOST('c', 'int');
43 $ids = GETPOST('s', 'int');
44 $ida = GETPOST('a', 'int');
45 $action = GETPOST('action', 'aZ09');
46 $lang = GETPOST('l', 'alpha');
47 $code = GETPOST('key', 'alpha');
48 
49 $acc = "DATAPOLICIESACCEPT_".$lang;
50 $ref = "DATAPOLICIESREFUSE_".$lang;
51 $langs->load('datapolicy@datapolicy', 0, 0, $lang);
52 
53 if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
54  return 0;
55 } elseif (!empty($idc)) {
56  $contact = new Contact($db);
57  $contact->fetch($idc);
58  $check = md5($contact->email);
59  if ($check != $code) {
60  $return = $langs->trans('ErrorEmailDATAPOLICIES');
61  } elseif ($action == 1) {
62  $contact->array_options['options_datapolicy_consentement'] = 1;
63  $contact->array_options['options_datapolicy_opposition_traitement'] = 0;
64  $contact->array_options['options_datapolicy_opposition_prospection'] = 0;
65  $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
66 
67  $return = $conf->global->$acc;
68  } elseif ($action == 2) {
69  $contact->no_email = 1;
70  $contact->array_options['options_datapolicy_consentement'] = 0;
71  $contact->array_options['options_datapolicy_opposition_traitement'] = 1;
72  $contact->array_options['options_datapolicy_opposition_prospection'] = 1;
73  $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
74 
75  $return = $conf->global->$ref;
76  }
77  $contact->update($idc);
78 } elseif (!empty($ids)) {
79  $societe = new Societe($db);
80  $societe->fetch($ids);
81  $check = md5($societe->email);
82  if ($check != $code) {
83  $return = $langs->trans('ErrorEmailDATAPOLICIES');
84  } elseif ($action == 1) {
85  $societe->array_options['options_datapolicy_consentement'] = 1;
86  $societe->array_options['options_datapolicy_opposition_traitement'] = 0;
87  $societe->array_options['options_datapolicy_opposition_prospection'] = 0;
88  $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
89  $return = $conf->global->$acc;
90  } elseif ($action == 2) {
91  $societe->array_options['options_datapolicy_consentement'] = 0;
92  $societe->array_options['options_datapolicy_opposition_traitement'] = 1;
93  $societe->array_options['options_datapolicy_opposition_prospection'] = 1;
94  $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
95 
96  $return = $conf->global->$ref;
97  }
98  $societe->update($ids);
99 } elseif (!empty($ida)) {
100  $adherent = new Adherent($db);
101  $adherent->fetch($ida);
102  $check = md5($adherent->email);
103  if ($check != $code) {
104  $return = $langs->trans('ErrorEmailDATAPOLICIES');
105  } elseif ($action == 1) {
106  $adherent->array_options['options_datapolicy_consentement'] = 1;
107  $adherent->array_options['options_datapolicy_opposition_traitement'] = 0;
108  $adherent->array_options['options_datapolicy_opposition_prospection'] = 0;
109  //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
110  $return = $conf->global->$acc;
111  } elseif ($action == 2) {
112  $adherent->array_options['options_datapolicy_consentement'] = 0;
113  $adherent->array_options['options_datapolicy_opposition_traitement'] = 1;
114  $adherent->array_options['options_datapolicy_opposition_prospection'] = 1;
115  //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
116 
117  $return = $conf->global->$ref;
118  }
119  $newuser = new User($db);
120  $adherent->update($newuser);
121 }
122 
123 header("Content-type: text/html; charset=".$conf->file->character_set_client);
124 
125 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
126 print "\n";
127 print "<html>\n";
128 print "<head>\n";
129 print '<meta name="robots" content="noindex,nofollow">'."\n";
130 print '<meta name="keywords" content="dolibarr">'."\n";
131 print '<meta name="description" content="Dolibarr DATAPOLICIES">'."\n";
132 print "<title>".$langs->trans("DATAPOLICIESReturn")."</title>\n";
133 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$lang.'">'."\n";
134 print '<style type="text/css">';
135 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;}';
136 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;}';
137 print '</style>';
138 
139 print "</head>\n";
140 print '<body style="margin: 10% 40%">'."\n";
141 print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
142 print $return."<br>\n";
143 print '</td></tr></table>';
144 print "</body>\n";
145 print "</html>\n";
146 
147 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
User
Class to manage Dolibarr users.
Definition: user.class.php:44