dolibarr 24.0.0-beta
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-2026 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->initHooks(array('newpayment'));
55
56if (!$user->admin) {
58}
59
60$error = 0;
61
62
63/*
64 * Actions
65 */
66
67if ($action == 'setMEMBER_ENABLE_PUBLIC') {
68 if (GETPOST('value')) {
69 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
70 } else {
71 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
72 }
73}
74
75if ($action == 'update') {
76 $public = GETPOST('MEMBER_ENABLE_PUBLIC');
77 $amount = '';
78
79 $minamount = GETPOST('MEMBER_MIN_AMOUNT');
80 $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
81 $showtable = GETPOST('MEMBER_SHOW_TABLE');
82 $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
83 $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
84 $forcetype = GETPOSTINT('MEMBER_NEWFORM_FORCETYPE');
85 $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
86
87 $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
88 $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
89 $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
90 $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", $showtable ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show"
91 if (GETPOSTISSET('MEMBER_HIDE_VOTE_ALLOWED')) {
92 $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", $showvoteallowed ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show"
93 }
94 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
95 if ($forcetype < 0) {
96 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
97 } else {
98 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
99 }
100 if (empty($forcemorphy) || $forcemorphy == '-1') {
101 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
102 } else {
103 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
104 }
105 if (GETPOSTISSET('MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE')) {
106 $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);
107 }
108
109 if (!($res > 0)) {
110 $error++;
111 }
112
113 if (!$error) {
114 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
115 } else {
116 setEventMessages($langs->trans("Error"), null, 'errors');
117 }
118}
119
120
121/*
122 * View
123 */
124
125$form = new Form($db);
126
127$title = $langs->trans("MembersSetup");
128$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
129
130llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-admin_website');
131
132$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>';
133
134print load_fiche_titre($title, $linkback, 'title_setup');
135
137
138
139
140print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
141print '<input type="hidden" name="action" value="update">';
142print '<input type="hidden" name="token" value="'.newToken().'">';
143
144print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
145
146if ($conf->use_javascript_ajax) {
147 print "\n".'<script type="text/javascript">';
148 print 'jQuery(document).ready(function () {
149 function initemail()
150 {
151 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') {
152 jQuery("#tremail").hide();
153 } else {
154 jQuery("#tremail").show();
155 }
156 }
157 function initfields()
158 {
159 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') {
160 jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
161 }
162 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') {
163 jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
164 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
165 else jQuery("#tremail").show();
166 }
167 }
168 initfields();
169 jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
170 jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
171 })';
172 print '</script>'."\n";
173}
174
175
176print '<div class="info">'.$langs->trans("BlankSubscriptionFormDesc").'</div><br>';
177
178$param = '';
179
180$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
181if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
182 // Button off, click to enable
183 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
184 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
185 $enabledisablehtml .= '</a>';
186} else {
187 // Button on, click to disable
188 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
189 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
190 $enabledisablehtml .= '</a>';
191}
192
193print '<div class="neutral">';
194print $enabledisablehtml;
195print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(!getDolGlobalString('MEMBER_ENABLE_PUBLIC') ? 0 : 1).'">';
196print '</div>';
197
198print '<br>';
199
200
201if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
202 print '<br>';
203 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
204 if (isModEnabled('multicompany')) {
205 $entity_qr = '?entity='.((int) $conf->entity);
206 } else {
207 $entity_qr = '';
208 }
209
210 // Define $urlwithroot
211 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
212 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
213 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
214
215 print '<div class="urllink">';
216 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
217 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
218 print '</div>';
219 print ajax_autoselect('publicurlmember');
220
221 print '<br><br>';
222
223 print '<div class="div-table-responsive-no-min">';
224 print '<table class="noborder centpercent">';
225
226 print '<tr class="liste_titre">';
227 print '<td>'.$langs->trans("Parameter").'</td>';
228 print '<td></td>';
229 print "</tr>\n";
230
231 // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
232 $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
233 print '<tr class="oddeven" id="tredit"><td>';
234 print $langs->trans("MembersShowMembershipTypesTable");
235 print '</td><td>';
236 print $form->selectyesno("MEMBER_SHOW_TABLE", (int) !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
237 print "</td></tr>\n";
238
239 // Show "vote allowed" setting for membership types
240 if (!$skiptable) {
241 $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED');
242 print '<tr class="oddeven" id="tredit"><td>';
243 print $langs->trans("MembersShowVotesAllowed");
244 print '</td><td>';
245 print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", (int) !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
246 print "</td></tr>\n";
247 }
248
249 // Force Type
250 $adht = new AdherentType($db);
251 print '<tr class="oddeven drag" id="trforcetype"><td>';
252 print $langs->trans("ForceMemberType");
253 print '</td><td>';
254 $listofval = array();
255 $listofval += $adht->liste_array(1);
256 $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1);
257 print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200');
258 print "</td></tr>\n";
259
260 // Force nature of member (mor/phy)
261 $morphys = [
262 "phy" => $langs->trans("Physical"),
263 "mor" => $langs->trans("Moral"),
264 ];
265 print '<tr class="oddeven drag" id="trforcenature"><td>';
266 print $langs->trans("ForceMemberNature");
267 print '</td><td>';
268
269 $forcenature = getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY'); // 'phy' or 'mor'
270 print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200');
271 print "</td></tr>\n";
272
273 // Min amount
274 print '<tr class="oddeven" id="tredit"><td>';
275 print $langs->trans("MinimumAmount");
276 print '</td><td>';
277 print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.getDolGlobalString('MEMBER_MIN_AMOUNT').'">';
278 print ' <span class="opacitymedium">'.$langs->getCurrencySymbol($mysoc->currency_code).'</span>';
279 print "</td></tr>\n";
280
281 // SHow counter of validated members publicly
282 print '<tr class="oddeven" id="tredit"><td>';
283 print $langs->trans("MemberCountersArePublic");
284 print '</td><td>';
285 print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1, false, 0, 1);
286 print "</td></tr>\n";
287
288 // Jump to an online payment page
289 print '<tr class="oddeven" id="trpayment"><td>';
290 print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
291 print '</td><td>';
292
293 // Initialize $validpaymentmethod
294 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
295 $validpaymentmethod = getValidOnlinePaymentMethods('', 1);
296
297 // Define $listofval using the $validpaymentmethod
298 $listofval = array();
299 $listofval['-1'] = array('label' => $langs->trans('No'));
300 $listofval['all'] = array('label' => $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')', 'data-html' => $langs->trans('Yes').' &nbsp; <span class="opacitymedium">('.$langs->trans("VisitorCanChooseItsPaymentMode").')</span>');
301 foreach ($validpaymentmethod as $key => $val) {
302 if (is_array($val)) {
303 $listofval[$key] = $val;
304 } else {
305 $listofval[$key] = array('label' => $key, 'status' => 'valid');
306 }
307 }
308
309 print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0);
310 print "</td></tr>\n";
311
312 // Search a member after member creation form
313 print '<tr class="oddeven" id="trpayment"><td>';
314 print $form->textwithpicto($langs->trans("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE"), $langs->trans("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATEDesc"));
315 print '</td><td>';
316 print $form->selectyesno("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE", getDolGlobalInt("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE")); // Reverse the logic "hide -> show" for retrocompatibility
317 print "</td></tr>\n";
318
319 print '</table>';
320 print '</div>';
321
322 print '<div class="center">';
323 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
324 print '</div>';
325}
326
327
328print dol_get_fiche_end();
329
330print '</form>';
331
332// End of page
333llxFooter();
334$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.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.