member_emails.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
  43. $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
  44. $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
  45. //$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
  46. // Editing global variables not related to a specific theme
  47. $constantes = array(
  48. 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
  49. 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>array('type'=>'emailtemplate:member'),
  50. 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>array('type'=>'emailtemplate:member'),
  51. 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>array('type'=>'emailtemplate:member'),
  52. 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>array('type'=>'emailtemplate:member'),
  53. 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>array('type'=>'emailtemplate:member'),
  54. 'ADHERENT_EMAIL_TEMPLATE_EXCLUSION' =>array('type'=>'emailtemplate:member'),
  55. 'ADHERENT_MAIL_FROM' =>array('type'=>'string'),
  56. 'ADHERENT_CC_MAIL_FROM' =>array('type'=>'string'),
  57. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT' =>array('type'=>'string'),
  58. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL' =>array('type'=>'html', 'tooltip'=>$helptext)
  59. );
  60. /*
  61. * Actions
  62. */
  63. //
  64. if ($action == 'updateall') {
  65. $db->begin();
  66. $res = 0;
  67. foreach ($constantes as $constname => $value) {
  68. $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
  69. $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
  70. $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
  71. $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
  72. $constvalue = preg_replace('/:member$/', '', $constvalue);
  73. $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
  74. if ($res <= 0) {
  75. $error++;
  76. $action = 'list';
  77. }
  78. }
  79. if ($error > 0) {
  80. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  81. $db->rollback();
  82. } else {
  83. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  84. $db->commit();
  85. }
  86. }
  87. // Action to update or add a constant
  88. if ($action == 'update' || $action == 'add') {
  89. $constlineid = GETPOST('rowid', 'int');
  90. $constname = GETPOST('constname', 'alpha');
  91. $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
  92. $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
  93. $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
  94. $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
  95. $constvalue = preg_replace('/:member$/', '', $constvalue);
  96. $res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
  97. if (!($res > 0)) {
  98. $error++;
  99. }
  100. if (!$error) {
  101. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  102. } else {
  103. setEventMessages($langs->trans("Error"), null, 'errors');
  104. }
  105. }
  106. /*
  107. * View
  108. */
  109. $form = new Form($db);
  110. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
  111. llxHeader('', $langs->trans("MembersSetup"), $help_url);
  112. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  113. print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
  114. $head = member_admin_prepare_head();
  115. print dol_get_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
  116. // TODO Use global form
  117. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  118. print '<input type="hidden" name="token" value="'.newToken().'">';
  119. print '<input type="hidden" name="action" value="updateall">';
  120. form_constantes($constantes, 3, '');
  121. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
  122. print '</form>';
  123. print dol_get_fiche_end();
  124. // End of page
  125. llxFooter();
  126. $db->close();