dolibarr 21.0.0-alpha
member_emails.php
Go to the documentation of this file.
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 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
37
38// Load translation files required by the page
39$langs->loadLangs(array("admin", "members"));
40
41if (!$user->admin) {
43}
44
45
46$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
47
48$action = GETPOST('action', 'aZ09');
49
50$error = 0;
51
52$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
53$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
54$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
55//$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
56
57// Editing global variables not related to a specific theme
58$constantes = array(
59 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
60 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>array('type'=>'emailtemplate:member','label'=>''),
61 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>array('type'=>'emailtemplate:member','label'=>''),
62 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>array('type'=>'emailtemplate:member','label'=>''),
63 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>array('type'=>'emailtemplate:member','label'=>''),
64 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>array('type'=>'emailtemplate:member','label'=>''),
65 'ADHERENT_EMAIL_TEMPLATE_EXCLUSION' =>array('type'=>'emailtemplate:member','label'=>''),
66 'ADHERENT_MAIL_FROM' =>array('type'=>'string','label'=>''),
67 'ADHERENT_CC_MAIL_FROM' =>array('type'=>'string','label'=>''),
68 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT' =>array('type'=>'string','label'=>''),
69 'ADHERENT_AUTOREGISTER_NOTIF_MAIL' =>array('type'=>'html', 'tooltip'=>$helptext,'label'=>'')
70);
71
72
73
74/*
75 * Actions
76 */
77
78//
79if ($action == 'updateall') {
80 $db->begin();
81
82 $res = 0;
83 foreach ($constantes as $constname => $value) {
84 $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
85 $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
86 $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
87
88 $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
89 $constvalue = preg_replace('/:member$/', '', $constvalue);
90
91 $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
92 if ($res <= 0) {
93 $error++;
94 $action = 'list';
95 }
96 }
97
98 if ($error > 0) {
99 setEventMessages('ErrorFailedToSaveDate', null, 'errors');
100 $db->rollback();
101 } else {
102 setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
103 $db->commit();
104 }
105}
106
107// Action to update or add a constant
108if ($action == 'update' || $action == 'add') {
109 $constlineid = GETPOSTINT('rowid');
110 $constname = GETPOST('constname', 'alpha');
111
112 $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
113 $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
114 $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
115
116 $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
117 $constvalue = preg_replace('/:member$/', '', $constvalue);
118
119 $res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
120
121 if (!($res > 0)) {
122 $error++;
123 }
124
125 if (!$error) {
126 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
127 } else {
128 setEventMessages($langs->trans("Error"), null, 'errors');
129 }
130}
131
132
133/*
134 * View
135 */
136
137$form = new Form($db);
138
139$title = $langs->trans("MembersSetup");
140$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
141
142llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-admin_emails');
143
144
145$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
146print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
147
148
150
151print dol_get_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
152
153// TODO Use global form
154print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
155print '<input type="hidden" name="token" value="'.newToken().'">';
156print '<input type="hidden" name="action" value="updateall">';
157
158print '<br>';
159
160form_constantes($constantes, 3, '');
161
162print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
163print '</form>';
164
165print dol_get_fiche_end();
166
167// End of page
168llxFooter();
169$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
member_admin_prepare_head()
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.