index.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. /**
  18. * \file htdocs/datapolicy/admin/setup.php
  19. * \ingroup datapolicy
  20. * \brief datapolicy setup page.
  21. */
  22. if (!defined('NOLOGIN')) {
  23. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  24. }
  25. if (!defined('NOCSRFCHECK')) {
  26. define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
  27. }
  28. if (!defined('NOREQUIREMENU')) {
  29. define('NOREQUIREMENU', '1');
  30. }
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php';
  37. $idc = GETPOST('c', 'int');
  38. $ids = GETPOST('s', 'int');
  39. $ida = GETPOST('a', 'int');
  40. $action = GETPOST('action', 'aZ09');
  41. $lang = GETPOST('l', 'alpha');
  42. $code = GETPOST('key', 'alpha');
  43. $acc = "DATAPOLICIESACCEPT_".$lang;
  44. $ref = "DATAPOLICIESREFUSE_".$lang;
  45. $langs->load('datapolicy@datapolicy', 0, 0, $lang);
  46. if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
  47. return 0;
  48. } elseif (!empty($idc)) {
  49. $contact = new Contact($db);
  50. $contact->fetch($idc);
  51. $check = md5($contact->email);
  52. if ($check != $code) {
  53. $return = $langs->trans('ErrorEmailDATAPOLICIES');
  54. } elseif ($action == 1) {
  55. $contact->array_options['options_datapolicy_consentement'] = 1;
  56. $contact->array_options['options_datapolicy_opposition_traitement'] = 0;
  57. $contact->array_options['options_datapolicy_opposition_prospection'] = 0;
  58. $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  59. $return = $conf->global->$acc;
  60. } elseif ($action == 2) {
  61. $contact->no_email = 1;
  62. $contact->array_options['options_datapolicy_consentement'] = 0;
  63. $contact->array_options['options_datapolicy_opposition_traitement'] = 1;
  64. $contact->array_options['options_datapolicy_opposition_prospection'] = 1;
  65. $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  66. $return = $conf->global->$ref;
  67. }
  68. $contact->update($idc);
  69. } elseif (!empty($ids)) {
  70. $societe = new Societe($db);
  71. $societe->fetch($ids);
  72. $check = md5($societe->email);
  73. if ($check != $code) {
  74. $return = $langs->trans('ErrorEmailDATAPOLICIES');
  75. } elseif ($action == 1) {
  76. $societe->array_options['options_datapolicy_consentement'] = 1;
  77. $societe->array_options['options_datapolicy_opposition_traitement'] = 0;
  78. $societe->array_options['options_datapolicy_opposition_prospection'] = 0;
  79. $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  80. $return = $conf->global->$acc;
  81. } elseif ($action == 2) {
  82. $societe->array_options['options_datapolicy_consentement'] = 0;
  83. $societe->array_options['options_datapolicy_opposition_traitement'] = 1;
  84. $societe->array_options['options_datapolicy_opposition_prospection'] = 1;
  85. $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  86. $return = $conf->global->$ref;
  87. }
  88. $societe->update($ids);
  89. } elseif (!empty($ida)) {
  90. $adherent = new Adherent($db);
  91. $adherent->fetch($ida);
  92. $check = md5($adherent->email);
  93. if ($check != $code) {
  94. $return = $langs->trans('ErrorEmailDATAPOLICIES');
  95. } elseif ($action == 1) {
  96. $adherent->array_options['options_datapolicy_consentement'] = 1;
  97. $adherent->array_options['options_datapolicy_opposition_traitement'] = 0;
  98. $adherent->array_options['options_datapolicy_opposition_prospection'] = 0;
  99. //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  100. $return = $conf->global->$acc;
  101. } elseif ($action == 2) {
  102. $adherent->array_options['options_datapolicy_consentement'] = 0;
  103. $adherent->array_options['options_datapolicy_opposition_traitement'] = 1;
  104. $adherent->array_options['options_datapolicy_opposition_prospection'] = 1;
  105. //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time());
  106. $return = $conf->global->$ref;
  107. }
  108. $newuser = new User($db);
  109. $adherent->update($newuser);
  110. }
  111. header("Content-type: text/html; charset=".$conf->file->character_set_client);
  112. print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
  113. print "\n";
  114. print "<html>\n";
  115. print "<head>\n";
  116. print '<meta name="robots" content="noindex,nofollow">'."\n";
  117. print '<meta name="keywords" content="dolibarr">'."\n";
  118. print '<meta name="description" content="Dolibarr DATAPOLICIES">'."\n";
  119. print "<title>".$langs->trans("DATAPOLICIESReturn")."</title>\n";
  120. print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$lang.'">'."\n";
  121. print '<style type="text/css">';
  122. 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;}';
  123. 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;}';
  124. print '</style>';
  125. print "</head>\n";
  126. print '<body style="margin: 10% 40%">'."\n";
  127. print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
  128. print $return."<br>\n";
  129. print '</td></tr></table>';
  130. print "</body>\n";
  131. print "</html>\n";
  132. $db->close();