setupmail.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  4. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/datapolicy/admin/setupmail.php
  21. * \ingroup datapolicy
  22. * \brief Datapolicy setup page to define email content end send email for end user agreement.
  23. */
  24. // Load Dolibarr environment
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/datapolicy/lib/datapolicy.lib.php';
  30. // Translations
  31. $langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy'));
  32. // Parameters
  33. $action = GETPOST('action', 'aZ09');
  34. $backtopage = GETPOST('backtopage', 'alpha');
  35. if (GETPOST('l')) {
  36. $l = GETPOST('l');
  37. } else {
  38. $l = $langs->defaultlang;
  39. }
  40. // Security
  41. if (!isModEnabled("datapolicy")) {
  42. accessforbidden();
  43. }
  44. if (!$user->admin) {
  45. accessforbidden();
  46. }
  47. /*
  48. * Actions
  49. */
  50. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  51. if ($action == 'setvalue' && $user->admin) {
  52. $db->begin();
  53. $sub = "DATAPOLICYSUBJECT_".$l;
  54. $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
  55. $cont = "DATAPOLICYCONTENT_".$l;
  56. $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
  57. $cont = "TXTLINKDATAPOLICYACCEPT_".$l;
  58. $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
  59. $cont = "TXTLINKDATAPOLICYREFUSE_".$l;
  60. $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
  61. $sub = "DATAPOLICYACCEPT_".$l;
  62. $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
  63. $sub = "DATAPOLICYREFUSE_".$l;
  64. $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
  65. if (!($result > 0)) {
  66. $error++;
  67. }
  68. if (!$error) {
  69. $db->commit();
  70. setEventMessage($langs->trans("SetupSaved"));
  71. } else {
  72. $db->rollback();
  73. dol_print_error($db);
  74. }
  75. }
  76. /*
  77. * View
  78. */
  79. $formadmin = new FormAdmin($db);
  80. $page_name = "datapolicySetup";
  81. llxHeader('', $langs->trans($page_name));
  82. // Subheader
  83. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
  84. print load_fiche_titre($langs->trans($page_name), $linkback, 'generic');
  85. // Configuration header
  86. $head = datapolicyAdminPrepareHead();
  87. print dol_get_fiche_head($head, 'emailing', '', -1, '');
  88. print "<script type='text/javascript'>
  89. $(document).ready(function(){
  90. $('#default_lang').change(function(){
  91. lang=$('#default_lang').val();
  92. window.location.replace('" . $_SERVER['PHP_SELF']."?l='+lang);
  93. });
  94. });
  95. </script>";
  96. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?l='.$l.'">';
  97. print '<input type="hidden" name="token" value="'.newToken().'">';
  98. print '<input type="hidden" name="action" value="setvalue">';
  99. print '<table>';
  100. if (getDolGlobalInt('MAIN_MULTILANGS')) {
  101. print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
  102. print img_picto('', 'language', 'class="pictofixedwidth"');
  103. print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
  104. print '</tr>';
  105. }
  106. $subject = 'DATAPOLICYSUBJECT_'.$l;
  107. $linka = 'TXTLINKDATAPOLICYACCEPT_'.$l;
  108. $linkr = 'TXTLINKDATAPOLICYREFUSE_'.$l;
  109. $content = 'DATAPOLICYCONTENT_'.$l;
  110. $acc = 'DATAPOLICYACCEPT_'.$l;
  111. $ref = 'DATAPOLICYREFUSE_'.$l;
  112. print '<tr class"oddeven"><td class="fieldrequired">';
  113. print $langs->trans('DATAPOLICYSUBJECTMAIL').'</td><td>';
  114. print '<input type="text" name="'.$subject.'" value="'.$conf->global->$subject.'" />';
  115. print '</td><tr>';
  116. print '<tr class"oddeven"><td class="fieldrequired">';
  117. print $langs->trans('DATAPOLICYCONTENTMAIL').'</td><td>';
  118. print '<span class="opacitymedium">';
  119. print $langs->trans('DATAPOLICYSUBSITUTION');
  120. print '__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__';
  121. print '</span>';
  122. $doleditor = new DolEditor($content, $conf->global->$content, '', 250, 'Full', '', false, true, 1, 200, 70);
  123. $doleditor->Create();
  124. print '</td><tr>';
  125. print '<tr class"oddeven"><td class="fieldrequired">';
  126. print $langs->trans('TXTLINKDATAPOLICYACCEPT').'</td><td>';
  127. print '<input type="text" name="'.$linka.'" value="'.$conf->global->$linka.'" />';
  128. print '</td><tr>';
  129. print '<tr class"oddeven"><td class="fieldrequired">';
  130. print $langs->trans('TXTLINKDATAPOLICYREFUSE').'</td><td>';
  131. print '<input type="text" name="'.$linkr.'" value="'.$conf->global->$linkr.'" />';
  132. print '</td><tr>';
  133. print '<tr class"oddeven"><td class="fieldrequired">';
  134. print $langs->trans('DATAPOLICYACCEPT').'</td><td>';
  135. $doleditor = new DolEditor($acc, $conf->global->$acc, '', 250, 'Full', '', false, true, 1, 200, 70);
  136. $doleditor->Create();
  137. print '</td><tr>';
  138. print '<tr class"oddeven"><td class="fieldrequired">';
  139. print $langs->trans('DATAPOLICYREFUSE').'</td><td>';
  140. print $langs->trans('');
  141. $doleditor = new DolEditor($ref, $conf->global->$ref, '', 250, 'Full', '', false, true, 1, 200, 70);
  142. $doleditor->Create();
  143. print '</td><tr>';
  144. print '</table>';
  145. print '<br><center><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></center>';
  146. print '</form>';
  147. print dol_get_fiche_end();
  148. print '<br><br>';
  149. print $langs->trans('SendAgreementText');
  150. print '<a class="button" href="'.DOL_URL_ROOT.'/datapolicy/admin/mailing.php">'.$langs->trans('SendAgreementRequestByEmail').'</a>';
  151. llxFooter();
  152. $db->close();