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