index.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 Page to show the result of updating it Data policiy preferences after an email campaign using sendMailDataPolicyContact()
  21. */
  22. if (!defined('NOLOGIN')) {
  23. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  24. }
  25. if (!defined('NOREQUIREMENU')) {
  26. define('NOREQUIREMENU', '1');
  27. }
  28. // Load Dolibarr environment
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  36. $idc = GETPOST('c', 'int');
  37. $ids = GETPOST('s', 'int');
  38. $ida = GETPOST('a', 'int');
  39. $action = GETPOST('action', 'aZ09'); // 1 or 2
  40. $l = GETPOST('l', 'alpha');
  41. $securitykey = GETPOST('key', 'alpha');
  42. $acc = "DATAPOLICIESACCEPT_".$l;
  43. $ref = "DATAPOLICIESREFUSE_".$l;
  44. $langs->load('datapolicy', 0, 0, $l);
  45. /*
  46. * Actions
  47. */
  48. if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
  49. print 'Missing paramater s, c or a';
  50. return 0;
  51. } elseif (!empty($idc)) {
  52. $contact = new Contact($db);
  53. $contact->fetch($idc);
  54. $check = dol_hash($contact->email, 'md5');
  55. if ($check != $securitykey) {
  56. $return = $langs->trans('Bad value for key.');
  57. } elseif ($action == 1) {
  58. $contact->array_options['options_datapolicy_consentement'] = 1;
  59. $contact->array_options['options_datapolicy_opposition_traitement'] = 0;
  60. $contact->array_options['options_datapolicy_opposition_prospection'] = 0;
  61. $contact->array_options['options_datapolicy_date'] = dol_now();
  62. $return = getDolGlobalString($acc);
  63. } elseif ($action == 2) {
  64. $contact->no_email = 1;
  65. $contact->array_options['options_datapolicy_consentement'] = 0;
  66. $contact->array_options['options_datapolicy_opposition_traitement'] = 1;
  67. $contact->array_options['options_datapolicy_opposition_prospection'] = 1;
  68. $contact->array_options['options_datapolicy_date'] = dol_now();
  69. $return = getDolGlobalString($ref);
  70. }
  71. $contact->update($idc);
  72. } elseif (!empty($ids)) {
  73. $societe = new Societe($db);
  74. $societe->fetch($ids);
  75. $check = dol_hash($societe->email, 'md5');
  76. if ($check != $securitykey) {
  77. $return = $langs->trans('Bad value for key.');
  78. } elseif ($action == 1) {
  79. $societe->array_options['options_datapolicy_consentement'] = 1;
  80. $societe->array_options['options_datapolicy_opposition_traitement'] = 0;
  81. $societe->array_options['options_datapolicy_opposition_prospection'] = 0;
  82. $societe->array_options['options_datapolicy_date'] = dol_now();
  83. $return = getDolGlobalString($acc);
  84. } elseif ($action == 2) {
  85. $societe->array_options['options_datapolicy_consentement'] = 0;
  86. $societe->array_options['options_datapolicy_opposition_traitement'] = 1;
  87. $societe->array_options['options_datapolicy_opposition_prospection'] = 1;
  88. $societe->array_options['options_datapolicy_date'] = dol_now();
  89. $return = getDolGlobalString($ref);
  90. }
  91. $societe->update($ids);
  92. } elseif (!empty($ida)) {
  93. $adherent = new Adherent($db);
  94. $adherent->fetch($ida);
  95. $check = dol_hash($adherent->email, 'md5');
  96. if ($check != $securitykey) {
  97. $return = $langs->trans('Bad value for key.');
  98. } elseif ($action == 1) {
  99. $adherent->array_options['options_datapolicy_consentement'] = 1;
  100. $adherent->array_options['options_datapolicy_opposition_traitement'] = 0;
  101. $adherent->array_options['options_datapolicy_opposition_prospection'] = 0;
  102. //$adherent->array_options['options_datapolicy_date'] = dol_now();
  103. $return = getDolGlobalString($acc);
  104. } elseif ($action == 2) {
  105. $adherent->array_options['options_datapolicy_consentement'] = 0;
  106. $adherent->array_options['options_datapolicy_opposition_traitement'] = 1;
  107. $adherent->array_options['options_datapolicy_opposition_prospection'] = 1;
  108. //$adherent->array_options['options_datapolicy_date'] = dol_now();
  109. $return = getDolGlobalString($ref);
  110. }
  111. $newuser = new User($db);
  112. $adherent->update($newuser);
  113. }
  114. /*
  115. * View
  116. */
  117. top_httphead();
  118. print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
  119. print "\n";
  120. print "<html>\n";
  121. print "<head>\n";
  122. print '<meta name="robots" content="noindex,nofollow">'."\n";
  123. print '<meta name="keywords" content="dolibarr">'."\n";
  124. print '<meta name="description" content="Dolibarr DATAPOLICIES">'."\n";
  125. print "<title>".$langs->trans("DATAPOLICIESReturn")."</title>\n";
  126. print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$lang.'">'."\n";
  127. print '<style type="text/css">';
  128. 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;}';
  129. 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;}';
  130. print '</style>';
  131. print "</head>\n";
  132. print '<body style="margin: 10% 40%">'."\n";
  133. print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
  134. print $return."<br>\n";
  135. print '</td></tr></table>';
  136. print "</body>\n";
  137. print "</html>\n";
  138. $db->close();