member_emails.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  6. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  7. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
  10. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/adherents/admin/member_emails.php
  27. * \ingroup member
  28. * \brief Page to setup the module Foundation
  29. */
  30. // Load Dolibarr environment
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("admin", "members"));
  36. if (!$user->admin) {
  37. accessforbidden();
  38. }
  39. $oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
  40. $action = GETPOST('action', 'aZ09');
  41. $error = 0;
  42. // Editing global variables not related to a specific theme
  43. $constantes = array(
  44. 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
  45. 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
  46. 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', // until Dolibarr 7 it was ADHERENT_AUTOREGISTER_MAIL
  47. 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', // until Dolibarr 7 it was ADHERENT_MAIL_VALID
  48. 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', // until Dolibarr 7 it was ADHERENT_MAIL_COTIS
  49. 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', // until Dolibarr 7 it was ADHERENT_MAIL_RESIL
  50. 'ADHERENT_EMAIL_TEMPLATE_EXCLUSION' =>'emailtemplate:member',
  51. 'ADHERENT_MAIL_FROM' =>'string',
  52. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT' =>'string',
  53. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL' =>'html',
  54. );
  55. /*
  56. * Actions
  57. */
  58. //
  59. if ($action == 'updateall') {
  60. $db->begin();
  61. $res = 0;
  62. foreach ($constantes as $constname => $value) {
  63. $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
  64. $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
  65. $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
  66. $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
  67. $constvalue = preg_replace('/:member$/', '', $constvalue);
  68. $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
  69. if ($res <= 0) {
  70. $error++;
  71. $action = 'list';
  72. }
  73. }
  74. if ($error > 0) {
  75. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  76. $db->rollback();
  77. } else {
  78. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  79. $db->commit();
  80. }
  81. }
  82. // Action to update or add a constant
  83. if ($action == 'update' || $action == 'add') {
  84. $constlineid = GETPOST('rowid', 'int');
  85. $constname = GETPOST('constname', 'alpha');
  86. $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
  87. $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
  88. $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
  89. $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
  90. $constvalue = preg_replace('/:member$/', '', $constvalue);
  91. $res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
  92. if (!($res > 0)) {
  93. $error++;
  94. }
  95. if (!$error) {
  96. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  97. } else {
  98. setEventMessages($langs->trans("Error"), null, 'errors');
  99. }
  100. }
  101. /*
  102. * View
  103. */
  104. $form = new Form($db);
  105. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
  106. llxHeader('', $langs->trans("MembersSetup"), $help_url);
  107. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  108. print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
  109. $head = member_admin_prepare_head();
  110. print dol_get_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
  111. // TODO Use global form
  112. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  113. print '<input type="hidden" name="token" value="'.newToken().'">';
  114. print '<input type="hidden" name="action" value="updateall">';
  115. $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
  116. $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
  117. $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
  118. //$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
  119. form_constantes($constantes, 3, $helptext);
  120. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
  121. print '</form>';
  122. print dol_get_fiche_end();
  123. // End of page
  124. llxFooter();
  125. $db->close();