dolibarr  19.0.0-dev
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 || !isModEnabled('modulebuilder')) {
31 }
32 
33 $action = GETPOST('action', 'aZ09');
34 $backtopage = GETPOST('backtopage', 'alpha');
35 
36 
37 /*
38  * Actions
39  */
40 
41 if ($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();
60 if (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 
75 if (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 = '';
93 llxHeader('', $langs->trans("ModulebuilderSetup"), $help_url);
94 
95 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
96 
97 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
98 print '<input type="hidden" name="token" value="'.newToken().'">';
99 print '<input type="hidden" name="action" value="update">';
100 
101 print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback);
102 
103 if (GETPOST('withtab', 'alpha')) {
104  print dol_get_fiche_head($head, 'modulebuilder', '', -1);
105 }
106 
107 print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc")."</span><br>\n";
108 
109 print '<br>';
110 
111 print '<table class="noborder centpercent">';
112 
113 print '<tr class="liste_titre">';
114 print '<td>'.$langs->trans("Parameter").'</td>';
115 print '<td>'.$langs->trans("Value").'</td>';
116 print "</tr>\n";
117 
118 
119 if ($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 
137 print '<tr class="oddeven">';
138 print '<td>'.$langs->trans("UseSpecificEditorName").'</td>';
139 print '<td>';
140 print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_NAME" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME.'">';
141 print '</td>';
142 print '</tr>';
143 
144 print '<tr class="oddeven">';
145 print '<td>'.$langs->trans("UseSpecificEditorURL").'</td>';
146 print '<td>';
147 print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_URL" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL.'">';
148 print '</td>';
149 print '</tr>';
150 
151 if ($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 
174 print '<tr class="oddeven">';
175 print '<td>'.$langs->trans("UseSpecificReadme").'</td>';
176 print '<td>';
177 print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
178 print '</td>';
179 print '</tr>';
180 
181 print '<tr class="oddeven">';
182 print '<td>'.$langs->trans("AsciiToHtmlConverter").'</td>';
183 print '<td>';
184 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTOR.'">';
185 print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
186 print '</td>';
187 print '</tr>';
188 
189 print '<tr class="oddeven">';
190 print '<td>'.$langs->trans("AsciiToPdfConverter").'</td>';
191 print '<td>';
192 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.'">';
193 print ' '.$langs->trans("Example").': asciidoctor-pdf';
194 print '</td>';
195 print '</tr>';
196 
197 print '</table>';
198 
199 print $form->buttonsSaveCancel("Save", '');
200 
201 if (GETPOST('withtab', 'alpha')) {
202  print dol_get_fiche_end();
203 }
204 
205 print '<br>';
206 
207 print '</form>';
208 
209 // End of page
210 llxFooter();
211 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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:638
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:630
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.