dolibarr 24.0.0-beta
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";
38require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
39require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
40
41// Translations
42$langs->loadLangs(array("admin", "webportal", "website"));
43
44// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
45$hookmanager->initHooks(array('webportalsetup', 'globalsetup'));
46
47// Parameters
48$action = GETPOST('action', 'aZ09');
49$backtopage = GETPOST('backtopage', 'alpha');
50$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
51
52$value = GETPOST('value', 'alpha');
53$label = GETPOST('label', 'alpha');
54$scandir = GETPOST('scan_dir', 'alpha');
55$type = 'webportal';
56
57$error = 0;
58$setupnotempty = 0;
59
60// Access control
61if (!$user->admin) {
63}
64
65// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
66$useFormSetup = 1;
67
68if (!class_exists('FormSetup')) {
69 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php';
70}
71$formSetup = new FormSetup($db);
72
73
74// Add logged user
75//$formSetup->newItem('WEBPORTAL_USER_LOGGED2')->setAsSelectUser();
76// only enabled users
77$userList = $formSetup->form->select_dolusers(getDolGlobalInt('WEBPORTAL_USER_LOGGED'), 'WEBPORTAL_USER_LOGGED', 1, null, 0, '', '', '0', 0, 0, '', 0, '', '', 1, 2);
78
79$item = $formSetup->newItem('WEBPORTAL_USER_LOGGED');
80$item->setAsSelect($userList);
81$item->picto = 'user';
82$item->helpText = $langs->transnoentities('WebPortalUserLoggedHelp');
83// TODO Add a property mandatory to set style to "fieldrequired" and to add a check in submit
84
85
86// root url
87
88// @var FormSetupItem $item
89$item = $formSetup->newItem('WEBPORTAL_ROOT_URL')->setAsString();
90$item->nameText = $langs->transnoentities('UrlPublicInterfaceLabelAdmin');
91$item->fieldAttr = array('placeholder' => 'https://');
92$item->helpText = $langs->transnoentities('UrlPublicInterfaceHelpAdmin');
93require_once __DIR__ . '/../class/context.class.php';
94//$context = Context::getInstance();
95//$item->fieldOutputOverride = '<a target="_blank" href="'.Context::getRootConfigUrl().'" >'.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().'</a>';
96
97
98$formSetup->newItem('WEBPORTAL_TITLE')->defaultFieldValue = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
99
100
101// Enable access for the proposals
102if (isModEnabled('propal')) {
103 $formSetup->newItem('WEBPORTAL_PROPAL_LIST_ACCESS')->setAsYesNo();
104}
105
106// Enable access for the orders
107if (isModEnabled('order')) {
108 $formSetup->newItem('WEBPORTAL_ORDER_LIST_ACCESS')->setAsYesNo();
109}
110
111// Enable access for the invoices
112if (isModEnabled('invoice')) {
113 $formSetup->newItem('WEBPORTAL_INVOICE_LIST_ACCESS')->setAsYesNo();
114}
115
116// Enable access for the intervention
117if (isModEnabled('intervention')) {
118 $formSetup->newItem('WEBPORTAL_FICHEINTER_LIST_ACCESS')->setAsYesNo();
119}
120
121// Enable access for the tickets
122if (isModEnabled('ticket')) {
123 $formSetup->newItem('WEBPORTAL_TICKET_LIST_ACCESS')->setAsYesNo();
124}
125
126// Enable access for the partnership record
127if (isModEnabled('partnership')) {
128 $access_list = array(
129 'hidden' => $langs->trans('WebPortalAccessHidden'),
130 'visible' => $langs->trans('WebPortalAccessVisible'),
131 );
132 $item = $formSetup->newItem('WEBPORTAL_PARTNERSHIP_CARD_ACCESS');
133 $item->setAsSelect($access_list);
134 $item->helpText = $langs->transnoentities('WebPortalPartnerShipCardAccessHelp');
135}
136
137// Enable access for the membership record
138if (isModEnabled('member')) {
139 $access_list = array(
140 'hidden' => $langs->trans('WebPortalAccessHidden'),
141 'visible' => $langs->trans('WebPortalAccessVisible'),
142 'edit' => $langs->trans('WebPortalAccessEdit'),
143 );
144 $item = $formSetup->newItem('WEBPORTAL_MEMBER_CARD_ACCESS');
145 $item->setAsSelect($access_list);
146 $item->helpText = $langs->transnoentities('WebPortalMemberCardAccessHelp');
147}
148
149
150$setupnotempty += count($formSetup->items);
151
152$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
153
154$moduledir = 'webportal';
155$myTmpObjects = array();
156$myTmpObjects['webportal'] = array('label' => 'WebPortal', 'includerefgeneration' => 0, 'includedocgeneration' => 0, 'class' => 'WebPortal');
157
158$tmpobjectkey = GETPOST('object', 'aZ09');
159if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
160 accessforbidden('Bad value for object. Hack attempt ?');
161}
162
163
164/*
165 * Actions
166 */
167
168include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
169
170// Force always edit mode
171if (empty($action) || $action == 'update') {
172 $action = 'edit';
173}
174
175
176/*
177 * View
178 */
179
180$form = new Form($db);
181
182$help_url = '';
183$title = "WebPortalSetup";
184
185llxHeader('', $langs->trans($title), $help_url);
186
187// Subheader
188$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
189
190print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
191
192// Configuration header
194print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "webportal");
195
196print '<br>';
197
198// URL For webportal
199print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('WebPortalURL').'</span><br>';
200if (isModEnabled('multicompany')) {
201 $entity_qr = '?entity='.((int) $conf->entity);
202} else {
203 $entity_qr = '';
204}
205
206// Define $urlwithroot
207$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
208$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
209//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
210
211print '<div class="urllink">';
212print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/webportal/index.php'.$entity_qr.'">';
213print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/webportal/index.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
214print '</div>';
215print ajax_autoselect('publicurlmember');
216//print '<a target="_blank" href="'.Context::getRootConfigUrl().'" >'.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().'</a>';
217
218// Setup page goes here
219print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp", $langs->transnoentities("WebsiteAccount")));
220
221print '<br><br>';
222
223if ($action == 'edit') {
224 print $formSetup->generateOutput(true);
225 print '<br>';
226} elseif (!empty($formSetup->items)) {
227 print $formSetup->generateOutput();
228 print '<div class="tabsAction">';
229 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>';
230 print '</div>';
231} else {
232 print '<br>' . $langs->trans("NothingToSetup");
233}
234
235// Page end
236print dol_get_fiche_end();
237
238llxFooter();
239$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.
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.
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)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
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.
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.