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