adherent_emails.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/adherent.php
  27. * \ingroup member
  28. * \brief Page to setup the module Foundation
  29. */
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array("admin", "members"));
  35. if (!$user->admin) accessforbidden();
  36. $oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
  37. $action = GETPOST('action', 'alpha');
  38. $error = 0;
  39. // Editing global variables not related to a specific theme
  40. $constantes = array(
  41. 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
  42. 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
  43. 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
  44. 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
  45. 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
  46. 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
  47. 'ADHERENT_MAIL_FROM'=>'string',
  48. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
  49. 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
  50. );
  51. /*
  52. * Actions
  53. */
  54. //
  55. if ($action == 'updateall')
  56. {
  57. $db->begin();
  58. $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
  59. $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
  60. if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
  61. {
  62. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  63. $db->rollback();
  64. }
  65. else
  66. {
  67. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  68. $db->commit();
  69. }
  70. }
  71. // Action to update or add a constant
  72. if ($action == 'update' || $action == 'add')
  73. {
  74. $constlineid = GETPOST('rowid', 'int');
  75. $constname = GETPOST('constname', 'alpha');
  76. $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
  77. $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
  78. $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
  79. $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
  80. $res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
  81. if (!$res > 0) $error++;
  82. if (!$error)
  83. {
  84. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  85. }
  86. else
  87. {
  88. setEventMessages($langs->trans("Error"), null, 'errors');
  89. }
  90. }
  91. // Action to enable a submodule of the adherent module
  92. if ($action == 'set')
  93. {
  94. $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
  95. if ($result < 0)
  96. {
  97. print $db->error();
  98. }
  99. }
  100. // Action to disable a submodule of the adherent module
  101. if ($action == 'unset')
  102. {
  103. $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
  104. if ($result < 0)
  105. {
  106. print $db->error();
  107. }
  108. }
  109. /*
  110. * View
  111. */
  112. $form = new Form($db);
  113. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  114. llxHeader('', $langs->trans("MembersSetup"), $help_url);
  115. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  116. print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
  117. $head = member_admin_prepare_head();
  118. dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
  119. // TODO Use global form
  120. //print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  121. //print '<input type="hidden" name="token" value="'.newToken().'">';
  122. //print '<input type="hidden" name="action" value="updateall">';
  123. $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
  124. $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
  125. $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
  126. //$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
  127. form_constantes($constantes, 0, $helptext);
  128. //print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
  129. //print '</form>';
  130. dol_fiche_end();
  131. // End of page
  132. llxFooter();
  133. $db->close();