dolibarr 25.0.0-alpha
setup.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) ---Replace with your own copyright and developer email---
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
26// Load Dolibarr environment
27$res = 0;
28// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
29if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
30 $res = @include str_replace("..", "", $_SERVER["CONTEXT_DOCUMENT_ROOT"])."/main.inc.php";
31}
32// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
33$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
34$tmp2 = realpath(__FILE__);
35$i = strlen($tmp) - 1; // @phan-suppress-current-line DolibarrForbiddenFunctionPlugin
36$j = strlen($tmp2) - 1; // @phan-suppress-current-line DolibarrForbiddenFunctionPlugin
37while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
38 $i--;
39 $j--;
40}
41if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
42 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
43}
44if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
45 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
46}
47// Try main.inc.php using relative path
48if (!$res && file_exists("../../main.inc.php")) {
49 $res = @include "../../main.inc.php";
50}
51if (!$res && file_exists("../../../main.inc.php")) {
52 $res = @include "../../../main.inc.php";
53}
54if (!$res) {
55 die("Include of main fails");
56}
57
58// Libraries
59require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
60require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
61require_once '../lib/mymodule.lib.php';
62//require_once "../class/myclass.class.php";
63
72// Translations
73$langs->loadLangs(array("admin", "mymodule@mymodule"));
74
75// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
77$hookmanager->initHooks(array('mymodulesetup', 'globalsetup'));
78
79// Parameters
80$action = GETPOST('action', 'aZ09');
81$backtopage = GETPOST('backtopage', 'alpha');
82$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
83
84$value = GETPOST('value', 'alpha');
85$label = GETPOST('label', 'alpha');
86$scandir = GETPOST('scan_dir', 'alpha');
87$type = 'myobject';
88
89$error = 0;
90$setupnotempty = 0;
91
92// Access control
93if (!$user->admin) {
95}
96
97
98// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
99$useFormSetup = 1;
100
101if (!class_exists('FormSetup')) {
102 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
103}
104$formSetup = new FormSetup($db);
105
106// Enter here all parameters in your setup page
107
108// Setup conf for selection of an URL
109$item = $formSetup->newItem('MYMODULE_MYPARAM1');
110$item->fieldParams['isMandatory'] = 1;
111$item->fieldAttr['placeholder'] = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'];
112$item->cssClass = 'minwidth500';
113
114// Setup conf for selection of a simple string input
115$item = $formSetup->newItem('MYMODULE_MYPARAM2');
116$item->defaultFieldValue = 'default value';
117$item->fieldAttr['placeholder'] = 'A placeholder here';
118$item->helpText = 'Tooltip text';
119
120// Setup conf for selection of a simple textarea input but we replace the text of field title
121$item = $formSetup->newItem('MYMODULE_MYPARAM3');
122$item->nameText = $item->getNameText().' more html text ';
123
124// Setup conf for a selection of a Thirdparty
125$item = $formSetup->newItem('MYMODULE_MYPARAM4');
126$item->setAsThirdpartyType();
127
128// Setup conf for a selection of a boolean
129$formSetup->newItem('MYMODULE_MYPARAM5')->setAsYesNo(); // ->fieldParams['alertifoff'] = 1 or ->fieldParams['alertifon'] = 1;
130
131// Setup conf for a selection of an Email template of type thirdparty
132$formSetup->newItem('MYMODULE_MYPARAM6')->setAsEmailTemplate('thirdparty');
133
134// Setup conf for a selection of a secured key
135//$formSetup->newItem('MYMODULE_MYPARAM7')->setAsSecureKey();
136
137// Setup conf for a selection of a Product
138$formSetup->newItem('MYMODULE_MYPARAM8')->setAsProduct();
139
140// Add a title for a new section
141$formSetup->newItem('NewSection')->setAsTitle();
142
143$TField = array(
144 'test01' => $langs->trans('test01'),
145 'test02' => $langs->trans('test02'),
146 'test03' => $langs->trans('test03'),
147 'test04' => $langs->trans('test04'),
148 'test05' => $langs->trans('test05'),
149 'test06' => $langs->trans('test06'),
150);
151
152// Setup conf for a simple combo list
153$formSetup->newItem('MYMODULE_MYPARAM9')->setAsSelect($TField);
154
155// Setup conf for a multiselect combo list
156$item = $formSetup->newItem('MYMODULE_MYPARAM10');
157$item->setAsMultiSelect($TField);
158$item->helpText = $langs->transnoentities('MYMODULE_MYPARAM10');
159
160// Setup conf for a category selection
161$formSetup->newItem('MYMODULE_CATEGORY_ID_XXX')->setAsCategory('product');
162
163// Setup conf MYMODULE_MYPARAM10
164$item = $formSetup->newItem('MYMODULE_MYPARAM10');
165$item->setAsColor();
166$item->defaultFieldValue = '#FF0000';
167//$item->fieldValue = '';
168//$item->fieldAttr = array() ; // fields attribute only for compatible fields like input text
169//$item->fieldOverride = false; // set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too
170//$item->fieldInputOverride = false; // set this var to override field input
171//$item->fieldOutputOverride = false; // set this var to override field output
172
173$item = $formSetup->newItem('MYMODULE_MYPARAM11')->setAsHtml();
174$item->nameText = $item->getNameText().' more html text ';
175$item->fieldInputOverride = '';
176$item->helpText = $langs->transnoentities('HelpMessage');
177$item->cssClass = 'minwidth500';
178
179$item = $formSetup->newItem('MYMODULE_MYPARAM12');
180$item->fieldOverride = "Value forced, can't be modified";
181$item->cssClass = 'minwidth500';
182
183//$item = $formSetup->newItem('MYMODULE_MYPARAM13')->setAsDate(); // Not yet implemented
184
185// End of definition of parameters
186
187
188$setupnotempty += count($formSetup->items);
189
190
191$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
192
193$moduledir = 'mymodule';
194$myTmpObjects = array();
195// TODO Scan list of objects to fill this array
196$myTmpObjects['myobject'] = array('label' => 'MyObject', 'includerefgeneration' => 0, 'includedocgeneration' => 0, 'class' => 'MyObject');
197
198$tmpobjectkey = GETPOST('object', 'aZ09');
199if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
200 accessforbidden('Bad value for object. Hack attempt ?');
201}
202
203
204/*
205 * Actions
206 */
207
208// For retrocompatibility Dolibarr < 15.0
209if (versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) {
210 $formSetup->saveConfFromPost();
211}
212
213include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
214
215if ($action == 'updateMask') {
216 $maskconst = GETPOST('maskconst', 'aZ09');
217 $maskvalue = GETPOST('maskvalue', 'alpha');
218
219 if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
220 $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
221 if (!($res > 0)) {
222 $error++;
223 }
224 }
225
226 if (!$error) {
227 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
228 } else {
229 setEventMessages($langs->trans("Error"), null, 'errors');
230 }
231} elseif ($action == 'specimen' && $tmpobjectkey) {
232 $modele = GETPOST('module', 'alpha');
233
234 $className = $myTmpObjects[$tmpobjectkey]['class'];
235 $tmpobject = new $className($db);
236 '@phan-var-force MyObject $tmpobject';
237 $tmpobject->initAsSpecimen();
238
239 // Search template files
240 $file = '';
241 $className = '';
242 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
243 foreach ($dirmodels as $reldir) {
244 $file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".dol_strtolower($tmpobjectkey).".modules.php", 0);
245 if (file_exists($file)) {
246 $className = "pdf_".$modele."_".dol_strtolower($tmpobjectkey);
247 break;
248 }
249 }
250
251 if ($className !== '') {
252 require_once $file;
253
254 $module = new $className($db);
255 '@phan-var-force ModelePDFMyObject $module';
256
257 '@phan-var-force ModelePDFMyObject $module';
258
259 if ($module->write_file($tmpobject, $langs) > 0) {
260 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mymodule-".dol_strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
261 exit;
262 } else {
263 setEventMessages($module->error, null, 'errors');
264 dol_syslog($module->error, LOG_ERR);
265 }
266 } else {
267 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
268 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
269 }
270} elseif ($action == 'setmod') {
271 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
272 if (!empty($tmpobjectkey)) {
273 $constforval = 'MYMODULE_'.dol_strtoupper($tmpobjectkey)."_ADDON";
274 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
275 }
276} elseif ($action == 'set') {
277 // Activate a model
278 $ret = addDocumentModel($value, $type, $label, $scandir);
279} elseif ($action == 'del') {
280 $ret = delDocumentModel($value, $type);
281 if ($ret > 0) {
282 if (!empty($tmpobjectkey)) {
283 $constforval = 'MYMODULE_'.dol_strtoupper($tmpobjectkey).'_ADDON_PDF';
284 if (getDolGlobalString($constforval) == "$value") {
285 dolibarr_del_const($db, $constforval, $conf->entity);
286 }
287 }
288 }
289} elseif ($action == 'setdoc') {
290 // Set or unset default model
291 if (!empty($tmpobjectkey)) {
292 $constforval = 'MYMODULE_'.dol_strtoupper($tmpobjectkey).'_ADDON_PDF';
293 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
294 // The constant that was read before the new set
295 // We therefore requires a variable to have a coherent view
296 $conf->global->{$constforval} = $value;
297 }
298
299 // We disable/enable the document template (into llx_document_model table)
300 $ret = delDocumentModel($value, $type);
301 if ($ret > 0) {
302 $ret = addDocumentModel($value, $type, $label, $scandir);
303 }
304 }
305} elseif ($action == 'unsetdoc') {
306 if (!empty($tmpobjectkey)) {
307 $constforval = 'MYMODULE_'.dol_strtoupper($tmpobjectkey).'_ADDON_PDF';
308 dolibarr_del_const($db, $constforval, $conf->entity);
309 }
310}
311
312$action = 'edit';
313
314
315/*
316 * View
317 */
318
319$form = new Form($db);
320
321$help_url = '';
322$title = "MyModuleSetup";
323
324llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', '', '', 'mod-mymodule page-admin');
325
326// Subheader
327$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>';
328
329print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
330
331// Configuration header
333print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "mymodule@mymodule");
334
335// Setup page goes here
336echo '<span class="opacitymedium">'.$langs->trans("MyModuleSetupPage").'</span><br><br>';
337
338
339/*if ($action == 'edit') {
340 print $formSetup->generateOutput(true);
341 print '<br>';
342 } elseif (!empty($formSetup->items)) {
343 print $formSetup->generateOutput();
344 print '<div class="tabsAction">';
345 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
346 print '</div>';
347 }
348 */
349if (!empty($formSetup->items)) {
350 print $formSetup->generateOutput(true);
351 print '<br>';
352}
353
354
355$refGenerationObjects = array();
356$docGenerationObjects = array();
357
358foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
359 if (!empty($myTmpObjectArray['includerefgeneration'])) {
360 $refGenerationObjects[$myTmpObjectKey] = $myTmpObjectArray;
361 }
362
363 if (!empty($myTmpObjectArray['includedocgeneration'])) {
364 $docGenerationObjects[$myTmpObjectKey] = $myTmpObjectArray;
365 }
366}
367
368// Numbering models
369if (!empty($refGenerationObjects)) {
370 $setupnotempty++;
371
372 print load_fiche_titre($langs->trans("NumberingModules"), '', '');
373
374 print '<table class="noborder centpercent">';
375 print '<tr class="liste_titre">';
376 print '<td>'.$langs->trans("Name").'</td>';
377 print '<td>'.$langs->trans("Description").'</td>';
378 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
379 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
380 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
381 print '</tr>'."\n";
382
383 clearstatcache();
384
385 foreach ($refGenerationObjects as $myTmpObjectKey => $myTmpObjectArray) {
386 if (empty($myTmpObjectArray['includerefgeneration'])) {
387 continue;
388 }
389
390 print '<tr class="liste_titre">';
391 print '<td colspan="5"><strong>'.$langs->trans($myTmpObjectArray['label']).'</strong></td>';
392 print '</tr>'."\n";
393
394 foreach ($dirmodels as $reldir) {
395 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
396
397 if (!dol_is_dir($dir)) {
398 continue;
399 }
400
401 $handle = opendir($dir);
402 if (!is_resource($handle)) {
403 continue;
404 }
405
406 while (($file = readdir($handle)) !== false) {
407 if (strpos($file, 'mod_'.dol_strtolower($myTmpObjectKey).'_') !== 0 || dol_substr($file, dol_strlen($file) - 3, 3) != 'php') {
408 continue;
409 }
410
411 $file = dol_substr($file, 0, dol_strlen($file) - 4);
412
413 require_once $dir.'/'.$file.'.php';
414
415 $module = new $file($db);
416 '@phan-var-force ModeleNumRefMyObject $module';
417
418 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
419 continue;
420 }
421 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
422 continue;
423 }
424 if (!$module->isEnabled()) {
425 continue;
426 }
427
428 dol_include_once('/'.$moduledir.'/class/'.dol_strtolower($myTmpObjectKey).'.class.php');
429
430 print '<tr class="oddeven"><td>'.$module->getName($langs)."</td><td>\n";
431 print $module->info($langs);
432 print '</td>';
433
434 print '<td class="nowrap">';
435 $tmp = $module->getExample();
436 if (preg_match('/^Error/', $tmp)) {
437 $langs->load("errors");
438 print '<div class="error">'.$langs->trans($tmp).'</div>';
439 } elseif ($tmp == 'NotConfigured') {
440 print $langs->trans($tmp);
441 } else {
442 print $tmp;
443 }
444 print '</td>'."\n";
445
446 print '<td class="center">';
447 $constforvar = 'MYMODULE_'.dol_strtoupper($myTmpObjectKey).'_ADDON';
448 $defaultifnotset = 'thevaluetousebydefault';
449 $activenumberingmodel = getDolGlobalString($constforvar, $defaultifnotset);
450
451 if ($activenumberingmodel == $file) {
452 print img_picto($langs->trans("Activated"), 'switch_on');
453 } else {
454 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.urlencode(dol_strtolower($myTmpObjectKey)).'&value='.urlencode($file).'">';
455 print img_picto($langs->trans("Disabled"), 'switch_off');
456 print '</a>';
457 }
458 print '</td>';
459
460 $className = $myTmpObjectArray['class'];
461 $mytmpinstance = new $className($db);
462 '@phan-var-force MyObject $mytmpinstance';
463 $mytmpinstance->initAsSpecimen();
464
465 $htmltooltip = '';
466 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
467
468 $nextval = $module->getNextValue($mytmpinstance);
469 if ("$nextval" != $langs->trans("NotAvailable")) {
470 $htmltooltip .= ''.$langs->trans("NextValue").': ';
471 if ($nextval) {
472 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
473 $nextval = $langs->trans($nextval);
474 }
475 $htmltooltip .= $nextval.'<br>';
476 } else {
477 $htmltooltip .= $langs->trans($module->error).'<br>';
478 }
479 }
480
481 print '<td class="center">';
482 print $form->textwithpicto('', $htmltooltip, 1, 'info');
483 print '</td>';
484
485 print "</tr>\n";
486 }
487
488 closedir($handle);
489 }
490
491 print '<tr><td colspan="5"><br></td></tr>'."\n";
492 }
493
494 print "</table><br>\n";
495}
496
497// Document templates generators
498if (!empty($docGenerationObjects)) {
499 $setupnotempty++;
500
501 print load_fiche_titre($langs->trans("DocumentModules"), '', '');
502
503 print '<table class="noborder centpercent">'."\n";
504 print '<tr class="liste_titre">'."\n";
505 print '<td>'.$langs->trans("Name").'</td>';
506 print '<td>'.$langs->trans("Description").'</td>';
507 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
508 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
509 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
510 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
511 print "</tr>\n";
512
513 clearstatcache();
514
515 foreach ($docGenerationObjects as $myTmpObjectKey => $myTmpObjectArray) {
516 if (empty($myTmpObjectArray['includedocgeneration'])) {
517 continue;
518 }
519
520 $type = dol_strtolower($myTmpObjectKey);
521
522 print '<tr class="liste_titre">';
523 print '<td colspan="6"><strong>'.$langs->trans($myTmpObjectArray['label']).'</strong></td>';
524 print '</tr>'."\n";
525
526 $def = array();
527
528 $sql = "SELECT nom";
529 $sql .= " FROM ".$db->prefix()."document_model";
530 $sql .= " WHERE type = '".$db->escape($type)."'";
531 $sql .= " AND entity = ".((int) $conf->entity);
532
533 $resql = $db->query($sql);
534 if ($resql) {
535 $i = 0;
536 $num_rows = $db->num_rows($resql);
537 while ($i < $num_rows) {
538 $array = $db->fetch_array($resql);
539 array_push($def, $array[0]);
540 $i++;
541 }
542 } else {
543 dol_print_error($db);
544 }
545
546 foreach ($dirmodels as $reldir) {
547 foreach (array('', '/doc') as $valdir) {
548 $realpath = $reldir."core/modules/".$moduledir.$valdir;
549 $dir = dol_buildpath($realpath);
550
551 if (!dol_is_dir($dir)) {
552 continue;
553 }
554
555 $handle = opendir($dir);
556 if (!is_resource($handle)) {
557 continue;
558 }
559
560 $filelist = array();
561
562 while (($file = readdir($handle)) !== false) {
563 $filelist[] = $file;
564 }
565 closedir($handle);
566
567 arsort($filelist);
568
569 foreach ($filelist as $file) {
570 if (!preg_match('/\.modules\.php$/i', $file) || !preg_match('/^(pdf_|doc_)/', $file)) {
571 continue;
572 }
573
574 if (!preg_match('/_'.preg_quote($type, '/').'(_odt)?\.modules\.php$/i', $file)) {
575 continue;
576 }
577
578 if (!file_exists($dir.'/'.$file)) {
579 continue;
580 }
581
582 $name = dol_substr($file, 4, dol_strlen($file) - 16);
583 $className = dol_substr($file, 0, dol_strlen($file) - 12);
584
585 require_once $dir.'/'.$file;
586
587 $module = new $className($db);
588 '@phan-var-force ModelePDFMyObject $module';
589
590 $modulequalified = 1;
591 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
592 $modulequalified = 0;
593 }
594 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
595 $modulequalified = 0;
596 }
597
598 if (!$modulequalified) {
599 continue;
600 }
601
602 print '<tr class="oddeven"><td width="100">';
603 print(empty($module->name) ? $name : $module->name);
604 print "</td><td>\n";
605
606 if (method_exists($module, 'info')) {
607 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
608 } else {
609 print $module->description;
610 }
611
612 print '</td>';
613
614 if (in_array($name, $def)) {
615 print '<td class="center">'."\n";
616 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&type='.urlencode($type).'">';
617 print img_picto($langs->trans("Enabled"), 'switch_on');
618 print '</a>';
619 print '</td>';
620 } else {
621 print '<td class="center">'."\n";
622 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'">';
623 print img_picto($langs->trans("Disabled"), 'switch_off');
624 print '</a>';
625 print "</td>";
626 }
627
628 print '<td class="center">';
629 $constforvar = 'MYMODULE_'.dol_strtoupper($myTmpObjectKey).'_ADDON_PDF';
630
631 if (getDolGlobalString($constforvar) == $name) {
632 print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">';
633 print img_picto($langs->trans("Enabled"), 'on');
634 print '</a>';
635 } else {
636 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Default").'">';
637 print img_picto($langs->trans("Disabled"), 'off');
638 print '</a>';
639 }
640
641 print '</td>';
642
643 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
644 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
645
646 if ($module->type == 'pdf') {
647 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
648 }
649
650 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
651 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
652 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
653 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
654
655 print '<td class="center">';
656 print $form->textwithpicto('', $htmltooltip, 1, 'info');
657 print '</td>';
658
659 print '<td class="center">';
660 if ($module->type == 'pdf') {
661 $newname = preg_replace('/_'.preg_quote($type, '/').'/', '', $name);
662 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.urlencode($newname).'&object='.urlencode($type).'">';
663 print img_object($langs->trans("Preview"), 'pdf');
664 print '</a>';
665 } else {
666 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"), 'generic');
667 }
668 print '</td>';
669
670 print "</tr>\n";
671 }
672 }
673 }
674
675 print '<tr><td colspan="6"><br></td></tr>'."\n";
676 }
677
678 print '</table>';
679}
680
681if (empty($setupnotempty)) {
682 print '<br>'.$langs->trans("NothingToSetup");
683}
684
685// Page end
686print dol_get_fiche_end();
687
688llxFooter();
689$db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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.
delDocumentModel($name, $type)
Delete document model used by doc generator.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:72
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.
This class help you create setup render.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_is_dir($folder)
Test if filename is a directory.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
mymoduleAdminPrepareHead()
Prepare admin pages header.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.