dolibarr 23.0.3
website.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
7 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
47
48// Load translation files required by the page
49$langs->loadLangs(array("admin", "members"));
50
51$action = GETPOST('action', 'aZ09');
52
53// Hook to be used by external payment modules (ie Payzen, ...)
54$hookmanager = new HookManager($db);
55$hookmanager->initHooks(array('newpayment'));
56
57if (!$user->admin) {
59}
60
61$error = 0;
62
63
64/*
65 * Actions
66 */
67
68if ($action == 'setMEMBER_ENABLE_PUBLIC') {
69 if (GETPOST('value')) {
70 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
71 } else {
72 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
73 }
74}
75
76if ($action == 'update') {
77 $public = GETPOST('MEMBER_ENABLE_PUBLIC');
78 if (GETPOST('MEMBER_NEWFORM_AMOUNT') !== '') {
79 $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
80 } else {
81 $amount = '';
82 }
83 $minamount = GETPOST('MEMBER_MIN_AMOUNT');
84 $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
85 $showtable = GETPOST('MEMBER_SHOW_TABLE');
86 $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
87 $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
88 $forcetype = GETPOSTINT('MEMBER_NEWFORM_FORCETYPE');
89 $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
90
91 $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
92 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
93 $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
94 $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
95 $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", $showtable ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show"
96 if (GETPOSTISSET('MEMBER_HIDE_VOTE_ALLOWED')) {
97 $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", $showvoteallowed ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show"
98 }
99 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
100 if ($forcetype < 0) {
101 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
102 } else {
103 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
104 }
105 if (empty($forcemorphy) || $forcemorphy == '-1') {
106 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
107 } else {
108 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
109 }
110 if (GETPOSTISSET('MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE')) {
111 $res = dolibarr_set_const($db, "MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE", GETPOST('MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE') == 'yes' ? 1 : 0, 'chaine', 0, '', $conf->entity);
112 }
113
114 if (!($res > 0)) {
115 $error++;
116 }
117
118 if (!$error) {
119 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
120 } else {
121 setEventMessages($langs->trans("Error"), null, 'errors');
122 }
123}
124
125
126/*
127 * View
128 */
129
130$form = new Form($db);
131
132$title = $langs->trans("MembersSetup");
133$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
134
135llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-admin_website');
136
137$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
138
139print load_fiche_titre($title, $linkback, 'title_setup');
140
142
143
144
145print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
146print '<input type="hidden" name="action" value="update">';
147print '<input type="hidden" name="token" value="'.newToken().'">';
148
149print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
150
151if ($conf->use_javascript_ajax) {
152 print "\n".'<script type="text/javascript">';
153 print 'jQuery(document).ready(function () {
154 function initemail()
155 {
156 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') {
157 jQuery("#tremail").hide();
158 } else {
159 jQuery("#tremail").show();
160 }
161 }
162 function initfields()
163 {
164 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') {
165 jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
166 }
167 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') {
168 jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
169 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
170 else jQuery("#tremail").show();
171 }
172 }
173 initfields();
174 jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
175 jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
176 })';
177 print '</script>'."\n";
178}
179
180
181print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
182
183$param = '';
184
185$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
186if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
187 // Button off, click to enable
188 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
189 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
190 $enabledisablehtml .= '</a>';
191} else {
192 // Button on, click to disable
193 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
194 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
195 $enabledisablehtml .= '</a>';
196}
197print $enabledisablehtml;
198print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(!getDolGlobalString('MEMBER_ENABLE_PUBLIC') ? 0 : 1).'">';
199
200print '<br><br>';
201
202
203if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
204 print '<br>';
205 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
206 if (isModEnabled('multicompany')) {
207 $entity_qr = '?entity='.((int) $conf->entity);
208 } else {
209 $entity_qr = '';
210 }
211
212 // Define $urlwithroot
213 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
214 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
215 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
216
217 print '<div class="urllink">';
218 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
219 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
220 print '</div>';
221 print ajax_autoselect('publicurlmember');
222
223 print '<br><br>';
224
225 print '<div class="div-table-responsive-no-min">';
226 print '<table class="noborder centpercent">';
227
228 print '<tr class="liste_titre">';
229 print '<td>'.$langs->trans("Parameter").'</td>';
230 print '<td></td>';
231 print "</tr>\n";
232
233 // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
234 $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
235 print '<tr class="oddeven" id="tredit"><td>';
236 print $langs->trans("MembersShowMembershipTypesTable");
237 print '</td><td>';
238 print $form->selectyesno("MEMBER_SHOW_TABLE", (int) !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
239 print "</td></tr>\n";
240
241 // Show "vote allowed" setting for membership types
242 if (!$skiptable) {
243 $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED');
244 print '<tr class="oddeven" id="tredit"><td>';
245 print $langs->trans("MembersShowVotesAllowed");
246 print '</td><td>';
247 print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", (int) !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
248 print "</td></tr>\n";
249 }
250
251 // Force Type
252 $adht = new AdherentType($db);
253 print '<tr class="oddeven drag" id="trforcetype"><td>';
254 print $langs->trans("ForceMemberType");
255 print '</td><td>';
256 $listofval = array();
257 $listofval += $adht->liste_array(1);
258 $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1);
259 print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200');
260 print "</td></tr>\n";
261
262 // Force nature of member (mor/phy)
263 $morphys = [
264 "phy" => $langs->trans("Physical"),
265 "mor" => $langs->trans("Moral"),
266 ];
267 print '<tr class="oddeven drag" id="trforcenature"><td>';
268 print $langs->trans("ForceMemberNature");
269 print '</td><td>';
270
271 $forcenature = getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY'); // 'phy' or 'mor'
272 print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200');
273 print "</td></tr>\n";
274
275 // Amount
276 print '<tr class="oddeven" id="tramount"><td>';
277 print $langs->trans("DefaultAmount");
278 print '</td><td>';
279 print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.getDolGlobalString('MEMBER_NEWFORM_AMOUNT').'">';
280 print ' <span class="opacitymedium">'.$langs->getCurrencySymbol($mysoc->currency_code).'</span>';
281 print "</td></tr>\n";
282
283 // Min amount
284 print '<tr class="oddeven" id="tredit"><td>';
285 print $langs->trans("MinimumAmount");
286 print '</td><td>';
287 print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.getDolGlobalString('MEMBER_MIN_AMOUNT').'">';
288 print ' <span class="opacitymedium">'.$langs->getCurrencySymbol($mysoc->currency_code).'</span>';
289 print "</td></tr>\n";
290
291 // SHow counter of validated members publicly
292 print '<tr class="oddeven" id="tredit"><td>';
293 print $langs->trans("MemberCountersArePublic");
294 print '</td><td>';
295 print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1, false, 0, 1);
296 print "</td></tr>\n";
297
298 // Jump to an online payment page
299 print '<tr class="oddeven" id="trpayment"><td>';
300 print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
301 print '</td><td>';
302
303 // Initialize $validpaymentmethod
304 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
305 $validpaymentmethod = getValidOnlinePaymentMethods('', 1);
306
307 // Define $listofval using the $validpaymentmethod
308 $listofval = array();
309 $listofval['-1'] = array('label' => $langs->trans('No'));
310 $listofval['all'] = array('label' => $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')', 'data-html' => $langs->trans('Yes').' &nbsp; <span class="opacitymedium">('.$langs->trans("VisitorCanChooseItsPaymentMode").')</span>');
311 foreach ($validpaymentmethod as $key => $val) {
312 if (is_array($val)) {
313 $listofval[$key] = $val;
314 } else {
315 $listofval[$key] = array('label' => $key, 'status' => 'valid');
316 }
317 }
318
319 print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0);
320 print "</td></tr>\n";
321
322 // Search a member after member creation form
323 print '<tr class="oddeven" id="trpayment"><td>';
324 print $form->textwithpicto($langs->trans("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE"), $langs->trans("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATEDesc"));
325 print '</td><td>';
326 print $form->selectyesno("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE", getDolGlobalInt("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE")); // Reverse the logic "hide -> show" for retrocompatibility
327 print "</td></tr>\n";
328
329 print '</table>';
330 print '</div>';
331
332 print '<div class="center">';
333 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
334 print '</div>';
335}
336
337
338print dol_get_fiche_end();
339
340print '</form>';
341
342// End of page
343llxFooter();
344$db->close();
global $dolibarr_main_url_root
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage members type.
Class to manage generation of HTML components Only common components must be here.
Class to manage hooks.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.