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