dolibarr 23.0.3
setup.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require_once "../../main.inc.php";
29require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
31
42// Translations
43$langs->loadLangs(array("admin", "webportal", "website"));
44
45// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
46$hookmanager->initHooks(array('webportalsetup', 'globalsetup'));
47
48// Parameters
49$action = GETPOST('action', 'aZ09');
50$backtopage = GETPOST('backtopage', 'alpha');
51$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
52
53$value = GETPOST('value', 'alpha');
54$label = GETPOST('label', 'alpha');
55$scandir = GETPOST('scan_dir', 'alpha');
56$type = 'webportal';
57
58$error = 0;
59$setupnotempty = 0;
60
61// Access control
62if (!$user->admin) {
64}
65
66// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
67$useFormSetup = 1;
68
69if (!class_exists('FormSetup')) {
70 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php';
71}
72$formSetup = new FormSetup($db);
73
74
75// Add logged user
76//$formSetup->newItem('WEBPORTAL_USER_LOGGED2')->setAsSelectUser();
77// only enabled users
78$userList = $formSetup->form->select_dolusers(getDolGlobalInt('WEBPORTAL_USER_LOGGED'), 'WEBPORTAL_USER_LOGGED', 1, null, 0, '', '', '0', 0, 0, '', 0, '', '', 1, 2);
79
80$item = $formSetup->newItem('WEBPORTAL_USER_LOGGED');
81$item->setAsSelect($userList);
82$item->picto = 'user';
83$item->helpText = $langs->transnoentities('WebPortalUserLoggedHelp');
84// TODO Add a property mandatory to set style to "fieldrequired" and to add a check in submit
85
86
87// root url
88
89// @var FormSetupItem $item
90$item = $formSetup->newItem('WEBPORTAL_ROOT_URL')->setAsString();
91$item->nameText = $langs->transnoentities('UrlPublicInterfaceLabelAdmin');
92$item->fieldAttr = array('placeholder' => 'https://');
93$item->helpText = $langs->transnoentities('UrlPublicInterfaceHelpAdmin');
94require_once __DIR__ . '/../class/context.class.php';
95//$context = Context::getInstance();
96//$item->fieldOutputOverride = '<a target="_blank" href="'.Context::getRootConfigUrl().'" >'.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().'</a>';
97
98
99$formSetup->newItem('WEBPORTAL_TITLE')->defaultFieldValue = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
100
101
102// Enable access for the proposals
103if (isModEnabled('propal')) {
104 $formSetup->newItem('WEBPORTAL_PROPAL_LIST_ACCESS')->setAsYesNo();
105}
106
107// Enable access for the orders
108if (isModEnabled('order')) {
109 $formSetup->newItem('WEBPORTAL_ORDER_LIST_ACCESS')->setAsYesNo();
110}
111
112// Enable access for the invoices
113if (isModEnabled('invoice')) {
114 $formSetup->newItem('WEBPORTAL_INVOICE_LIST_ACCESS')->setAsYesNo();
115}
116
117// Enable access for the partnership record
118if (isModEnabled('partnership')) {
119 $access_list = array(
120 'hidden' => $langs->trans('WebPortalAccessHidden'),
121 'visible' => $langs->trans('WebPortalAccessVisible'),
122 );
123 $item = $formSetup->newItem('WEBPORTAL_PARTNERSHIP_CARD_ACCESS');
124 $item->setAsSelect($access_list);
125 $item->helpText = $langs->transnoentities('WebPortalPartnerShipCardAccessHelp');
126}
127
128// Enable access for the membership record
129if (isModEnabled('member')) {
130 $access_list = array(
131 'hidden' => $langs->trans('WebPortalAccessHidden'),
132 'visible' => $langs->trans('WebPortalAccessVisible'),
133 'edit' => $langs->trans('WebPortalAccessEdit'),
134 );
135 $item = $formSetup->newItem('WEBPORTAL_MEMBER_CARD_ACCESS');
136 $item->setAsSelect($access_list);
137 $item->helpText = $langs->transnoentities('WebPortalMemberCardAccessHelp');
138}
139
140
141$setupnotempty += count($formSetup->items);
142
143$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
144
145$moduledir = 'webportal';
146$myTmpObjects = array();
147$myTmpObjects['webportal'] = array('label' => 'WebPortal', 'includerefgeneration' => 0, 'includedocgeneration' => 0, 'class' => 'WebPortal');
148
149$tmpobjectkey = GETPOST('object', 'aZ09');
150if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
151 accessforbidden('Bad value for object. Hack attempt ?');
152}
153
154
155/*
156 * Actions
157 */
158
159include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
160
161// Force always edit mode
162if (empty($action) || $action == 'update') {
163 $action = 'edit';
164}
165
166
167/*
168 * View
169 */
170
171$form = new Form($db);
172
173$help_url = '';
174$title = "WebPortalSetup";
175
176llxHeader('', $langs->trans($title), $help_url);
177
178// Subheader
179$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
180
181print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
182
183// Configuration header
185print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "webportal");
186
187print '<br>';
188
189// URL For webportal
190print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('WebPortalURL').'</span><br>';
191if (isModEnabled('multicompany')) {
192 $entity_qr = '?entity='.((int) $conf->entity);
193} else {
194 $entity_qr = '';
195}
196
197// Define $urlwithroot
198$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
199$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
200//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
201
202print '<div class="urllink">';
203print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/webportal/index.php'.$entity_qr.'">';
204print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/webportal/index.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
205print '</div>';
206print ajax_autoselect('publicurlmember');
207//print '<a target="_blank" href="'.Context::getRootConfigUrl().'" >'.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().'</a>';
208
209// Setup page goes here
210print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp", $langs->transnoentities("WebsiteAccount")));
211
212print '<br><br>';
213
214if ($action == 'edit') {
215 print $formSetup->generateOutput(true);
216 print '<br>';
217} elseif (!empty($formSetup->items)) {
218 print $formSetup->generateOutput();
219 print '<div class="tabsAction">';
220 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>';
221 print '</div>';
222} else {
223 print '<br>' . $langs->trans("NothingToSetup");
224}
225
226// Page end
227print dol_get_fiche_end();
228
229llxFooter();
230$db->close();
global $dolibarr_main_url_root
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 generation of HTML components Only common components must be here.
This class help you create setup render.
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)
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
webportalAdminPrepareHead()
Prepare admin pages header.