dolibarr 23.0.3
setup.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 Benjamin Falière <benjamin@faliere.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25require '../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27
36$langs->loadLangs(array("admin", "other", "modulebuilder"));
37
38$action = GETPOST('action', 'aZ09');
39$backtopage = GETPOST('backtopage', 'alpha');
40$head = [];
41
42if (!$user->admin || !isModEnabled('modulebuilder')) {
44}
45
46
47/*
48 * Actions
49 */
50
51if ($action == "update") {
52 $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity);
53 $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
54 $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
55 $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
56 $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
57 $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
58 $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'restricthtml'), 'chaine', 0, '', $conf->entity);
59 $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
60 if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) {
61 setEventMessages('ErrorFailedToSaveDate', null, 'errors');
62 $db->rollback();
63 } else {
64 setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
65 $db->commit();
66 }
67}
68
69$reg = array();
70if (preg_match('/set_(.*)/', $action, $reg)) {
71 $code = $reg[1];
72 $values = GETPOST($code);
73 if (is_array($values)) {
74 $values = implode(',', $values);
75 }
76
77 if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
78 header("Location: ".$_SERVER["PHP_SELF"]);
79 exit;
80 } else {
81 dol_print_error($db);
82 }
83}
84
85if (preg_match('/del_(.*)/', $action, $reg)) {
86 $code = $reg[1];
87 if (dolibarr_del_const($db, $code, 0) > 0) {
88 header("Location: ".$_SERVER["PHP_SELF"]);
89 exit;
90 } else {
91 dol_print_error($db);
92 }
93}
94
95
96/*
97 * View
98 */
99
100$form = new Form($db);
101
102$help_url = '';
103llxHeader('', $langs->trans("ModulebuilderSetup"), $help_url);
104
105$linkback = '<a href="'.($backtopage ? $backtopage : 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>';
106
107print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
108print '<input type="hidden" name="token" value="'.newToken().'">';
109print '<input type="hidden" name="action" value="update">';
110
111print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback);
112
113if (GETPOST('withtab', 'alpha')) {
114 print dol_get_fiche_head($head, 'modulebuilder', '', -1);
115}
116
117print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc")."</span><br>\n";
118
119print '<br>';
120
121print '<table class="noborder centpercent">';
122
123print '<tr class="liste_titre">';
124print '<td>'.$langs->trans("Parameter").'</td>';
125print '<td>'.$langs->trans("Value").'</td>';
126print "</tr>\n";
127
128
129if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
130 // What is use case of this 2 options ?
131
132 print '<tr class="oddeven">';
133 print '<td>'.$langs->trans("UseAboutPage").'</td>';
134 print '<td>';
135 if ($conf->use_javascript_ajax) {
136 print ajax_constantonoff('MODULEBUILDER_USE_ABOUT');
137 } else {
138 if (!getDolGlobalString('MODULEBUILDER_USE_ABOUT')) {
139 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=set_MODULEBUILDER_USE_ABOUT&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
140 } else {
141 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del_MODULEBUILDER_USE_ABOUT&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
142 }
143 }
144 print '</td></tr>';
145}
146
147print '<tr class="oddeven">';
148print '<td><label for="MODULEBUILDER_SPECIFIC_EDITOR_NAME" class="block">'.$langs->trans("UseSpecificEditorName").'</label></td>';
149print '<td>';
150print '<input id="MODULEBUILDER_SPECIFIC_EDITOR_NAME" type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_NAME" value="'.getDolGlobalString('MODULEBUILDER_SPECIFIC_EDITOR_NAME').'">';
151print '</td>';
152print '</tr>';
153
154print '<tr class="oddeven">';
155print '<td><label for="MODULEBUILDER_SPECIFIC_EDITOR_URL" class="block">'.$langs->trans("UseSpecificEditorURL").'</label></td>';
156print '<td>';
157print '<input id="MODULEBUILDER_SPECIFIC_EDITOR_URL" type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_URL" value="'.getDolGlobalString('MODULEBUILDER_SPECIFIC_EDITOR_URL').'">';
158print '</td>';
159print '</tr>';
160
161if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
162 print '<tr class="oddeven">';
163 print '<td><label for="MODULEBUILDER_SPECIFIC_FAMILY" class="block">'.$langs->trans("UseSpecificFamily").'</label></td>';
164 print '<td>';
165 print '<input id="MODULEBUILDER_SPECIFIC_FAMILY" type="text" name="MODULEBUILDER_SPECIFIC_FAMILY" value="'.getDolGlobalString('MODULEBUILDER_SPECIFIC_FAMILY').'">';
166 print '</td>';
167 print '</tr>';
168
169 print '<tr class="oddeven">';
170 print '<td><label for="MODULEBUILDER_SPECIFIC_AUTHOR" class="block">'.$langs->trans("UseSpecificAuthor").'</label></td>';
171 print '<td>';
172 print '<input id="MODULEBUILDER_SPECIFIC_AUTHOR" type="text" name="MODULEBUILDER_SPECIFIC_AUTHOR" value="'.getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR').'">';
173 print '</td>';
174 print '</tr>';
175
176 print '<tr class="oddeven">';
177 print '<td><label for="MODULEBUILDER_SPECIFIC_VERSION" class="block">'.$langs->trans("UseSpecificVersion").'</label></td>';
178 print '<td>';
179 print '<input id="MODULEBUILDER_SPECIFIC_VERSION" type="text" name="MODULEBUILDER_SPECIFIC_VERSION" value="'.getDolGlobalString('MODULEBUILDER_SPECIFIC_VERSION').'">';
180 print '</td>';
181 print '</tr>';
182}
183
184print '<tr class="oddeven">';
185print '<td><label for="MODULEBUILDER_SPECIFIC_README" class="block">'.$langs->trans("UseSpecificReadme").'</label></td>';
186print '<td>';
187print '<textarea id="MODULEBUILDER_SPECIFIC_README" class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.getDolGlobalString('MODULEBUILDER_SPECIFIC_README').'</textarea>';
188print '</td>';
189print '</tr>';
190
191print '<tr class="oddeven">';
192print '<td><label for="MODULEBUILDER_ASCIIDOCTOR" class="block">'.$langs->trans("AsciiToHtmlConverter").'</label></td>';
193print '<td>';
194print '<input id="MODULEBUILDER_ASCIIDOCTOR" type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.getDolGlobalString('MODULEBUILDER_ASCIIDOCTOR').'">';
195print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
196print '</td>';
197print '</tr>';
198
199print '<tr class="oddeven">';
200print '<td><label for="MODULEBUILDER_ASCIIDOCTORPDF" class="block">'.$langs->trans("AsciiToPdfConverter").'</label></td>';
201print '<td>';
202print '<input id="MODULEBUILDER_ASCIIDOCTORPDF" type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.getDolGlobalString('MODULEBUILDER_ASCIIDOCTORPDF').'">';
203print ' '.$langs->trans("Example").': asciidoctor-pdf';
204print '</td>';
205print '</tr>';
206
207print '</table>';
208
209print $form->buttonsSaveCancel("Save", '');
210
211if (GETPOST('withtab', 'alpha')) {
212 print dol_get_fiche_end();
213}
214
215print '<br>';
216
217print '</form>';
218
219// End of page
220llxFooter();
221$db->close();
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 generation of HTML components Only common components must be here.
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)
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.