dolibarr  13.0.2
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 
23 require '../../main.inc.php';
24 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
25 
26 global $conf, $langs, $user, $db;
27 $langs->loadLangs(array("admin", "other", "modulebuilder"));
28 
29 if (!$user->admin || empty($conf->modulebuilder->enabled))
31 
32 $action = GETPOST('action', 'aZ09');
33 $backtopage = GETPOST('backtopage', 'alpha');
34 
35 /*
36  * Actions
37  */
38 if ($action == "update")
39 {
40  $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity);
41  $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity);
42  $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity);
43  $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity);
44  $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity);
45  $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity);
46  $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity);
47  $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity);
48  if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) {
49  setEventMessages('ErrorFailedToSaveDate', null, 'errors');
50  $db->rollback();
51  } else {
52  setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
53  $db->commit();
54  }
55 }
56 
57 $reg = array();
58 if (preg_match('/set_(.*)/', $action, $reg)) {
59  $code = $reg[1];
60  $values = GETPOST($code);
61  if (is_array($values))
62  $values = implode(',', $values);
63 
64  if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
65  header("Location: ".$_SERVER["PHP_SELF"]);
66  exit;
67  } else {
68  dol_print_error($db);
69  }
70 }
71 
72 if (preg_match('/del_(.*)/', $action, $reg)) {
73  $code = $reg[1];
74  if (dolibarr_del_const($db, $code, 0) > 0) {
75  Header("Location: ".$_SERVER["PHP_SELF"]);
76  exit;
77  } else {
78  dol_print_error($db);
79  }
80 }
81 
82 
83 /*
84  * View
85  */
86 
87 $form = new Form($db);
88 
89 llxHeader('', $langs->trans("ModulebuilderSetup"));
90 
91 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
92 
93 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
94 print '<input type="hidden" name="token" value="'.newToken().'">';
95 print '<input type="hidden" name="action" value="update">';
96 
97 print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback);
98 
99 if (GETPOST('withtab', 'alpha')) {
100  print dol_get_fiche_head($head, 'modulebuilder', '', -1);
101 }
102 
103 print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc")."</span><br>\n";
104 
105 print '<br>';
106 
107 print '<table class="noborder centpercent">';
108 
109 print '<tr class="liste_titre">';
110 print '<td style="width: 30%">'.$langs->trans("Key").'</td>';
111 print '<td>'.$langs->trans("Value").'</td>';
112 print "</tr>\n";
113 
114 
115 if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
116 {
117  // What is use case of this 2 options ?
118 
119  print '<tr class="oddeven">';
120  print '<td>'.$langs->trans("UseAboutPage").'</td>';
121  print '<td class="center">';
122  if ($conf->use_javascript_ajax) {
123  print ajax_constantonoff('MODULEBUILDER_USE_ABOUT');
124  } else {
125  if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) {
126  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=set_MODULEBUILDER_USE_ABOUT&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
127  } else {
128  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del_MODULEBUILDER_USE_ABOUT&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
129  }
130  }
131  print '</td></tr>';
132 
133  print '<tr class="oddeven">';
134  print '<td class="tdtop">'.$langs->trans("UseSpecificEditorName").'</td>';
135  print '<td>';
136  print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_NAME" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME.'">';
137  print '</td>';
138  print '</tr>';
139 
140  print '<tr class="oddeven">';
141  print '<td class="tdtop">'.$langs->trans("UseSpecificEditorURL").'</td>';
142  print '<td>';
143  print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_URL" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL.'">';
144  print '</td>';
145  print '</tr>';
146 
147  print '<tr class="oddeven">';
148  print '<td class="tdtop">'.$langs->trans("UseSpecificFamily").'</td>';
149  print '<td>';
150  print '<input type="text" name="MODULEBUILDER_SPECIFIC_FAMILY" value="'.$conf->global->MODULEBUILDER_SPECIFIC_FAMILY.'">';
151  print '</td>';
152  print '</tr>';
153 
154  print '<tr class="oddeven">';
155  print '<td class="tdtop">'.$langs->trans("UseSpecificAuthor").'</td>';
156  print '<td>';
157  print '<input type="text" name="MODULEBUILDER_SPECIFIC_AUTHOR" value="'.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR.'">';
158  print '</td>';
159  print '</tr>';
160 
161  print '<tr class="oddeven">';
162  print '<td class="tdtop">'.$langs->trans("UseSpecificVersion").'</td>';
163  print '<td>';
164  print '<input type="text" name="MODULEBUILDER_SPECIFIC_VERSION" value="'.$conf->global->MODULEBUILDER_SPECIFIC_VERSION.'">';
165  print '</td>';
166  print '</tr>';
167 }
168 
169 print '<tr class="oddeven">';
170 print '<td class="tdtop">'.$langs->trans("UseSpecificReadme").'</td>';
171 print '<td>';
172 print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
173 print '</td>';
174 print '</tr>';
175 
176 print '<tr class="oddeven">';
177 print '<td class="tdtop">'.$langs->trans("AsciiToHtmlConverter").'</td>';
178 print '<td>';
179 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTOR.'">';
180 print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
181 print '</td>';
182 print '</tr>';
183 
184 print '<tr class="oddeven">';
185 print '<td class="tdtop">'.$langs->trans("AsciiToPdfConverter").'</td>';
186 print '<td>';
187 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.'">';
188 print ' '.$langs->trans("Example").': asciidoctor-pdf';
189 print '</td>';
190 print '</tr>';
191 
192 print '</table>';
193 
194 print '<center><input type="submit" class="button button-save" value="'.$langs->trans("Save").'" name="Button"></center>';
195 
196 if (GETPOST('withtab', 'alpha')) {
198 }
199 
200 print '<br>';
201 
202 print '</form>';
203 
204 // End of page
205 llxFooter();
206 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
Definition: admin.lib.php:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:499
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
Definition: ajax.lib.php:503
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59