31if (!defined(
'NOSCANPOSTFORINJECTION')) {
32 define(
'NOSCANPOSTFORINJECTION',
'1');
36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/modulebuilder.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
45$langs->loadLangs(array(
"admin",
"modulebuilder",
"other",
"cron",
"errors"));
48$action =
GETPOST(
'action',
'aZ09');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$cancel =
GETPOST(
'cancel',
'alpha');
52$sortfield =
GETPOST(
'sortfield',
'alpha');
53$sortorder =
GETPOST(
'sortorder',
'alpha');
55$module =
GETPOST(
'module',
'alpha');
57$tabobj =
GETPOST(
'tabobj',
'alpha');
58$tabdic =
GETPOST(
'tabdic',
'alpha');
59$propertykey =
GETPOST(
'propertykey',
'alpha');
61 $module =
'initmodule';
67 $tabobj =
'newobjectifnoobj';
70 $tabdic =
'newdicifnodic';
72$file =
GETPOST(
'file',
'alpha');
77$editorname=
GETPOST(
'editorname',
'alpha');
78$editorurl=
GETPOST(
'editorurl',
'alpha');
79$version=
GETPOST(
'version',
'alpha');
80$family=
GETPOST(
'family',
'alpha');
81$picto=
GETPOST(
'idpicto',
'alpha');
82$idmodule=
GETPOST(
'idmodule',
'alpha');
85if (!isModEnabled(
'modulebuilder')) {
88if (!$user->hasRight(
"modulebuilder",
"run")) {
93$tmp = explode(
',', $dolibarr_main_document_root_alt);
98$tmpdir = explode(
'@', $module);
99if (!empty($tmpdir[1])) {
100 $module = $tmpdir[0];
101 $dirread = $tmpdir[1];
104if (
GETPOST(
'dirins',
'alpha')) {
105 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
109$FILEFLAG =
'modulebuilder.txt';
113if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) {
114 $newmask = $conf->global->MAIN_UMASK;
116if (empty($newmask)) {
124$form =
new Form($db);
127$dirsrootforscan = array($dirread);
130if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) {
131 $dirsrootforscan[] = DOL_DOCUMENT_ROOT;
135$textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
136$listofmodules = array();
138foreach ($dirsrootforscan as $tmpdirread) {
139 $moduletype =
'external';
140 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
141 $moduletype =
'internal';
144 $dirsincustom =
dol_dir_list($tmpdirread,
'directories');
145 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
146 foreach ($dirsincustom as $dircustomcursor) {
147 $fullname = $dircustomcursor[
'fullname'];
150 $dirtoscanrel = basename($fullname).
'/core/modules/';
152 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
153 if (empty($descriptorfiles)) {
154 $dirtoscanrel =
'core/modules/';
155 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.strtoupper(basename($fullname)).
'\.class\.php$');
157 $modulenamewithcase =
'';
158 $moduledescriptorrelpath =
'';
159 $moduledescriptorfullpath =
'';
161 foreach ($descriptorfiles as $descriptorcursor) {
162 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
163 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
164 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
165 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
168 if ($modulenamewithcase) {
169 $listofmodules[$dircustomcursor[
'name']] = array(
170 'modulenamewithcase'=>$modulenamewithcase,
171 'moduledescriptorrelpath'=> $moduledescriptorrelpath,
172 'moduledescriptorfullpath'=>$moduledescriptorfullpath,
173 'moduledescriptorrootpath'=>$tmpdirread,
174 'moduletype'=>$moduletype
182 if ($forceddirread && empty($listofmodules)) {
183 $listofmodules[strtolower($module)] = array(
184 'modulenamewithcase'=>$module,
185 'moduledescriptorrelpath'=>
'notyetimplemented',
186 'moduledescriptorfullpath'=>
'notyetimplemented',
187 'moduledescriptorrootpath'=>
'notyetimplemented',
192 $newdircustom = $dirins;
193 if (empty($newdircustom)) {
199 $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
201 $textforlistofdirs .=
', ';
203 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$tmpdirread.
'</strong>';
204 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
206 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
209 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
220if ($dirins && $action ==
'initmodule' && $modulename) {
221 $modulename = ucfirst($modulename);
223 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
225 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
229 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
230 $destdir = $dirins.
'/'.strtolower($modulename);
232 $arrayreplacement = array(
233 'mymodule'=>strtolower($modulename),
234 'MyModule'=>$modulename
237 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
242 $langs->load(
"errors");
243 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
246 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
251 $tryToCopyFromSetupClass =
true;
252 $backportDest = $destdir .
'/backport/v16/core/class';
253 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
254 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
259 $langs->load(
"errors");
260 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
261 $tryToCopyFromSetupClass =
false;
264 if ($tryToCopyFromSetupClass) {
265 $result =
dol_copy($backportFileSrc, $backportFileDest);
269 $langs->load(
"errors");
270 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
272 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
277 if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) {
296 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
297 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
305 dol_delete_file($destdir.
'/test/phpunit/'.$modulename.
'FunctionnalTest.php');
314 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
316 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
317 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
318 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
319 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
333 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
334 foreach ($listofphpfilestoedit as $phpfileval) {
336 $arrayreplacement = array(
337 'mymodule'=>strtolower($modulename),
338 'MyModule'=>$modulename,
339 'MYMODULE'=>strtoupper($modulename),
340 'My module'=>$modulename,
341 'my module'=>$modulename,
342 'Mon module'=>$modulename,
343 'mon module'=>$modulename,
344 'htdocs/modulebuilder/template'=>strtolower($modulename),
345 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
346 'Editor name'=>$editorname,
347 'https://www.example.com'=>$editorurl,
348 '$this->version = \'1.0\''=>
'$this->version = \''.$version.
'\'',
349 '$this->picto = \'generic\';'=>(empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
350 "modulefamily" =>$family,
354 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
355 $arrayreplacement[
'Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
357 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
358 $arrayreplacement[
'https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
360 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
361 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
363 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
364 $arrayreplacement[
'1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
366 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
367 $arrayreplacement[
'modulefamily'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
373 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
377 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README)) {
378 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
380 file_put_contents($destdir.
'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README);
386 $module = $modulename;
388 clearstatcache(
true);
389 if (function_exists(
'opcache_invalidate')) {
393 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
400if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module)) {
401 $modulename = ucfirst($module);
402 $objectname = $tabobj;
403 $varnametoupdate =
'';
404 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
405 $destdir = $dirins.
'/'.strtolower($module);
411 if ($action ==
'initapi') {
412 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
413 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php', 0, 1);
415 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
416 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
417 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
418 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
419 } elseif ($action ==
'initphpunit') {
420 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
421 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
422 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
423 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
424 } elseif ($action ==
'initpagecontact') {
425 dol_mkdir($dirins.
'/'.strtolower($module));
426 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
427 $srcfile = $srcdir.
'/myobject_contact.php';
428 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
429 $varnametoupdate =
'showtabofpagecontact';
430 } elseif ($action ==
'initpagedocument') {
431 dol_mkdir($dirins.
'/'.strtolower($module));
432 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
433 $srcfile = $srcdir.
'/myobject_document.php';
434 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
435 $varnametoupdate =
'showtabofpagedocument';
436 } elseif ($action ==
'initpagenote') {
437 dol_mkdir($dirins.
'/'.strtolower($module));
438 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
439 $srcfile = $srcdir.
'/myobject_note.php';
440 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
441 $varnametoupdate =
'showtabofpagenote';
442 } elseif ($action ==
'initpageagenda') {
443 dol_mkdir($dirins.
'/'.strtolower($module));
444 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
445 $srcfile = $srcdir.
'/myobject_agenda.php';
446 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
447 $varnametoupdate =
'showtabofpageagenda';
452 if (!file_exists($destfile)) {
453 $result =
dol_copy($srcfile, $destfile, 0, 0);
458 $arrayreplacement = array(
459 'mymodule'=>strtolower($modulename),
460 'MyModule'=>$modulename,
461 'MYMODULE'=>strtoupper($modulename),
462 'My module'=>$modulename,
463 'my module'=>$modulename,
464 'Mon module'=>$modulename,
465 'mon module'=>$modulename,
466 'htdocs/modulebuilder/template'=>strtolower($modulename),
467 'myobject'=>strtolower($objectname),
468 'MyObject'=>$objectname,
469 'MYOBJECT'=>strtoupper($objectname),
470 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
473 if (count($objects) > 1) {
477 dolReplaceInFile($destfile, array(
'/*begin methods CRUD*/' =>
'/*begin methods CRUD*/'.
"\n\t".
'/*CRUD FOR '.strtoupper($objectname).
'*/',
'/*end methods CRUD*/' =>
'/*END CRUD FOR '.strtoupper($objectname).
'*/'.
"\n\t".
'/*end methods CRUD*/'));
480 if ($varnametoupdate) {
482 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
483 $arrayreplacement = array(
'/\$'.$varnametoupdate.
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
487 $langs->load(
"errors");
488 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
494if ($dirins && $action ==
'initsqlextrafields' && !empty($module)) {
495 $modulename = ucfirst($module);
496 $objectname = $tabobj;
498 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
499 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
500 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
501 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
504 $result1 =
dol_copy($srcfile1, $destfile1, 0, 0);
505 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
506 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
509 $result2 =
dol_copy($srcfile2, $destfile2, 0, 0);
511 if ($result1 > 0 && $result2 > 0) {
512 $modulename = ucfirst($module);
515 $arrayreplacement = array(
516 'mymodule'=>strtolower($modulename),
517 'MyModule'=>$modulename,
518 'MYMODULE'=>strtoupper($modulename),
519 'My module'=>$modulename,
520 'my module'=>$modulename,
521 'Mon module'=>$modulename,
522 'mon module'=>$modulename,
523 'htdocs/modulebuilder/template'=>strtolower($modulename),
524 'My Object'=>$objectname,
525 'MyObject'=>$objectname,
526 'my object'=>strtolower($objectname),
527 'myobject'=>strtolower($objectname),
528 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
534 $langs->load(
"errors");
536 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
539 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
544 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
545 $arrayreplacement = array(
'/\$isextrafieldmanaged = 0;/' =>
'$isextrafieldmanaged = 1;');
551if ($dirins && $action ==
'inithook' && !empty($module)) {
552 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
553 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
554 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
555 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
558 $result =
dol_copy($srcfile, $destfile, 0, 0);
561 $modulename = ucfirst($module);
564 $arrayreplacement = array(
565 'mymodule'=>strtolower($modulename),
566 'MyModule'=>$modulename,
567 'MYMODULE'=>strtoupper($modulename),
568 'My module'=>$modulename,
569 'my module'=>$modulename,
570 'Mon module'=>$modulename,
571 'mon module'=>$modulename,
572 'htdocs/modulebuilder/template'=>strtolower($modulename),
573 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
578 $langs->load(
"errors");
579 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
585if ($dirins && $action ==
'inittrigger' && !empty($module)) {
586 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
587 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
588 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
589 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
592 $result =
dol_copy($srcfile, $destfile, 0, 0);
595 $modulename = ucfirst($module);
598 $arrayreplacement = array(
599 'mymodule'=>strtolower($modulename),
600 'MyModule'=>$modulename,
601 'MYMODULE'=>strtoupper($modulename),
602 'My module'=>$modulename,
603 'my module'=>$modulename,
604 'Mon module'=>$modulename,
605 'mon module'=>$modulename,
606 'htdocs/modulebuilder/template'=>strtolower($modulename),
607 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
612 $langs->load(
"errors");
613 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
619if ($dirins && $action ==
'initwidget' && !empty($module)) {
620 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
621 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
622 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
623 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
626 $result =
dol_copy($srcfile, $destfile, 0, 0);
629 $modulename = ucfirst($module);
632 $arrayreplacement = array(
633 'mymodule'=>strtolower($modulename),
634 'MyModule'=>$modulename,
635 'MYMODULE'=>strtoupper($modulename),
636 'My module'=>$modulename,
637 'my module'=>$modulename,
638 'Mon module'=>$modulename,
639 'mon module'=>$modulename,
640 'htdocs/modulebuilder/template'=>strtolower($modulename),
641 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
646 $langs->load(
"errors");
647 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
653if ($dirins && $action ==
'initcss' && !empty($module)) {
654 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
655 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
656 $srcfile = $srcdir.
'/css/mymodule.css.php';
657 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
660 $result =
dol_copy($srcfile, $destfile, 0, 0);
663 $modulename = ucfirst($module);
666 $arrayreplacement = array(
667 'mymodule'=>strtolower($modulename),
668 'MyModule'=>$modulename,
669 'MYMODULE'=>strtoupper($modulename),
670 'My module'=>$modulename,
671 'my module'=>$modulename,
672 'Mon module'=>$modulename,
673 'mon module'=>$modulename,
674 'htdocs/modulebuilder/template'=>strtolower($modulename),
675 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
681 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
682 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
685 $langs->load(
"errors");
686 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
692if ($dirins && $action ==
'initjs' && !empty($module)) {
693 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
694 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
695 $srcfile = $srcdir.
'/js/mymodule.js.php';
696 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
699 $result =
dol_copy($srcfile, $destfile, 0, 0);
702 $modulename = ucfirst($module);
705 $arrayreplacement = array(
706 'mymodule'=>strtolower($modulename),
707 'MyModule'=>$modulename,
708 'MYMODULE'=>strtoupper($modulename),
709 'My module'=>$modulename,
710 'my module'=>$modulename,
711 'Mon module'=>$modulename,
712 'mon module'=>$modulename,
713 'htdocs/modulebuilder/template'=>strtolower($modulename),
714 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
720 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
721 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
724 $langs->load(
"errors");
725 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
731if ($dirins && $action ==
'initcli' && !empty($module)) {
732 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
733 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
734 $srcfile = $srcdir.
'/scripts/mymodule.php';
735 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
738 $result =
dol_copy($srcfile, $destfile, 0, 0);
741 $modulename = ucfirst($module);
744 $arrayreplacement = array(
745 'mymodule'=>strtolower($modulename),
746 'MyModule'=>$modulename,
747 'MYMODULE'=>strtoupper($modulename),
748 'My module'=>$modulename,
749 'my module'=>$modulename,
750 'Mon module'=>$modulename,
751 'mon module'=>$modulename,
752 'htdocs/modulebuilder/template'=>strtolower($modulename),
753 '__MYCOMPANY_NAME__'=>$mysoc->name,
754 '__KEYWORDS__'=>$modulename,
755 '__USER_FULLNAME__'=>$user->getFullName($langs),
756 '__USER_EMAIL__'=>$user->email,
758 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
763 $langs->load(
"errors");
764 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
770if ($dirins && $action ==
'initdoc' && !empty($module)) {
771 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
772 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
773 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
774 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
777 $result =
dol_copy($srcfile, $destfile, 0, 0);
780 $modulename = ucfirst($module);
781 $modulelowercase = strtolower($module);
784 $arrayreplacement = array(
785 'mymodule'=>strtolower($modulename),
786 'MyModule'=>$modulename,
787 'MYMODULE'=>strtoupper($modulename),
788 'My module'=>$modulename,
789 'my module'=>$modulename,
790 'Mon module'=>$modulename,
791 'mon module'=>$modulename,
792 'htdocs/modulebuilder/template'=>strtolower($modulename),
793 '__MYCOMPANY_NAME__'=>$mysoc->name,
794 '__KEYWORDS__'=>$modulename,
795 '__USER_FULLNAME__'=>$user->getFullName($langs),
796 '__USER_EMAIL__'=>$user->email,
798 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
804 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
805 $destdir = $dirins.
'/'.strtolower($module);
807 foreach ($objects as $path=>$obj) {
812 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
816 $FILENAMEDOC = $modulelowercase.
'.html';
817 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
818 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
819 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
820 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
821 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
826 $langs->load(
"errors");
827 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
833if ($dirins && $action ==
'addlanguage' && !empty($module)) {
834 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
837 $modulelowercase = strtolower($module);
842 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
844 $diroflang = $dolibarr_main_document_root;
846 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
847 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
849 $result =
dol_copy($srcfile, $destfile, 0, 0);
851 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
854 $srcdir = $diroflang.
'/langs/en_US';
855 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
856 $destdir = $diroflang.
'/langs/'.$newlangcode;
858 $arrayofreplacement = array();
860 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
861 $arrayofreplacement = array(
'mymodule'=>$modulelowercase);
863 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayofreplacement);
866 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
872if ($dirins && $action ==
'confirm_removefile' && !empty($module)) {
873 $objectname = $tabobj;
874 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
875 $destdir = $dirins.
'/'.strtolower($module);
880 if ($relativefilename) {
881 $dirnametodelete = dirname($relativefilename);
882 $filetodelete = $dirins.
'/'.$relativefilename;
883 $dirtodelete = $dirins.
'/'.$dirnametodelete;
886 if (strpos($relativefilename,
'api') !==
false) {
887 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
889 $var =
getFromFile($file_api,
'/*begin methods CRUD*/',
'/*end methods CRUD*/');
890 if (str_word_count($var) == 0) {
900 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
903 if (preg_match(
'/\.sql$/', $relativefilename)) {
904 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
905 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
906 $filetodelete = $dirins.
'/'.$relativefilename;
908 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
909 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
910 $filetodelete = $dirins.
'/'.$relativefilename;
920 if (in_array($tab, array(
'css',
'js'))) {
921 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
922 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
'=>'
926 if (preg_match(
'/_extrafields/', $relativefilename)) {
928 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
929 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
934 $varnametoupdate =
'';
936 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
937 $varnametoupdate =
'showtabofpage'.$reg[1];
939 if ($varnametoupdate) {
940 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
941 $arrayreplacement = array(
'/\$'.$varnametoupdate.
' = 1;/' =>
'$'.$varnametoupdate.
' = 0;');
949if ($dirins && $action ==
'initobject' && $module && $objectname) {
950 $objectname = ucfirst($objectname);
952 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
953 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
955 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
957 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
958 $tabobj =
'newobject';
960 if (class_exists($objectname)) {
963 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
964 $tabobj =
'newobject';
967 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
968 $destdir = $dirins.
'/'.strtolower($module);
979 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
980 $alreadyfound =
false;
981 foreach ($dirlist as $key => $val) {
982 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
983 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
984 $alreadyfound =
true;
986 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
993 $stringforproperties =
'';
994 $tablename =
GETPOST(
'initfromtablename',
'alpha');
996 $_results = $db->DDLDescTable($tablename);
997 if (empty($_results)) {
999 $langs->load(
"errors");
1000 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1049 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1050 $stringforproperties .=
'public $fields=array('.
"\n";
1052 while ($obj = $db->fetch_object($_results)) {
1054 $fieldname = $obj->Field;
1057 if ($type ==
'int(11)') {
1060 if ($type ==
'float') {
1063 if (strstr($type,
'tinyint')) {
1066 if ($obj->Field ==
'fk_soc') {
1067 $type =
'integer:Societe:societe/class/societe.class.php';
1069 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1070 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1072 if (preg_match(
'/^fk_prod/', $obj->Field)) {
1073 $type =
'integer:Product:product/class/product.class.php:1';
1075 if ($obj->Field ==
'fk_warehouse') {
1076 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1078 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1079 $type =
'integer:User:user/class/user.class.php';
1083 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1084 if ($fieldname ==
'fk_user_modif') {
1088 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1089 if ($fieldname ==
'rowid') {
1090 $label =
'TechnicalID';
1092 if ($fieldname ==
'import_key') {
1093 $label =
'ImportId';
1095 if ($fieldname ==
'fk_soc') {
1096 $label =
'ThirdParty';
1098 if ($fieldname ==
'tms') {
1099 $label =
'DateModification';
1101 if ($fieldname ==
'datec') {
1102 $label =
'DateCreation';
1104 if ($fieldname ==
'date_valid') {
1105 $label =
'DateValidation';
1107 if ($fieldname ==
'datev') {
1108 $label =
'DateValidation';
1110 if ($fieldname ==
'note_private') {
1111 $label =
'NotePublic';
1113 if ($fieldname ==
'note_public') {
1114 $label =
'NotePrivate';
1116 if ($fieldname ==
'fk_user_creat') {
1117 $label =
'UserAuthor';
1119 if ($fieldname ==
'fk_user_modif') {
1120 $label =
'UserModif';
1122 if ($fieldname ==
'fk_user_valid') {
1123 $label =
'UserValidation';
1127 if ($fieldname ==
'entity') {
1130 if ($fieldname ==
'import_key') {
1133 if ($fieldname ==
'fk_user_creat') {
1136 if ($fieldname ==
'fk_user_modif') {
1139 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1146 if ($fieldname ==
'entity') {
1151 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1154 if ($fieldname ==
'import_key') {
1158 if ($fieldname ==
'label') {
1159 $alwayseditable = 1;
1163 if ($fieldname ==
'entity') {
1170 if (preg_match(
'/^fk_/', $fieldname)) {
1171 $css =
'maxwidth500 widthcentpercentminusxx';
1173 if ($fieldname ==
'label') {
1174 $css =
'minwidth300';
1175 $cssview =
'wordbreak';
1177 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1178 $cssview =
'wordbreak';
1180 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1181 $csslist =
'tdoverflowmax150';
1185 $picto = $obj->Picto;
1186 if ($obj->Field ==
'fk_soc') {
1189 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1194 $stringforproperties .=
"'".$obj->Field.
"'=>array('type'=>'".$type.
"', 'label'=>'".$label.
"',";
1195 if ($default !=
'') {
1196 $stringforproperties .=
" 'default'=>".$default.
",";
1198 $stringforproperties .=
" 'enabled'=>".$enabled.
",";
1199 $stringforproperties .=
" 'visible'=>".$visible;
1201 $stringforproperties .=
", 'notnull'=>".$notnull;
1203 if ($alwayseditable) {
1204 $stringforproperties .=
", 'alwayseditable'=>1";
1206 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1207 $stringforproperties .=
", 'showoncombobox'=>1";
1209 $stringforproperties .=
", 'position'=>".$position;
1211 $stringforproperties .=
", 'index'=>".$index;
1214 $stringforproperties .=
", 'picto'=>'".$picto.
"'";
1217 $stringforproperties .=
", 'css'=>'".$css.
"'";
1220 $stringforproperties .=
", 'cssview'=>'".$cssview.
"'";
1223 $stringforproperties .=
", 'csslist'=>'".$csslist.
"'";
1225 $stringforproperties .=
"),\n";
1228 $stringforproperties .=
');'.
"\n";
1229 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1235 $filetogenerate = array(
1236 'myobject_card.php'=>strtolower($objectname).
'_card.php',
1237 'myobject_note.php'=>strtolower($objectname).
'_note.php',
1238 'myobject_contact.php'=>strtolower($objectname).
'_contact.php',
1239 'myobject_document.php'=>strtolower($objectname).
'_document.php',
1240 'myobject_agenda.php'=>strtolower($objectname).
'_agenda.php',
1241 'myobject_list.php'=>strtolower($objectname).
'_list.php',
1242 'admin/myobject_extrafields.php'=>
'admin/'.strtolower($objectname).
'_extrafields.php',
1243 'lib/mymodule_myobject.lib.php'=>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1245 'sql/llx_mymodule_myobject.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1246 'sql/llx_mymodule_myobject.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1247 'sql/llx_mymodule_myobject_extrafields.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1248 'sql/llx_mymodule_myobject_extrafields.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1250 'class/myobject.class.php'=>
'class/'.strtolower($objectname).
'.class.php',
1254 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1255 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1257 $filetogenerate += array(
1258 'core/modules/mymodule/mod_myobject_advanced.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1259 'core/modules/mymodule/mod_myobject_standard.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1260 'core/modules/mymodule/modules_myobject.php'=>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1263 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1264 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1265 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1267 $filetogenerate += array(
1268 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1269 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1272 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1273 $firstobjectname =
'myobject';
1274 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1276 $class =
'mod'.$module;
1277 if (class_exists($class)) {
1279 $moduleobj =
new $class($db);
1285 $rights = $moduleobj->rights;
1286 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1288 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1289 if ($generatePerms < 0) {
1290 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1296 foreach ($filetogenerate as $srcfile => $destfile) {
1297 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1301 $langs->load(
"errors");
1302 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1305 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1308 $arrayreplacement = array(
1309 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1310 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1317 if (!$error && $stringforproperties) {
1319 $arrayreplacement = array(
1320 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1323 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1327 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1329 $arrayreplacement = array(
1330 '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' =>
"'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"
1334 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1336 $arrayreplacement = array(
1337 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1339 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1343 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1345 $arrayreplacement = array(
1346 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1348 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1349 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'', 0, 0, 1);
1351 $arrayreplacement = array(
1352 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1355 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1362 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1364 $firstobjectname =
'';
1365 foreach ($listofobject as $fileobj) {
1366 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1369 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1373 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1375 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1376 $objectnameloop = $reg[1];
1377 if (empty($firstobjectname)) {
1378 $firstobjectname = $objectnameloop;
1384 \$this->menu[\$r++]=array(
1385 'fk_menu'=>'fk_mainmenu=mymodule',
1387 'titre'=>'MyObject',
1388 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1389 'mainmenu'=>'mymodule',
1390 'leftmenu'=>'myobject',
1391 'url'=>'/mymodule/myobject_list.php',
1392 'langs'=>'mymodule@mymodule',
1393 'position'=>1000+\$r,
1394 'enabled'=>'\$conf->testmodule->enabled',
1399 \$this->menu[\$r++]=array(
1400 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1402 'titre'=>'List MyObject',
1403 'mainmenu'=>'mymodule',
1404 'leftmenu'=>'mymodule_myobject_list',
1405 'url'=>'/mymodule/myobject_list.php',
1406 'langs'=>'mymodule@mymodule',
1407 'position'=>1000+\$r,
1408 'enabled'=>'\$conf->mymodule->enabled',
1413 \$this->menu[\$r++]=array(
1414 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1416 'titre'=>'New MyObject',
1417 'mainmenu'=>'mymodule',
1418 'leftmenu'=>'mymodule_myobject_new',
1419 'url'=>'/mymodule/myobject_card.php?action=create',
1420 'langs'=>'mymodule@mymodule',
1421 'position'=>1000+\$r,
1422 'enabled'=>'\$conf->mymodule->enabled',
1427 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1428 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1429 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1431 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1437 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1439 $class =
'mod'.$module;
1440 if (class_exists($class)) {
1442 $moduleobj =
new $class($db);
1448 $menus = $moduleobj->menu;
1450 foreach ($menus as $menu) {
1451 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1456 dolReplaceInFile($moduledescriptorfile, array(
'/* END MODULEBUILDER LEFTMENU MYOBJECT */' =>
'/*LEFTMENU '.strtoupper($objectname).
'*/'.$stringtoadd.
"\n\t\t".
'/*END LEFTMENU '.strtoupper($objectname).
'*/'.
"\n\t\t".
'/* END MODULEBUILDER LEFTMENU MYOBJECT */'));
1459 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1464 foreach ($filetogenerate as $destfile) {
1465 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1468 $arrayreplacement = array(
1469 'mymodule'=>strtolower($module),
1470 'MyModule'=>$module,
1471 'MYMODULE'=>strtoupper($module),
1472 'My module'=>$module,
1473 'my module'=>$module,
1474 'mon module'=>$module,
1475 'Mon module'=>$module,
1476 'htdocs/modulebuilder/template/'=>strtolower($modulename),
1477 'myobject'=>strtolower($objectname),
1478 'MyObject'=>$objectname,
1480 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
1483 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
1484 $arrayreplacement[
'Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
1486 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
1487 $arrayreplacement[
'https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
1489 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
1490 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
1492 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
1493 $arrayreplacement[
'1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
1495 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
1496 $arrayreplacement[
'other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
1502 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1511 if (is_numeric($object) && $object <= 0) {
1512 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1513 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1517 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1518 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1520 if (file_exists($destfile)) {
1526 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1535 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1536 $tabobj = $objectname;
1538 $tabobj =
'newobject';
1542 if (isModEnabled(strtolower($module))) {
1544 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
1548 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
1549 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1555if ($dirins && $action ==
'initdic' && $module && $dicname) {
1557 $newdicname = $dicname;
1558 if (!preg_match(
'/^c_/', $newdicname)) {
1559 $newdicname =
'c_'.$dicname;
1569if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj)) {
1570 $objectname = $tabobj;
1572 $arrayoftables = array();
1573 if ($action ==
'droptable') {
1574 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1576 if ($action ==
'droptableextrafields') {
1577 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1580 foreach ($arrayoftables as $tabletodrop) {
1582 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1583 $resql = $db->query($sql);
1585 $obj = $db->fetch_object($resql);
1590 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1591 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1597 $resql = $db->DDLDropTable($tabletodrop);
1599 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1600 } elseif ($nb > 0) {
1601 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1606if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && !empty($tabobj)) {
1609 $objectname = $tabobj;
1611 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1612 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1614 $srcdir = $dirread.
'/'.strtolower($module);
1615 $destdir = $dirins.
'/'.strtolower($module);
1619 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1620 if (!
GETPOST(
'propname',
'aZ09')) {
1622 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1624 if (!
GETPOST(
'proplabel',
'alpha')) {
1626 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1628 if (!
GETPOST(
'proptype',
'alpha')) {
1630 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1633 if (!$error && !
GETPOST(
'regenerateclasssql')&& !
GETPOST(
'regeneratemissing')) {
1634 $addfieldentry = array(
1635 'name'=>
GETPOST(
'propname',
'aZ09'),
1636 'label'=>
GETPOST(
'proplabel',
'alpha'),
1637 'type'=>
GETPOST(
'proptype',
'alpha'),
1638 'arrayofkeyval'=>
GETPOST(
'proparrayofkeyval',
'restricthtml'),
1639 'visible'=>
GETPOST(
'propvisible',
'int'),
1640 'enabled'=>
GETPOST(
'propenabled',
'int'),
1641 'position'=>
GETPOST(
'propposition',
'int'),
1642 'notnull'=>
GETPOST(
'propnotnull',
'int'),
1643 'index'=>
GETPOST(
'propindex',
'int'),
1644 'foreignkey'=>
GETPOST(
'propforeignkey',
'alpha'),
1645 'searchall'=>
GETPOST(
'propsearchall',
'int'),
1646 'isameasure'=>
GETPOST(
'propisameasure',
'int'),
1647 'comment'=>
GETPOST(
'propcomment',
'alpha'),
1648 'help'=>
GETPOST(
'prophelp',
'alpha'),
1649 'css'=>
GETPOST(
'propcss',
'alpha'),
1650 'cssview'=>
GETPOST(
'propcssview',
'alpha'),
1651 'csslist'=>
GETPOST(
'propcsslist',
'alpha'),
1652 'default'=>
GETPOST(
'propdefault',
'restricthtml'),
1653 'noteditable'=>intval(
GETPOST(
'propnoteditable',
'int')),
1654 'alwayseditable'=>intval(
GETPOST(
'propalwayseditable',
'int')),
1655 'validate' =>
GETPOST(
'propvalidate',
'int')
1659 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1660 $addfieldentry[
'arrayofkeyval'] = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1664 $addfieldentry = array();
1673 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1677 $object =
rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry, $moduletype);
1679 if (is_numeric($object) && $object <= 0) {
1680 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1681 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1688 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1691 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1697 clearstatcache(
true);
1699 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1704 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1710if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey) {
1711 $objectname = $tabobj;
1713 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1714 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1716 $srcdir = $dirread.
'/'.strtolower($module);
1717 $destdir = $dirins.
'/'.strtolower($module);
1722 $object =
rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey);
1724 if (is_numeric($object) && $object <= 0) {
1725 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1726 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1733 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1736 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1742 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1744 clearstatcache(
true);
1747 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1753if ($dirins && $action ==
'confirm_deletemodule') {
1754 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1756 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1760 $modulelowercase = strtolower($module);
1763 $dir = $dirins.
'/'.$modulelowercase;
1765 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1775 $class =
'mod'.$module;
1777 if (class_exists($class)) {
1779 $moduleobj =
new $class($db);
1786 $langs->load(
"errors");
1787 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1791 $moduleobj->remove();
1798 clearstatcache(
true);
1799 if (function_exists(
'opcache_invalidate')) {
1803 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
1811 $module =
'deletemodule';
1814if ($dirins && $action ==
'confirm_deleteobject' && $objectname) {
1815 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1817 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1821 $modulelowercase = strtolower($module);
1822 $objectlowercase = strtolower($objectname);
1825 $dir = $dirins.
'/'.$modulelowercase;
1828 $filetodelete = array(
1829 'myobject_card.php'=>strtolower($objectname).
'_card.php',
1830 'myobject_note.php'=>strtolower($objectname).
'_note.php',
1831 'myobject_contact.php'=>strtolower($objectname).
'_contact.php',
1832 'myobject_document.php'=>strtolower($objectname).
'_document.php',
1833 'myobject_agenda.php'=>strtolower($objectname).
'_agenda.php',
1834 'myobject_list.php'=>strtolower($objectname).
'_list.php',
1835 'admin/myobject_extrafields.php'=>
'admin/'.strtolower($objectname).
'_extrafields.php',
1836 'lib/mymodule_myobject.lib.php'=>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1837 'test/phpunit/MyObjectTest.php'=>
'test/phpunit/'.strtolower($objectname).
'Test.php',
1838 'sql/llx_mymodule_myobject.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1839 'sql/llx_mymodule_myobject_extrafields.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1840 'sql/llx_mymodule_myobject.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1841 'sql/llx_mymodule_myobject_extrafields.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1842 'scripts/myobject.php'=>
'scripts/'.strtolower($objectname).
'.php',
1843 'class/myobject.class.php'=>
'class/'.strtolower($objectname).
'.class.php',
1844 'class/api_myobject.class.php'=>
'class/api_'.strtolower($module).
'.class.php',
1845 'core/modules/mymodule/mod_myobject_advanced.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1846 'core/modules/mymodule/mod_myobject_standard.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1847 'core/modules/mymodule/modules_myobject.php'=>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1848 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1849 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1854 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1856 $class =
'mod'.$module;
1857 if (class_exists($class)) {
1859 $moduleobj =
new $class($db);
1865 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1868 $menus = $moduleobj->menu;
1869 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
1872 $permissions = $moduleobj->rights;
1876 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
1879 clearstatcache(
true);
1880 if (function_exists(
'opcache_invalidate')) {
1884 foreach ($filetodelete as $tmpfiletodelete) {
1886 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
1892 if ($resultko == 0) {
1895 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
1900 $tabobj =
'deleteobject';
1903 if (isModEnabled(strtolower($module))) {
1905 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
1909 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
1910 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1915if ($dirins && $action ==
'generatedoc') {
1916 $modulelowercase = strtolower($module);
1921 $FILENAMEDOC = strtolower($module).
'.html';
1923 $util =
new Utils($db);
1924 $result = $util->generateDoc($module);
1927 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
1933if ($dirins && $action ==
'generatepackage') {
1934 $modulelowercase = strtolower($module);
1936 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1946 $class =
'mod'.$module;
1948 if (class_exists($class)) {
1950 $moduleobj =
new $class($db);
1957 $langs->load(
"errors");
1958 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1962 $arrayversion = explode(
'.', $moduleobj->version, 3);
1963 if (count($arrayversion)) {
1964 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
1967 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
1973 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
1979 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
1982 $langs->load(
"errors");
1983 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
1987 $langs->load(
"errors");
1988 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
1993if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel)) {
1997 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1999 $class =
'mod'.$module;
2000 if (class_exists($class)) {
2002 $moduleobj =
new $class($db);
2010 if (!
GETPOST(
'label',
'alpha')) {
2012 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2014 if (!
GETPOST(
'permissionObj',
'alpha')) {
2016 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2020 $label =
GETPOST(
'label',
'alpha');
2021 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2022 $crud =
GETPOST(
'crud',
'alpha');
2026 $permsForObject =array();
2027 $permissions = $moduleobj->rights;
2028 $allObject = array();
2030 $countPerms = count($permissions);
2032 for ($i =0; $i<$countPerms; $i++) {
2033 if ($permissions[$i][4] == $objectForPerms) {
2035 if (count($permsForObject) < 3) {
2036 $permsForObject[] = $permissions[$i];
2039 $allObject[] = $permissions[$i][4];
2043 $countPermsObj = count($permsForObject);
2044 for ($j = 0; $j<$countPermsObj; $j++) {
2045 if (in_array($crud, $permsForObject[$j])) {
2047 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2052 $key = $countPerms + 1;
2061 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2066 if (isModEnabled(strtolower($module))) {
2068 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2072 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2076 clearstatcache(
true);
2077 if (function_exists(
'opcache_invalidate')) {
2081 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2087if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright')&& empty($cancel)) {
2090 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2092 $class =
'mod'.$module;
2093 if (class_exists($class)) {
2095 $moduleobj =
new $class($db);
2102 if (!
GETPOST(
'label',
'alpha')) {
2104 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2106 if (!
GETPOST(
'permissionObj',
'alpha')) {
2108 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2111 $label =
GETPOST(
'label',
'alpha');
2112 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2113 $crud =
GETPOST(
'crud',
'alpha');
2116 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2118 $label ==
"Read objects of $module";
2120 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2122 $label ==
"Create/Update objects of $module";
2124 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2126 $label ==
"Delete objects of $module";
2129 $permissions = $moduleobj->rights;
2130 $key =(int)
GETPOST(
'counter')-1;
2132 $x1 = $permissions[$key][1];
2133 $x2 = $permissions[$key][4];
2134 $x3 = $permissions[$key][5];
2137 $permsForObject =array();
2138 $permissions = $moduleobj->rights;
2141 $allObject = array();
2143 $countPerms = count($permissions);
2144 for ($i =0; $i<$countPerms; $i++) {
2145 if ($permissions[$i][4] == $objectForPerms) {
2147 if (count($permsForObject) < 3) {
2148 $permsForObject[] = $permissions[$i];
2151 $allObject[] = $permissions[$i][4];
2154 if ($label != $x1 && $crud != $x3) {
2155 $countPermsObj = count($permsForObject);
2156 for ($j = 0; $j<$countPermsObj; $j++) {
2157 if (in_array($label, $permsForObject[$j])) {
2159 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2165 if (isModEnabled(strtolower($module))) {
2167 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2171 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2174 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2180 clearstatcache(
true);
2181 if (function_exists(
'opcache_invalidate')) {
2185 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2190if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOST(
'permskey',
'int')) {
2193 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2195 $class =
'mod'.$module;
2196 if (class_exists($class)) {
2198 $moduleobj =
new $class($db);
2205 $permissions = $moduleobj->rights;
2206 $key = (int)
GETPOST(
'permskey',
'int')-1;
2209 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2215 if (isModEnabled(strtolower($module))) {
2217 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2222 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2224 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2229 clearstatcache(
true);
2230 if (function_exists(
'opcache_invalidate')) {
2234 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2240if ($action ==
'savefile' && empty($cancel)) {
2241 $relofcustom = basename($dirins);
2245 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2246 $file = $relofcustom.
'/'.$file;
2254 dol_copy($pathoffile, $pathoffilebackup, 0, 1);
2257 $check =
'restricthtml';
2259 if ($srclang ==
'md') {
2260 $check =
'restricthtml';
2262 if ($srclang ==
'lang') {
2263 $check =
'restricthtml';
2265 if ($srclang ==
'php') {
2269 $content =
GETPOST(
'editfilecontent', $check);
2274 $result = file_put_contents($pathoffile, $content);
2291if ($action ==
'set' && $user->admin) {
2294 $param .=
'&module='.urlencode($module);
2297 $param .=
'&tab='.urlencode($tab);
2300 $param .=
'&tabobj='.urlencode($tabobj);
2303 $value =
GETPOST(
'value',
'alpha');
2305 if (!empty($resarray[
'errors'])) {
2309 if ($resarray[
'nbperms'] > 0) {
2310 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2311 $resqltmp = $db->query($tmpsql);
2313 $obj = $db->fetch_object($resqltmp);
2315 if ($obj && $obj->nb > 1) {
2316 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2324 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2329if ($action ==
'reset' && $user->admin) {
2332 $param .=
'&module='.urlencode($module);
2335 $param .=
'&tab='.urlencode($tab);
2338 $param .=
'&tabobj='.urlencode($tabobj);
2341 $value =
GETPOST(
'value',
'alpha');
2346 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2351if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOST(
'menukey',
'int')) {
2353 if (isModEnabled(strtolower($module))) {
2355 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2359 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2360 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2363 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2365 $class =
'mod'.$module;
2366 if (class_exists($class)) {
2368 $moduleobj =
new $class($db);
2375 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2376 $destdir = $dir.
'/'.strtolower($module);
2378 $result = array_map(
'strtolower', $objects);
2380 $menus = $moduleobj->menu;
2381 $key = (int)
GETPOST(
'menukey',
'int');
2382 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2384 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2385 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2386 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2394 clearstatcache(
true);
2395 if (function_exists(
'opcache_invalidate')) {
2400 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2405if ($dirins && $action ==
'addmenu' && empty($cancel)) {
2407 if (isModEnabled(strtolower($module))) {
2409 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2413 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2414 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2419 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2421 $class =
'mod'.$module;
2422 if (class_exists($class)) {
2424 $moduleobj =
new $class($db);
2431 $menus = $moduleobj->menu;
2434 if (!
GETPOST(
'type',
'alpha')) {
2436 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2438 if (!
GETPOST(
'titre',
'alpha')) {
2440 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2442 if (!
GETPOST(
'user',
'alpha')) {
2444 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2446 if (!
GETPOST(
'url',
'alpha')) {
2448 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2450 if (!empty(
GETPOST(
'target'))) {
2451 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2452 if (!in_array(
GETPOST(
'target'), $targets)) {
2454 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2461 foreach ($menus as $menu) {
2464 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2467 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2469 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2474 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2475 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2477 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"leftmenu")),
null,
'errors');
2480 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2481 $destdir = $dirins.
'/'.strtolower($module);
2484 if (
GETPOST(
'type',
'alpha') ==
'left') {
2485 if (empty(
GETPOST(
'leftmenu')) && count($objects) >0) {
2487 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"leftmenu"), $langs->transnoentities(
"type")),
null,
'errors');
2490 if (
GETPOST(
'type',
'alpha') ==
'top') {
2492 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2495 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2499 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2500 'type' =>
GETPOST(
'type',
'alpha'),
2501 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2503 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2504 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2505 'url' =>
GETPOST(
'url',
'alpha'),
2506 'langs' => strtolower($module).
"@".strtolower($module),
2508 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2509 'perms' =>
GETPOST(
'perms',
'alpha'),
2510 'target' =>
GETPOST(
'target',
'alpha'),
2511 'user' =>
GETPOST(
'user',
'alpha'),
2513 if (
GETPOST(
'type') ==
'left') {
2514 unset($menuToAdd[
'prefix']);
2515 if (empty(
GETPOST(
'fk_menu'))) {
2516 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2518 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2521 if (
GETPOST(
'enabled') ==
'1') {
2522 $menuToAdd[
'enabled'] =
"\$conf->".strtolower($module).
"->enabled";
2524 $menuToAdd[
'enabled'] =
"0";
2526 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2528 clearstatcache(
true);
2529 if (function_exists(
'opcache_invalidate')) {
2532 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2539if ($dirins && $action ==
"modify_menu" &&
GETPOST(
'menukey',
'int')) {
2540 if (empty($cancel)) {
2541 if (isModEnabled(strtolower($module))) {
2543 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2547 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2548 setEventMessages($langs->trans(
'WarningModuleNeedRefrech', $langs->transnoentities($module)),
null,
'warnings');
2552 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2554 $class =
'mod'.$module;
2555 if (class_exists($class)) {
2557 $moduleobj =
new $class($db);
2563 $menus = $moduleobj->menu;
2564 $key = (int)
GETPOST(
'menukey',
'int') - 1;
2566 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2568 $menuModify = array(
2569 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2570 'type' =>
GETPOST(
'type',
'alpha'),
2571 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2572 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2573 'leftmenu' => $menus[$key][
'leftmenu'],
2574 'url' =>
GETPOST(
'url',
'alpha'),
2575 'langs' => strtolower($module).
"@".strtolower($module),
2577 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2578 'perms' =>
GETPOST(
'perms',
'alpha'),
2579 'target' =>
GETPOST(
'target',
'alpha'),
2580 'user' =>
GETPOST(
'user',
'alpha'),
2582 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
2583 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2584 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
2585 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
2587 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
2589 if (
GETPOST(
'enabled') !=
'0') {
2590 $menuModify[
'enabled'] =
"\$conf->".strtolower($module).
"->enabled";
2592 $menuModify[
'enabled'] =
"0";
2595 if (
GETPOST(
'type',
'alpha') ==
'top') {
2597 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2601 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
2603 clearstatcache(
true);
2604 if (function_exists(
'opcache_invalidate')) {
2609 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?action=editmenu&token='.newToken().
'&menukey='.urlencode($key+1).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.($key+1));
2613 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2617 $_POST[
'type'] =
'';
2618 $_POST[
'titre'] =
'';
2619 $_POST[
'fk_menu'] =
'';
2620 $_POST[
'leftmenu'] =
'';
2629$form =
new Form($db);
2640 '/includes/ace/src/ace.js',
2641 '/includes/ace/src/ext-statusbar.js',
2642 '/includes/ace/src/ext-language_tools.js',
2647llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
2650$text = $langs->trans(
"ModuleBuilder");
2654print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
2655print
'<br class="hideonsmartphone">';
2664 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
2669 $langs->load(
"errors");
2670 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
2674 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
2683$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
2687$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2688$allowonlineinstall =
true;
2689if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2690 $allowonlineinstall =
false;
2692if (empty($allowonlineinstall)) {
2695 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
2698 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0, 1,
'warning');
2713if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
2714 $modulelowercase = strtolower($module);
2715 $loadclasserrormessage =
'';
2719 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2724 $class =
'mod'.$module;
2725 }
catch (Throwable $e) {
2726 $loadclasserrormessage = $e->getMessage().
"<br>\n";
2727 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
2728 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
2731 if (class_exists($class)) {
2733 $moduleobj =
new $class($db);
2736 print $e->getMessage();
2739 if (empty($forceddirread)) {
2742 $langs->load(
"errors");
2743 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
2744 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
2745 print $loadclasserrormessage;
2756$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
2757$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
2758$head[$h][2] =
'initmodule';
2761$linktoenabledisable =
'';
2763if (is_array($listofmodules) && count($listofmodules) > 0) {
2765 $modulelowercase = strtolower($module);
2766 $const_name =
'MAIN_MODULE_'.strtoupper($module);
2770 $param .=
'&tab='.urlencode($tab);
2773 $param .=
'&module='.urlencode($module);
2776 $param .=
'&tabobj='.urlencode($tabobj);
2779 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
2782 if (isModEnabled($modulelowercase)) {
2783 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=reset&token='.newToken().
'&value=mod'.$module.$param.
'">';
2784 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'',
false, 0, 0,
'',
'', 1);
2785 $linktoenabledisable .=
'</a>';
2787 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
2789 $objMod = $moduleobj;
2790 $backtourlparam =
'';
2791 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
2793 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
2795 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
2798 if (is_array($objMod->config_page_url)) {
2800 foreach ($objMod->config_page_url as $page) {
2803 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
2806 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
2807 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
2808 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
2812 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
2813 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
2817 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
2818 $linktoenabledisable .=
' <a href="'.dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1).
'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
2821 if (!empty($moduleobj)) {
2822 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=set&token='.newToken().
'&value=mod'.$module.$param.
'">';
2823 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"',
false, 0, 0,
'',
'classfortooltip', 1);
2824 $linktoenabledisable .=
"</a>\n";
2829 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
2830 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
2831 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
2832 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
2834 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
2835 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
2842$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
2843$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
2844$head[$h][2] =
'deletemodule';
2850if ($module ==
'initmodule') {
2852 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2853 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2854 print
'<input type="hidden" name="action" value="initmodule">';
2855 print
'<input type="hidden" name="module" value="initmodule">';
2860 print
'<div class="tagtable">';
2862 print
'<div class="tagtr"><div class="tagtd paddingright">';
2863 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
2864 print
'</div><div class="tagtd">';
2865 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
2866 print
'<span class="opacitymedium">';
2868 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
2870 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
2873 print
'</div></div>';
2875 print
'<div class="tagtr"><div class="tagtd paddingright">';
2876 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
2877 print
'</div><div class="tagtd">';
2878 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
2879 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
2880 print
'</div></div>';
2882 print
'<div class="tagtr"><div class="tagtd paddingright">';
2883 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
2884 print
'</div><div class="tagtd">';
2885 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
2886 print
'</div></div>';
2888 print
'<div class="tagtr"><div class="tagtd paddingright">';
2889 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
2890 print
'</div><div class="tagtd">';
2891 print
'<input type="text" name="version" class="width75" value="'.(GETPOSTISSET(
'version') ?
GETPOST(
'version') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_VERSION',
'1.0')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Version")).
'">';
2892 print
'</div></div>';
2894 print
'<div class="tagtr"><div class="tagtd paddingright">';
2895 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
2896 print
'</div><div class="tagtd">';
2897 print
'<select name="family" id="family" class="minwidth400">';
2898 $arrayoffamilies = array(
2899 'hr' =>
"ModuleFamilyHr",
2900 'crm' =>
"ModuleFamilyCrm",
2901 'srm' =>
"ModuleFamilySrm",
2902 'financial' =>
'ModuleFamilyFinancial',
2903 'products' =>
'ModuleFamilyProducts',
2904 'projects' =>
'ModuleFamilyProjects',
2905 'ecm' =>
'ModuleFamilyECM',
2906 'technic' =>
'ModuleFamilyTechnic',
2907 'portal' =>
'ModuleFamilyPortal',
2908 'interface' =>
'ModuleFamilyInterface',
2909 'base' =>
'ModuleFamilyBase',
2910 'other' =>
'ModuleFamilyOther'
2912 foreach ($arrayoffamilies as $key => $value) {
2913 print
'<option value="hr"'.($key ==
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_FAMILY',
'other') ?
' selected="selected"' :
'').
' data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
2917 print
'</div></div>';
2919 print
'<div class="tagtr"><div class="tagtd paddingright">';
2920 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
2921 print
'</div><div class="tagtd">';
2922 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file-o')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
2923 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
2924 print
'</div></div>';
2926 print
'<div class="tagtr"><div class="tagtd paddingright">';
2927 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
2928 print
'</div><div class="tagtd">';
2929 print
'<input type="text" name="editorname" value="'.(GETPOSTISSET(
'editorname') ?
GETPOST(
'editorname') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_NAME', $mysoc->
name)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorName")).
'"><br>';
2930 print
'</div></div>';
2932 print
'<div class="tagtr"><div class="tagtd paddingright">';
2933 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
2934 print
'</div><div class="tagtd">';
2935 print
'<input type="text" name="editorurl" value="'.(GETPOSTISSET(
'editorurl') ?
GETPOST(
'editorurl') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_URL', $mysoc->url)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorUrl")).
'"><br>';
2936 print
'</div></div>';
2938 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
2940} elseif ($module ==
'deletemodule') {
2941 print
'<!-- Form to init a module -->'.
"\n";
2942 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
2943 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2944 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
2945 print
'<input type="hidden" name="module" value="deletemodule">';
2947 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
2949 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="">';
2950 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
2952} elseif (!empty($module)) {
2955 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2960 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2961 $head2[$h][1] = $langs->trans(
"Description");
2962 $head2[$h][2] =
'description';
2965 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2966 $head2[$h][1] = $langs->trans(
"Objects");
2967 $head2[$h][2] =
'objects';
2970 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2971 $head2[$h][1] = $langs->trans(
"Languages");
2972 $head2[$h][2] =
'languages';
2975 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2976 $head2[$h][1] = $langs->trans(
"Dictionaries");
2977 $head2[$h][2] =
'dictionaries';
2980 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2981 $head2[$h][1] = $langs->trans(
"Permissions");
2982 $head2[$h][2] =
'permissions';
2985 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2986 $head2[$h][1] = $langs->trans(
"Tabs");
2987 $head2[$h][2] =
'tabs';
2990 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2991 $head2[$h][1] = $langs->trans(
"Menus");
2992 $head2[$h][2] =
'menus';
2995 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
2996 $head2[$h][1] = $langs->trans(
"Hooks");
2997 $head2[$h][2] =
'hooks';
3000 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3001 $head2[$h][1] = $langs->trans(
"Triggers");
3002 $head2[$h][2] =
'triggers';
3005 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3006 $head2[$h][1] = $langs->trans(
"Widgets");
3007 $head2[$h][2] =
'widgets';
3010 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3011 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3012 $head2[$h][2] =
'exportimport';
3015 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3016 $head2[$h][1] = $langs->trans(
"CSS");
3017 $head2[$h][2] =
'css';
3020 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3021 $head2[$h][1] = $langs->trans(
"JS");
3022 $head2[$h][2] =
'js';
3025 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3026 $head2[$h][1] = $langs->trans(
"CLI");
3027 $head2[$h][2] =
'cli';
3030 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3031 $head2[$h][1] = $langs->trans(
"CronList");
3032 $head2[$h][2] =
'cron';
3035 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3036 $head2[$h][1] = $langs->trans(
"Documentation");
3037 $head2[$h][2] =
'specifications';
3040 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3041 $head2[$h][1] = $langs->trans(
"BuildPackage");
3042 $head2[$h][2] =
'buildpackage';
3045 $MAXTABFOROBJECT = 15;
3047 print
'<!-- Section for a given module -->';
3051 if ($tab ==
'description') {
3052 print
'<!-- tab=description -->'.
"\n";
3053 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3054 $pathtofilereadme = $modulelowercase.
'/README.md';
3055 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3057 if ($action !=
'editfile' || empty($file)) {
3058 $morehtmlright =
'';
3059 if (realpath($dirread.
'/'.$modulelowercase) != $dirread.
'/'.$modulelowercase) {
3060 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.realpath($dirread.
'/'.$modulelowercase).
'</strong>').
'</div>';
3063 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3065 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3071 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3072 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3075 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3076 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=markdown&file='.urlencode($pathtofilereadme).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3079 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3080 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=markdown&file='.urlencode($pathtochangelog).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3086 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3088 if (!empty($moduleobj)) {
3089 print
'<div class="underbanner clearboth"></div>';
3090 print
'<div class="fichecenter">';
3092 print
'<table class="border centpercent">';
3093 print
'<tr class="liste_titre"><td class="titlefield">';
3094 print $langs->trans(
"Parameter");
3096 print $langs->trans(
"Value");
3100 print $langs->trans(
"IdModule");
3102 print $moduleobj->numero;
3103 print
'<span class="opacitymedium">';
3105 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3106 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3111 print $langs->trans(
"ModuleName");
3113 print $moduleobj->getName();
3117 print $langs->trans(
"Description");
3119 print $moduleobj->getDesc();
3123 print $langs->trans(
"Version");
3125 print $moduleobj->getVersion();
3129 print $langs->trans(
"Family");
3132 print $moduleobj->family;
3136 print $langs->trans(
"Picto");
3138 print $moduleobj->picto;
3139 print
' '.img_picto(
'', $moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3143 print $langs->trans(
"EditorName");
3145 print $moduleobj->editor_name;
3149 print $langs->trans(
"EditorUrl");
3151 if (!empty($moduleobj->editor_url)) {
3152 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3158 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3161 if (!empty($moduleobj)) {
3165 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3167 print
'<!-- readme file -->';
3168 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3169 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3171 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3177 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3179 print
'<!-- changelog file -->';
3181 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3183 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3191 if ($fullpathoffile) {
3192 $content = file_get_contents($fullpathoffile);
3196 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3197 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3198 print
'<input type="hidden" name="action" value="savefile">';
3199 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3200 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3201 print
'<input type="hidden" name="module" value="'.$module.
'">';
3205 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%',
'');
3206 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3211 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3213 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3219 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3222 if ($tab ==
'languages') {
3223 print
'<!-- tab=languages -->'.
"\n";
3224 if ($action !=
'editfile' || empty($file)) {
3225 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3229 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3230 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3231 print
'<input type="hidden" name="action" value="addlanguage">';
3232 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3233 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3234 print
'<input type="hidden" name="module" value="'.$module.
'">';
3235 print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,
'newlangcode', 0, 0, 1, 0, 0,
'minwidth300', 1);
3236 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3242 $modulelowercase = strtolower($module);
3246 $diroflang .=
'/langs';
3247 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3249 if (!preg_match(
'/custom/', $dirread)) {
3251 $diroflang = $dirread;
3252 $diroflang .=
'/langs';
3253 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3256 print
'<table class="none">';
3257 foreach ($langfiles as $langfile) {
3258 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3259 if (!preg_match(
'/custom/', $dirread)) {
3260 $pathtofile =
'langs/'.$langfile[
'relativename'];
3262 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3263 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=ini&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3264 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3275 $content = file_get_contents($fullpathoffile);
3278 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3280 print
'<input type="hidden" name="action" value="savefile">';
3281 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3282 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3283 print
'<input type="hidden" name="module" value="'.$module.
'">';
3285 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3286 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3289 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3291 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3298 if ($tab ==
'objects') {
3299 print
'<!-- tab=objects -->'.
"\n";
3304 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3306 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3307 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3308 $head3[$h][2] =
'newobject';
3312 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3314 $firstobjectname =
'';
3315 foreach ($listofobject as $fileobj) {
3316 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3319 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3323 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3324 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3326 $objectname = $reg[1];
3327 if (empty($firstobjectname)) {
3328 $firstobjectname = $objectname;
3330 $pictoname =
'generic';
3331 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3332 $pictoname = $reg[1];
3335 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3336 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3337 $head3[$h][2] = $objectname;
3343 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
3344 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3345 $head3[$h][2] =
'deleteobject';
3350 if ($tabobj ==
'newobjectifnoobj') {
3351 if ($firstobjectname) {
3352 $tabobj = $firstobjectname;
3354 $tabobj =
'newobject';
3358 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
3360 if ($tabobj ==
'newobject') {
3362 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3363 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3364 print
'<input type="hidden" name="action" value="initobject">';
3365 print
'<input type="hidden" name="tab" value="objects">';
3366 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3368 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
3370 print
'<div class="tagtable">';
3372 print
'<div class="tagtr"><div class="tagtd">';
3373 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
3374 print
'</div><div class="tagtd">';
3375 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(
GETPOST(
'objectname',
'alpha') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus><br>';
3376 print
'</div></div>';
3378 print
'<div class="tagtr"><div class="tagtd">';
3379 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
3380 print
'</div><div class="tagtd">';
3381 print
'<input type="text" name="idpicto" value="fa-file-o" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3382 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3383 print
'</div></div>';
3385 print
'<div class="tagtr"><div class="tagtd">';
3386 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
3387 print
'</div><div class="tagtd">';
3388 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
3389 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
3390 print
'</div></div>';
3395 print
'<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label class="margintoponly" for="includerefgeneration">'.$form->textwithpicto($langs->trans(
"IncludeRefGeneration"), $langs->trans(
"IncludeRefGenerationHelp")).
'</label><br>';
3396 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
3397 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
3399 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3415 } elseif ($tabobj ==
'deleteobject') {
3417 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3418 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3419 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
3420 print
'<input type="hidden" name="tab" value="objects">';
3421 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3423 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
3425 print
'<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ObjectKey")).
'">';
3426 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3430 if ($action ==
'deleteproperty') {
3431 $formconfirm = $form->formconfirm(
3432 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
3433 $langs->trans(
'Delete'),
3434 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
3435 'confirm_deleteproperty',
3445 if ($action !=
'editfile' || empty($file)) {
3449 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
3450 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
3451 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
3452 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
3453 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
3454 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
3455 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
3456 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
3457 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
3460 clearstatcache(
true);
3461 if (function_exists(
'opcache_invalidate')) {
3462 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
3465 if (empty($forceddirread) && empty($dirread)) {
3467 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
3469 $result = @include_once $dirread.
'/'.$pathtoclass;
3470 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
3472 if (class_exists($tabobj)) {
3474 $tmpobject = @
new $tabobj($db);
3476 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
3479 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
3483 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
3486 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
3489 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
3492 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
3495 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
3496 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
3499 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
3502 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
3505 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
3508 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
3510 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
3512 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
3513 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
3515 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
3516 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
3518 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
3519 $pathtopicto = $tmpobject->picto;
3520 $realpathtopicto =
'';
3522 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
3523 $realpathtopicto = $dirread.
'/'.$pathtopicto;
3528 $realpathtoclass = $dirread.
'/'.$pathtoclass;
3529 $realpathtoapi = $dirread.
'/'.$pathtoapi;
3530 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
3531 $realpathtocard = $dirread.
'/'.$pathtocard;
3532 $realpathtodocument = $dirread.
'/'.$pathtodocument;
3533 $realpathtolist = $dirread.
'/'.$pathtolist;
3534 $realpathtonote = $dirread.
'/'.$pathtonote;
3535 $realpathtocontact = $dirread.
'/'.$pathtocontact;
3536 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
3537 $realpathtosql = $dirread.
'/'.$pathtosql;
3538 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
3539 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
3540 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
3541 $realpathtolib = $dirread.
'/'.$pathtolib;
3542 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
3544 if (empty($realpathtoapi)) {
3545 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
3546 $realpathtoapi = $dirread.
'/'.$pathtoapi;
3554 print
'<!-- section for object -->';
3555 print
'<div class="fichehalfleft smallxxx">';
3557 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ClassFile").
' : <strong>'.(
dol_is_file($realpathtoclass) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoclass).(
dol_is_file($realpathtoclass) ?
'' :
'</strike>').
'</strong>';
3558 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtoclass).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3561 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
3562 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.(
dol_is_file($realpathtopicto) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtopicto).(
dol_is_file($realpathtopicto) ?
'' :
'</strike>').
'</strong>';
3565 } elseif (!empty($tmpobject)) {
3566 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
3572 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ApiClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoapi) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoapi).(
dol_is_file($realpathtoapi)?
'':
'</span></strike>').
'</strong>';
3574 $file = file_get_contents($realpathtoapi);
3575 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
3576 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3578 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3580 if (empty($conf->global->$const_name)) {
3581 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
3583 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
3586 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initapi&token='.newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto(
'AddAPIsForThisObject',
'generate',
'class="paddingleft"').
'</a>';
3589 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initapi&token='.newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3593 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TestClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtophpunit) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtophpunit).(
dol_is_file($realpathtophpunit)?
'':
'</span></strike>').
'</strong>';
3595 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3597 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3599 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initphpunit&token='.newToken().
'&format=php&file='.urlencode($pathtophpunit).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3605 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtolib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtolib).(
dol_is_file($realpathtolib) ?
'' :
'</strike>').
'</strong>';
3606 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtolib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3608 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForObjLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoobjlib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoobjlib).(
dol_is_file($realpathtoobjlib) ?
'' :
'</strike>').
'</strong>';
3609 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtoobjlib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3613 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosql) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosql).(
dol_is_file($realpathtosql) ?
'' :
'</strike>').
'</strong>';
3614 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=sql&file='.urlencode($pathtosql).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3615 print
' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptable&token='.newToken().
'">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
3618 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKey").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlkey) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlkey).(
dol_is_file($realpathtosqlkey) ?
'' :
'</strike>').
'</strong>';
3619 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=sql&file='.urlencode($pathtosqlkey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3622 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextra) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextra).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
3624 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3626 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3628 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptableextrafields&token='.newToken().
'">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
3630 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&token='.newToken().
'&format=sql&file='.urlencode($pathtosqlextra).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3634 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKeyExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextrakey) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextrakey).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
3636 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=sql&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3638 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3640 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&token='.newToken().
'&format=sql&file='.urlencode($pathtosqlextra).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3645 print
'<div class="fichehalfleft smallxxxx">';
3646 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForList").
' : <strong class="wordbreak"><a href="'.$urloflist.
'" target="_test">'.(
dol_is_file($realpathtolist) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtolist).(
dol_is_file($realpathtolist) ?
'' :
'</span></strike>').
'</a></strong>';
3647 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtolist).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3649 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForCreateEditView").
' : <strong class="wordbreak"><a href="'.$urlofcard.
'?action=create" target="_test">'.(
dol_is_file($realpathtocard) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtocard).(
dol_is_file($realpathtocard) ?
'' :
'</strike>').
'?action=create</a></strong>';
3650 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtocard).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3653 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForContactTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtocontact) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtocontact).(
dol_is_file($realpathtocontact) ?
'' :
'</span></strike>').
'</strong>';
3654 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3657 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3659 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagecontact&token='.newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3663 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForDocumentTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtodocument) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtodocument).(
dol_is_file($realpathtodocument) ?
'' :
'</span></strike>').
'</strong>';
3664 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3667 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3669 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagedocument&token='.newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3673 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForNoteTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtonote) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtonote).(
dol_is_file($realpathtonote) ?
'' :
'</span></strike>').
'</strong>';
3674 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3677 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3679 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagenote&token='.newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3683 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForAgendaTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoagenda) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoagenda).(
dol_is_file($realpathtoagenda) ?
'' :
'</span></strike>').
'</strong>';
3684 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&token='.newToken().
'&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3687 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3689 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpageagenda&token='.newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
3696 print
'<br><br><br>';
3698 if (!empty($tmpobject)) {
3699 $reflector =
new ReflectionClass($tabobj);
3700 $reflectorproperties = $reflector->getProperties();
3701 $reflectorpropdefault = $reflector->getDefaultProperties();
3705 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3706 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3707 print
'<input type="hidden" name="action" value="addproperty">';
3708 print
'<input type="hidden" name="tab" value="objects">';
3709 print
'<input type="hidden" name="page_y" value="">';
3710 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
3711 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
3713 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
3718 print
'<!-- Table with properties of object -->'.
"\n";
3719 print
'<div class="div-table-responsive">';
3720 print
'<table class="noborder small">';
3721 print
'<tr class="liste_titre">';
3722 print
'<th class="none">';
3724 $htmltext = $langs->trans(
"PropertyDesc").
'<br><br><a class="" href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeExamples").
'</a>';
3725 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
3729 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
3731 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
3732 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
3733 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
3734 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
3735 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
3736 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
3737 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
3738 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
3739 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
3740 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
3741 print
'<th class="center">'.$langs->trans(
"AlwaysEditable").
'</th>';
3742 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
3743 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
3744 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
3745 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
3746 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
3747 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
3748 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
3750 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
3751 print
'<th>'.$langs->trans(
"Comment").
'</th>';
3752 print
'<th class="none"></th>';
3758 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
3760 if (!empty($properties)) {
3763 print
'<td class="none"><input type="text" class="maxwidth75" name="propname" value="'.dol_escape_htmltag(
GETPOST(
'propname',
'alpha')).
'"></td>';
3764 print
'<td><input type="text" class="maxwidth75" name="proplabel" value="'.dol_escape_htmltag(
GETPOST(
'proplabel',
'alpha')).
'"></td>';
3765 print
'<td><input type="text" class="maxwidth75" name="proptype" value="'.dol_escape_htmltag(
GETPOST(
'proptype',
'alpha')).
'"></td>';
3766 print
'<td><input type="text" class="maxwidth75" name="proparrayofkeyval" value="'.dol_escape_htmltag(
GETPOST(
'proparrayofkeyval',
'restricthtml')).
'"></td>';
3767 print
'<td class="center"><input type="text" class="center maxwidth50" name="propnotnull" value="'.dol_escape_htmltag(
GETPOST(
'propnotnull',
'alpha')).
'"></td>';
3768 print
'<td><input type="text" class="center maxwidth50" name="propdefault" value="'.dol_escape_htmltag(
GETPOST(
'propdefault',
'alpha')).
'"></td>';
3769 print
'<td class="center"><input type="text" class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag(
GETPOST(
'propindex',
'alpha')).
'"></td>';
3770 print
'<td class="center"><input type="text" class="maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag(
GETPOST(
'propforeignkey',
'alpha')).
'"></td>';
3771 print
'<td class="right"><input type="text" class="right" size="2" name="propposition" value="'.dol_escape_htmltag(
GETPOST(
'propposition',
'alpha')).
'"></td>';
3772 print
'<td class="center"><input type="text" class="center maxwidth50" name="propenabled" value="'.dol_escape_htmltag(
GETPOST(
'propenabled',
'alpha')).
'"></td>';
3773 print
'<td class="center"><input type="text" class="center maxwidth50" name="propvisible" value="'.dol_escape_htmltag(
GETPOST(
'propvisible',
'alpha')).
'"></td>';
3774 print
'<td class="center"><input type="text" class="center maxwidth50" name="propnoteditable" value="'.dol_escape_htmltag(
GETPOST(
'propnoteditable',
'alpha')).
'"></td>';
3775 print
'<td class="center"><input type="text" class="center maxwidth50" name="propalwayseditable" value="'.dol_escape_htmltag(
GETPOST(
'propalwayseditable',
'alpha')).
'"></td>';
3776 print
'<td class="center"><input type="text" class="center maxwidth50" name="propsearchall" value="'.dol_escape_htmltag(
GETPOST(
'propsearchall',
'alpha')).
'"></td>';
3777 print
'<td class="center"><input type="text" class="center maxwidth50" name="propisameasure" value="'.dol_escape_htmltag(
GETPOST(
'propisameasure',
'alpha')).
'"></td>';
3778 print
'<td class="center"><input type="text" class="maxwidth50" name="propcss" value="'.dol_escape_htmltag(
GETPOST(
'propcss',
'alpha')).
'"></td>';
3779 print
'<td class="center"><input type="text" class="maxwidth50" name="propcssview" value="'.dol_escape_htmltag(
GETPOST(
'propcssview',
'alpha')).
'"></td>';
3780 print
'<td class="center"><input type="text" class="maxwidth50" name="propcsslist" value="'.dol_escape_htmltag(
GETPOST(
'propcsslist',
'alpha')).
'"></td>';
3781 print
'<td><input type="text" class="maxwidth50" name="prophelp" value="'.dol_escape_htmltag(
GETPOST(
'prophelp',
'alpha')).
'"></td>';
3782 print
'<td class="center"><input type="text" class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag(
GETPOST(
'propshowoncombobox',
'alpha')).
'"></td>';
3784 print
'<td><input type="number" step="1" min="0" max="1" class="text maxwidth50" name="propvalidate" value="'.dol_escape_htmltag(
GETPOST(
'propvalidate',
'alpha')).
'"></td>';
3785 print
'<td><input class="text maxwidth100" name="propcomment" value="'.dol_escape_htmltag(
GETPOST(
'propcomment',
'alpha')).
'"></td>';
3786 print
'<td class="center tdstickyright tdstickyghostwhite">';
3787 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
3791 foreach ($properties as $propkey => $propval) {
3806 $propname = $propkey;
3807 $proplabel = $propval[
'label'];
3808 $proptype = $propval[
'type'];
3809 $proparrayofkeyval = !empty($propval[
'arrayofkeyval'])?$propval[
'arrayofkeyval']:
'';
3810 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
3811 $propdefault = !empty($propval[
'default'])?$propval[
'default']:
'';
3812 $propindex = !empty($propval[
'index'])?$propval[
'index']:
'';
3813 $propforeignkey = !empty($propval[
'foreignkey'])?$propval[
'foreignkey']:
'';
3814 $propposition = $propval[
'position'];
3815 $propenabled = $propval[
'enabled'];
3816 $propvisible = $propval[
'visible'];
3817 $propnoteditable = !empty($propval[
'noteditable'])?$propval[
'noteditable']:0;
3818 $propalwayseditable = !empty($propval[
'alwayseditable'])?$propval[
'alwayseditable']:0;
3819 $propsearchall = !empty($propval[
'searchall'])?$propval[
'searchall']:0;
3820 $propisameasure = !empty($propval[
'isameasure'])?$propval[
'isameasure']:0;
3821 $propcss = !empty($propval[
'css'])?$propval[
'css']:
'';
3822 $propcssview = !empty($propval[
'cssview'])?$propval[
'cssview']:
'';
3823 $propcsslist = !empty($propval[
'csslist'])?$propval[
'csslist']:
'';
3824 $prophelp = !empty($propval[
'help'])?$propval[
'help']:
'';
3825 $propshowoncombobox = !empty($propval[
'showoncombobox'])?$propval[
'showoncombobox']:0;
3827 $propvalidate = !empty($propval[
'validate'])?$propval[
'validate']:0;
3828 $propcomment = !empty($propval[
'comment'])?$propval[
'comment']:
'';
3830 print
'<tr class="oddeven">';
3832 print
'<td class="tdsticky tdstickygray">';
3838 if ($action ==
'editproperty' && $propname == $propertykey) {
3839 print
'<td class="tdoverflowmax200">';
3840 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
3841 print
'<input type="hidden" name="proplabel" value="'.dol_escape_htmltag($proplabel).
'">';
3842 print
'<input name="proptype" value="'.dol_escape_htmltag($proptype).
'"></input>';
3844 print
'<td class="tdoverflowmax200">';
3845 print
'<input name="proparrayofkeyval" value="';
3846 if (isset($proparrayofkeyval)) {
3847 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
3855 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
3858 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
3860 print
'<td class="center">';
3861 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
3864 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
3867 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
3870 print
'<input class="center" name="propenabled" size="2" value="'.dol_escape_htmltag($propenabled).
'">';
3873 print
'<input class="center" name="propvisible" size="2" value="'.dol_escape_htmltag($propvisible).
'">';
3876 print
'<input class="center" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
3879 print
'<input class="center" name="propalwayseditable" size="2" value="'.dol_escape_htmltag($propalwayseditable).
'">';
3882 print
'<input class="center" name="propsearchall" size="2" value="'.dol_escape_htmltag($propsearchall).
'">';
3885 print
'<input class="center" name="propisameasure" size="2" value="'.dol_escape_htmltag($propisameasure).
'">';
3888 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
3891 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
3894 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
3897 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
3900 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
3903 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
3906 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
3908 print
'<td class="center tdstickyright tdstickyghostwhite">';
3909 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
3910 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
3913 print
'<td class="tdoverflowmax200">';
3914 print
'<span title="'.dol_escape_htmltag($proptype).
'">'.
dol_escape_htmltag($proptype).
'</span>';
3916 print
'<td class="tdoverflowmax200">';
3917 if ($proparrayofkeyval) {
3918 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
3923 print
'<td class="center">';
3929 print
'<td class="center">';
3930 print $propindex ?
'1' :
'';
3932 print
'<td class="center">';
3935 print
'<td class="right">';
3938 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
3942 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
3946 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
3949 print
'<td class="center">';
3952 print
'<td class="center">';
3953 print $propsearchall ?
'1' :
'';
3955 print
'<td class="center">';
3958 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
3961 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
3964 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
3968 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
3971 print
'<td class="center">';
3977 print
'<td class="center">';
3980 print
'<td class="tdoverflowmax200">';
3981 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
3985 print
'<td class="center tdstickyright tdstickyghostwhite">';
3986 if ($propname !=
'rowid') {
3987 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=editproperty&token='.newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_edit().
'</a>';
3988 print
'<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteproperty&token='.newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
3995 if ($tab ==
'specifications') {
3996 if ($action !=
'editfile' || empty($file)) {
3997 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4002 foreach ($specs as $spec) {
4003 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4004 $format =
'asciidoc';
4005 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4006 $format =
'markdown';
4008 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4009 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4019 $content = file_get_contents($fullpathoffile);
4022 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4023 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4024 print
'<input type="hidden" name="action" value="savefile">';
4025 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4026 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4027 print
'<input type="hidden" name="module" value="'.$module.
'">';
4029 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4030 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4033 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4035 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4041 print
'<tr><td><span class="warning">'.$langs->trans(
'Property $field not found into the class. The class was probably not generated by modulebuilder.').
'</warning></td></tr>';
4048 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new '.$tabobj.
'($db)').
'</warning>';
4051 print $e->getMessage();
4054 if (empty($forceddirread)) {
4057 $fullpathoffile = $dirread.
'/'.$file;
4060 $content = file_get_contents($fullpathoffile);
4063 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4064 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4065 print
'<input type="hidden" name="action" value="savefile">';
4066 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4067 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4068 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4069 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4071 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4072 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4075 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4077 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4087 if ($tab ==
'dictionaries') {
4088 print
'<!-- tab=dictionaries -->'.
"\n";
4089 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4091 $dicts = $moduleobj->dictionaries;
4093 if ($action !=
'editfile' || empty($file)) {
4094 print
'<span class="opacitymedium">';
4095 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4096 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4097 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4101 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4102 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4104 if (is_array($dicts) && !empty($dicts)) {
4105 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4106 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
4110 print
'<!-- tab=objects -->'.
"\n";
4117 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
4118 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4119 $head3[$h][2] =
'newdictionary';
4126 if (!empty($dicts[
'tabname'])) {
4127 foreach ($dicts[
'tabname'] as $key => $dic) {
4129 $diclabel = $dicts[
'tablib'][$key];
4131 if (empty($firstdicname)) {
4132 $firstdicname = $dicname;
4135 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic='.$dicname;
4136 $head3[$h][1] = $diclabel;
4137 $head3[$h][2] = $dicname;
4143 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=deletedictionary';
4144 $head3[$h][1] = $langs->trans(
"DangerZone");
4145 $head3[$h][2] =
'deletedictionary';
4150 if ($tabdic ==
'newdicifnodic') {
4151 if ($firstdicname) {
4152 $tabdic = $firstdicname;
4154 $tabdic =
'newdictionary';
4158 print
load_fiche_titre($langs->trans(
"ListOfDictionariesEntries"),
'',
'');
4160 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4161 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4162 print
'<input type="hidden" name="action" value="addproperty">';
4163 print
'<input type="hidden" name="tab" value="dictionaries">';
4164 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4165 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
4167 print
'<div class="div-table-responsive">';
4168 print
'<table class="noborder">';
4170 print
'<tr class="liste_titre">';
4171 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
4183 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
4185 $maxi = count($dicts[
'tabname']);
4186 while ($i < $maxi) {
4187 print
'<tr class="oddeven">';
4189 print
'<td class="tdsticky tdstickygray">';
4194 print $dicts[
'tabname'][$i];
4198 print $dicts[
'tablib'][$i];
4202 print $dicts[
'tabsql'][$i];
4206 print $dicts[
'tabsqlsort'][$i];
4210 print $dicts[
'tabfield'][$i];
4214 print $dicts[
'tabfieldvalue'][$i];
4218 print $dicts[
'tabfieldinsert'][$i];
4221 print
'<td class="right">';
4222 print $dicts[
'tabrowid'][$i];
4225 print
'<td class="right">';
4226 print $dicts[
'tabcond'][$i];
4233 print
'<tr><td colspan="10"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
4243 if ($tabdic ==
'newdictionary') {
4245 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4246 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4247 print
'<input type="hidden" name="action" value="initdic">';
4248 print
'<input type="hidden" name="tab" value="dictionaries">';
4249 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4251 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
4253 print
'<input type="text" name="dicname" maxlength="64" value="'.dol_escape_htmltag(
GETPOST(
'dicname',
'alpha') ?
GETPOST(
'dicname',
'alpha') : $modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'" autofocus><br>';
4256 print
'<input type="submit" class="button smallpaddingimp" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4270 } elseif ($tabdic ==
'deletedictionary') {
4272 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4273 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4274 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4275 print
'<input type="hidden" name="tab" value="dictionaries">';
4276 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4278 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4280 print
'<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ObjectKey")).
'">';
4281 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4284 print $langs->trans(
"FeatureNotYetAvailable");
4291 $content = file_get_contents($fullpathoffile);
4294 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4295 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4296 print
'<input type="hidden" name="action" value="savefile">';
4297 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4298 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4299 print
'<input type="hidden" name="module" value="'.$module.
'">';
4301 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4302 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4305 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4307 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4314 if ($tab ==
'menus') {
4315 print
'<!-- tab=menus -->'.
"\n";
4316 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4317 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
4318 $destdir = $dirins.
'/'.strtolower($module);
4319 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
4320 $objects = dolGetListOfObjectclasses($destdir);
4322 $leftmenus = array();
4324 $menus = $moduleobj->menu;
4326 if ($action ==
'deletemenu') {
4327 $formconfirms = $form->formconfirm(
4328 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode(
GETPOST(
'menukey',
'int')).
'&tab='.urlencode($tab).
'&module='.urlencode($module),
4329 $langs->trans(
'Delete'),
4330 $langs->trans(
'Confirm Delete Menu',
GETPOST(
'menukey',
'int')),
4331 'confirm_deletemenu',
4336 print $formconfirms;
4338 if ($action !=
'editfile' || empty($file)) {
4339 print
'<span class="opacitymedium">';
4340 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
4341 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/menus/index.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Menus').
'</a>', $htmlhelp);
4342 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4346 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4347 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4353 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4354 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4355 print
'<input type="hidden" name="action" value="addmenu">';
4356 print
'<input type="hidden" name="tab" value="menus">';
4357 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4358 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4360 print
'<div class="div-table-responsive">';
4361 print
'<table class="noborder small">';
4363 print
'<tr class="liste_titre">';
4367 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder);
4370 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
4372 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
4373 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled'));
4374 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight'));
4375 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
4376 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailUser'));
4377 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
4380 $r = count($menus)+1;
4383 print
'<td class="center"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
4384 print
'<td class="center">';
4385 print
'<select class="center maxwidth50" name="type">';
4386 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
4387 print
'</select></td>';
4388 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
4389 print
'<td class="left">';
4390 print
'<select name="fk_menu">';
4391 print
'<option value="">'.$langs->trans(
"........").
'</option>';
4392 foreach ($menus as $obj) {
4393 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
4394 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
4399 print
'<td class="left"><input type="text" class="left maxwidth" name="mainmenu" value="'.(empty(
GETPOST(
'mainmenu')) ? strtolower($module) :
dol_escape_htmltag(
GETPOST(
'mainmenu',
'alpha'))).
'" readonly></td>';
4400 print
'<td class="center"><input type="text" class="left maxwidth" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
4401 print
'<td class="left"><input type="text" class="left maxwidth" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
4402 print
'<td class="left"><input type="text" class="left maxwidth" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
4403 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000+$r).
'" readonly></td>';
4404 print
'<td class="center">';
4405 print
'<select class="center maxwidth" name="enabled">';
4406 print
'<option value="1" selected>'.$langs->trans(
"Show").
'</option>';
4407 print
'<option value="0">'.$langs->trans(
"Hide").
'</option>';
4410 print
'<td class="center">';
4411 print
'<select class="center maxwidth" name="perms">';
4412 print
'<option selected value="1">'.$langs->trans(
"Yes").
'</option>';
4413 print
'<option value="0">'.$langs->trans(
"No").
'</option>';
4416 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
4417 print
'<td class="center"><select class="center maxwidth10" name="user"><option value="2">'.$langs->trans(
"AllMenus").
'</option><option value="0">'.$langs->trans(
"Internal").
'</option><option value="1">'.$langs->trans(
"External").
'</option></select></td>';
4419 print
'<td class="center tdstickyright tdstickyghostwhite">';
4420 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
4424 if (count($menus)) {
4426 foreach ($menus as $menu) {
4430 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
4432 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
4433 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
4434 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
4435 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
4436 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
4437 $propPerms = empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
4438 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
4439 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
4440 $propEnabled = empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
4441 if ($action ==
'editmenu' &&
GETPOST(
'menukey',
'int') == $i) {
4443 print
'<tr class="oddeven">';
4444 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4445 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4446 print
'<input type="hidden" name="action" value="modify_menu">';
4447 print
'<input type="hidden" name="tab" value="menus">';
4448 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4449 print
'<input type="hidden" name="tabobject" value="'.dol_escape_htmltag($tabobject).
'">';
4450 print
'<td class="tdsticky tdstickygray">';
4453 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
4454 print
'<td class="center">
4455 <select class="center maxwidth50" name="type">
4456 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
4459 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
4460 if ($menu[
'type'] ==
'left') {
4465 print
'</option></select></td>';
4466 print
'<td class="left"><input type="text" class="left maxwidth" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
4467 print
'<td class="left">';
4468 print
'<select name="fk_menu" class="left maxwidth">';
4469 print
'<option value="'.dol_escape_htmltag($propFk_menu).
'">'.
dol_escape_htmltag($value).
'</option>';
4470 foreach ($menus as $obj) {
4471 if ($obj[
'type'] ==
'left' && $obj[
'leftmenu'] != $value && $obj[
'leftmenu'] != $menu[
'leftmenu']) {
4472 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
4477 print
'<td class="left"><input type="text" class="left maxwidth75" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
4478 print
'<td class="left"><input type="text" class="left maxwidth" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'"></td>';
4479 print
'<td class="left"><input type="text" class="left maxwidth" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
4480 print
'<td class="left"><input type="text" class="left maxwidth" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
4481 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000+$r-1).
'" readonly></td>';
4482 print
'<td class="left">';
4483 print
'<select class="center maxwidth" name="enabled">';
4484 print
'<option value="'.dol_escape_htmltag($propEnabled).
'">'.(
dol_escape_htmltag($propEnabled) ==
'0' ? $langs->trans(
'Hide') : $langs->trans(
'Show')).
'</option>';
4485 if ($propEnabled !=
'0') {
4486 print
'<option value="0" >'.$langs->trans(
"Hide").
'</option>';
4488 print
'<option value="1">'.$langs->trans(
"Show").
'</option>';
4492 print
'<td class="center">';
4493 print
'<select class="center maxwidth" name="perms">';
4494 print
'<option selected value="'.dol_escape_htmltag($propPerms).
'">'.(
dol_escape_htmltag($propPerms) ==
'0' ? $langs->trans(
'No') : $langs->trans(
'Yes')).
'</option>';
4495 if ($propPerms !=
'0') {
4496 print
'<option value="0">'.$langs->trans(
"No").
'</option>';
4498 print
'<option value="1">'.$langs->trans(
"Yes").
'</option>';
4502 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag($propTarget).
'"></td>';
4503 print
'<td class="center"><select class="center maxwidth10" name="user"><option value="2">'.$langs->trans(
"AllMenus").
'</option><option value="0">'.$langs->trans(
"Internal").
'</option><option value="1">'.$langs->trans(
"External").
'</option></select></td>';
4504 print
'<td class="center tdstickyright tdstickyghostwhite maxwidth50">';
4505 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Modify").
'">';
4506 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4511 print
'<tr class="oddeven">';
4513 print
'<td class="tdsticky tdstickygray">';
4526 print ($value == strtolower($module) ?
'/' : $value);
4537 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($menu[
'url']).
'">';
4545 print
'<td class="center">';
4549 print
'<td class="center tdoverflowmax200" title="'.dol_escape_htmltag($menu[
'enabled']).
'">';
4550 print (
dol_escape_htmltag($menu[
'enabled']) ==
'0' ? $langs->trans(
"Hide") : $langs->trans(
"Show"));
4553 print
'<td class="center tdoverflowmax200" title="'.dol_escape_htmltag($menu[
'perms']).
'">';
4554 print (
dol_escape_htmltag($menu[
'perms'])==
'1' ? $langs->trans(
"Yes") : $langs->trans(
"No"));
4557 print
'<td class="center tdoverflowmax200" title="'.dol_escape_htmltag($menu[
'target']).
'">';
4561 print
'<td class="center">';
4562 if ($menu[
'user'] == 2) {
4563 print $langs->trans(
"AllMenus");
4564 } elseif ($menu[
'user'] == 0) {
4565 print $langs->trans(
'Internal');
4566 } elseif ($menu[
'user'] == 1) {
4567 print $langs->trans(
'External');
4569 print $menu[
'user'];
4572 print
'<td class="center tdstickyright tdstickyghostwhite">';
4573 if ($menu[
'titre'] !=
'Module'.$module.
'Name') {
4574 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmenu&token='.newToken().
'&menukey='.urlencode($i).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_edit().
'</a>';
4575 print
'<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deletemenu&token='.newToken().
'&menukey='.urlencode($i-1).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
4582 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
4592 $content = file_get_contents($fullpathoffile);
4595 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4596 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4597 print
'<input type="hidden" name="action" value="savefile">';
4598 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4599 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4600 print
'<input type="hidden" name="module" value="'.$module.
'">';
4602 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4603 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4606 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4608 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4615 if ($tab ==
'permissions') {
4616 print
'<!-- tab=permissions -->'.
"\n";
4617 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4619 $perms = $moduleobj->rights;
4622 $dir = $dirread.
'/'.$modulelowercase.
'/class';
4623 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
4624 $objects = array(
'myobject');
4626 foreach ($listofobject as $fileobj) {
4627 $tmpcontent = file_get_contents($fileobj[
'fullname']);
4628 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
4629 $objects[$fileobj[
'fullname']] = $reg[1];
4634 $crud = array(
'read'=>
'CRUDRead',
'write'=>
'CRUDCreateWrite',
'delete'=>
'Delete');
4635 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
4637 $action =
GETPOST(
'action',
'alpha');
4639 if ($action ==
'deleteright') {
4640 $formconfirm = $form->formconfirm(
4641 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode(
GETPOST(
'permskey',
'int')).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4642 $langs->trans(
'Delete'),
4643 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
4644 'confirm_deleteright',
4652 if ($action !=
'editfile' || empty($file)) {
4653 print
'<!-- Tab to manage permissions -->'.
"\n";
4654 print
'<span class="opacitymedium">';
4655 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
4656 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
4657 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4661 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4662 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4668 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4669 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4670 print
'<input type="hidden" name="action" value="addright">';
4671 print
'<input type="hidden" name="tab" value="permissions">';
4672 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4673 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4675 print
'<div class="div-table-responsive">';
4676 print
'<table class="noborder">';
4678 print
'<tr class="liste_titre">';
4680 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
4687 print
'<tr class="small">';
4688 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
4690 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
4691 print
'<option value=""></option>';
4692 foreach ($objects as $obj) {
4693 if ($obj !=
'myobject') {
4694 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
4697 print
'</select></td>';
4699 print
'<td><select class="maxwidth" name="crud" id="crud">';
4700 print
'<option value=""></option>';
4701 foreach ($crud as $key => $val) {
4702 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
4707 print
'<input type="text" name="label" id="label" class="minwidth200">';
4710 print
'<td class="center tdstickyright tdstickyghostwhite">';
4711 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
4715 if (count($perms)) {
4717 foreach ($perms as $perm) {
4721 if ($action ==
'edit_right' && $perm[0] == (
int)
GETPOST(
'permskey',
'int')) {
4722 print
'<tr class="oddeven">';
4723 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
4724 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4725 print
'<input type="hidden" name="tab" value="permissions">';
4726 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4727 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4728 print
'<input type="hidden" name="action" value="update_right">';
4729 print
'<input type="hidden" name="counter" value="'.$i.
'">';
4731 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
4733 print
'<td class="tdsticky tdstickygray">';
4734 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
4738 print
'<select name="crud">';
4739 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
4740 foreach ($crud as $i=> $x) {
4741 if ($perm[5] != $i) {
4742 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
4748 print
'<td><select name="permissionObj" >';
4749 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
4750 print
'</select></td>';
4753 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
4756 print
'<td class="center tdstickyright tdstickyghostwhite">';
4757 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
4759 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4766 print
'<tr class="oddeven">';
4773 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
4781 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
4782 print ucfirst($langs->trans($perm[5]));
4784 print ucfirst($langs->trans($perm[4]));
4789 print $langs->trans($perm[1]);
4792 print
'<td class="center tdstickyright tdstickyghostwhite">';
4793 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_right&token='.newToken().
'&permskey='.urlencode($perm[0]).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_edit().
'</a>';
4794 print
'<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteright&token='.newToken().
'&permskey='.urlencode($i).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
4802 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
4810 function updateInputField() {
4811 value1 = $("#crud").val();
4812 value2 = $("#permissionObj").val();
4814 // Vérifie si les deux sélections sont faites
4815 if ($("#label").val() == "" && value1 && value2) {
4816 switch(value1.toLowerCase()){
4818 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
4821 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
4824 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
4832 $("#crud, #permissionObj").change(updateInputField);
4838 $content = file_get_contents($fullpathoffile);
4841 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4842 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4843 print
'<input type="hidden" name="action" value="savefile">';
4844 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4845 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4846 print
'<input type="hidden" name="module" value="'.$module.
'">';
4848 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4849 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4852 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4854 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4861 if ($tab ==
'hooks') {
4862 print
'<!-- tab=hooks -->'.
"\n";
4863 if ($action !=
'editfile' || empty($file)) {
4864 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
4869 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4871 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4873 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4877 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
4878 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"HooksFile").
' : ';
4880 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
4882 print
'<td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a> ';
4883 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
4885 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
4886 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inithook&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</td>';
4893 $content = file_get_contents($fullpathoffile);
4896 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4897 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4898 print
'<input type="hidden" name="action" value="savefile">';
4899 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4900 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4901 print
'<input type="hidden" name="module" value="'.$module.
'">';
4903 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4904 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4907 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4909 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4916 if ($tab ==
'triggers') {
4917 print
'<!-- tab=triggers -->'.
"\n";
4918 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
4921 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
4923 if ($action !=
'editfile' || empty($file)) {
4924 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
4929 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4931 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4933 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4936 if (!empty($triggers)) {
4937 foreach ($triggers as $trigger) {
4938 $pathtofile = $trigger[
'relpath'];
4941 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4942 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
4943 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
4948 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TriggersFile");
4949 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
4950 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inittrigger&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
4959 $content = file_get_contents($fullpathoffile);
4962 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4963 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4964 print
'<input type="hidden" name="action" value="savefile">';
4965 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4966 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4967 print
'<input type="hidden" name="module" value="'.$module.
'">';
4969 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4970 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4973 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4975 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4982 if ($tab ==
'css') {
4983 print
'<!-- tab=css -->'.
"\n";
4984 if ($action !=
'editfile' || empty($file)) {
4985 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
4991 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
4992 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"CSSFile").
' : ';
4994 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
4995 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
4996 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&format='.$format.
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
4998 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
4999 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcss&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5005 $content = file_get_contents($fullpathoffile);
5008 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5009 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5010 print
'<input type="hidden" name="action" value="savefile">';
5011 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5012 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5013 print
'<input type="hidden" name="module" value="'.$module.
'">';
5015 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5016 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5019 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5021 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5029 print
'<!-- tab=js -->'.
"\n";
5030 if ($action !=
'editfile' || empty($file)) {
5031 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
5037 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
5038 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"JSFile").
' : ';
5040 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5041 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5042 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5044 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5045 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initjs&token='.newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5051 $content = file_get_contents($fullpathoffile);
5054 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5055 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5056 print
'<input type="hidden" name="action" value="savefile">';
5057 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5058 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5059 print
'<input type="hidden" name="module" value="'.$module.
'">';
5061 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5062 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5065 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5067 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5074 if ($tab ==
'widgets') {
5075 print
'<!-- tab=widgets -->'.
"\n";
5076 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
5080 if ($action !=
'editfile' || empty($file)) {
5081 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
5085 if (!empty($widgets)) {
5086 foreach ($widgets as $widget) {
5087 $pathtofile = $widget[
'relpath'];
5089 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5090 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5091 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5095 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
5096 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initwidget&token='.newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
5103 $content = file_get_contents($fullpathoffile);
5106 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5107 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5108 print
'<input type="hidden" name="action" value="savefile">';
5109 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5110 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5111 print
'<input type="hidden" name="module" value="'.$module.
'">';
5113 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5114 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5117 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5119 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5126 if ($tab ==
'exportimport') {
5127 print
'<!-- tab=exportimport -->'.
"\n";
5128 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5130 $exportlist = $moduleobj->export_label;
5131 $importlist = $moduleobj->import_label;
5133 if ($action !=
'editfile' || empty($file)) {
5134 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
5137 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5138 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5143 $content = file_get_contents($fullpathoffile);
5146 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5147 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5148 print
'<input type="hidden" name="action" value="savefile">';
5149 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5150 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5151 print
'<input type="hidden" name="module" value="'.$module.
'">';
5153 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5154 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5157 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5159 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5166 if ($tab ==
'cli') {
5167 print
'<!-- tab=cli -->'.
"\n";
5168 $clifiles = array();
5171 $dircli = array(
'/'.strtolower($module).
'/scripts');
5173 foreach ($dircli as $reldir) {
5178 if (!is_dir($newdir)) {
5182 $handle = opendir($newdir);
5184 if (is_resource($handle)) {
5185 while (($tmpfile = readdir($handle)) !==
false) {
5186 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
5187 if (preg_match(
'/\.back$/', $tmpfile)) {
5191 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
5200 if ($action !=
'editfile' || empty($file)) {
5201 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
5205 if (!empty($clifiles)) {
5206 foreach ($clifiles as $clifile) {
5207 $pathtofile = $clifile[
'relpath'];
5209 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5210 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5211 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5215 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated");
'</span>';
5216 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcli&token='.newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
5223 $content = file_get_contents($fullpathoffile);
5226 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5227 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5228 print
'<input type="hidden" name="action" value="savefile">';
5229 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5230 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5231 print
'<input type="hidden" name="module" value="'.$module.
'">';
5233 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5234 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5237 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5239 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5246 if ($tab ==
'cron') {
5247 print
'<!-- tab=cron -->'.
"\n";
5248 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5250 $cronjobs = $moduleobj->cronjobs;
5252 if ($action !=
'editfile' || empty($file)) {
5253 print
'<span class="opacitymedium">'.str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/cron/list.php">'.$langs->transnoentities(
'CronList').
'</a>', $langs->trans(
"CronJobDefDesc",
'{s1}')).
'</span><br>';
5256 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5257 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5263 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5264 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5265 print
'<input type="hidden" name="action" value="addproperty">';
5266 print
'<input type="hidden" name="tab" value="objects">';
5267 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5268 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5270 print
'<div class="div-table-responsive">';
5271 print
'<table class="noborder">';
5273 print
'<tr class="liste_titre">';
5281 if (count($cronjobs)) {
5282 foreach ($cronjobs as $cron) {
5283 print
'<tr class="oddeven">';
5286 print $cron[
'label'];
5290 if ($cron[
'jobtype'] ==
'method') {
5291 $text = $langs->trans(
"CronClass");
5292 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
5293 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
5294 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
5295 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
5296 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
5297 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
5298 } elseif ($cron[
'jobtype'] ==
'command') {
5299 $text = $langs->trans(
'CronCommand');
5300 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
5301 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
5302 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
5304 print $form->textwithpicto($text, $texttoshow, 1);
5308 if ($cron[
'unitfrequency'] ==
"60") {
5309 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
5311 if ($cron[
'unitfrequency'] ==
"3600") {
5312 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
5314 if ($cron[
'unitfrequency'] ==
"86400") {
5315 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
5317 if ($cron[
'unitfrequency'] ==
"604800") {
5318 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
5323 print $cron[
'status'];
5327 if (!empty($cron[
'comment'])) {
5328 print $cron[
'comment'];
5335 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5345 $content = file_get_contents($fullpathoffile);
5348 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5349 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5350 print
'<input type="hidden" name="action" value="savefile">';
5351 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5352 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5353 print
'<input type="hidden" name="module" value="'.$module.
'">';
5355 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5356 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5359 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5361 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5368 if ($tab ==
'specifications') {
5369 print
'<!-- tab=specifications -->'.
"\n";
5372 if ($action !=
'editfile' || empty($file)) {
5373 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
5377 if (is_array($specs) && !empty($specs)) {
5378 foreach ($specs as $spec) {
5379 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
5380 $format =
'asciidoc';
5381 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
5382 $format =
'markdown';
5385 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5386 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5387 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5392 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5393 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initdoc&token='.newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5404 $content = file_get_contents($fullpathoffile);
5407 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5408 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5409 print
'<input type="hidden" name="action" value="savefile">';
5410 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5411 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5412 print
'<input type="hidden" name="module" value="'.$module.
'">';
5414 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5415 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5418 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5420 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5426 print
'<br><br><br>';
5428 $FILENAMEDOC = $modulelowercase.
'.html';
5429 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
5430 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
5431 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
5432 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
5433 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
5434 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
5435 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
5438 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
5440 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5443 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
5444 print $outputfiledoc;
5447 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
5448 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&format='.$format.
'&file='.urlencode($outputfiledocrel).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
5450 print
'</strong><br>';
5453 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
5455 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5458 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
5459 print $outputfiledocpdf;
5462 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
5463 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&format='.$format.
'&file='.urlencode($outputfiledocrelpdf).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
5465 print
'</strong><br>';
5469 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
5470 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5471 print
'<input type="hidden" name="action" value="generatedoc">';
5472 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
5473 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5474 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
5475 if (!is_array($specs) || empty($specs)) {
5476 print
' disabled="disabled"';
5482 if ($tab ==
'buildpackage') {
5483 print
'<!-- tab=buildpackage -->'.
"\n";
5484 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
5487 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
5488 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
5492 $modulelowercase = strtolower($module);
5498 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5500 $class =
'mod'.$module;
5502 if (class_exists($class)) {
5504 $moduleobj =
new $class($db);
5511 $langs->load(
"errors");
5512 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
5516 $arrayversion = explode(
'.', $moduleobj->version, 3);
5517 if (count($arrayversion)) {
5518 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
5519 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
5524 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
5526 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5528 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
5529 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
5530 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
5531 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.newToken().
'&file='.urlencode($relativepath).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
5539 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
5540 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5541 print
'<input type="hidden" name="action" value="generatepackage">';
5542 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
5543 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5544 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
5548 if ($tab ==
'tabs') {
5549 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5551 $tabs = $moduleobj->tabs;
5553 if ($action !=
'editfile' || empty($file)) {
5554 print
'<span class="opacitymedium">';
5555 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
5556 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/menus/index.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Tabs').
'</a>', $htmlhelp);
5557 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5561 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
5562 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5568 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5569 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5570 print
'<input type="hidden" name="action" value="addproperty">';
5571 print
'<input type="hidden" name="tab" value="objects">';
5572 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5573 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5575 print
'<div class="div-table-responsive">';
5576 print
'<table class="noborder small">';
5578 print
'<tr class="liste_titre">';
5588 foreach ($tabs as $tab) {
5589 $parts = explode(
':', $tab[
'data']);
5591 $objectType = $parts[0];
5592 $tabName = $parts[1];
5593 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
5594 $langFile = isset($parts[3]) ? $parts[3] :
'';
5595 $condition = isset($parts[4]) ? $parts[4] :
'';
5596 $path = isset($parts[5]) ? $parts[5] :
'';
5600 if ($tabName[0] ===
'-') {
5602 $condition = isset($parts[2]) ? $parts[2] :
'';
5605 print
'<tr class="oddeven">';
5612 if ($tabName[0] ===
"+") {
5613 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
5615 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
5638 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5648 $content = file_get_contents($fullpathoffile);
5651 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5652 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5653 print
'<input type="hidden" name="action" value="savefile">';
5654 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5655 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5656 print
'<input type="hidden" name="module" value="'.$module.
'">';
5658 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5659 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5662 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5664 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5671 if ($tab !=
'description') {
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).
unActivateModule($value, $requiredby=1)
Disable a module.
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage triggers.
static getWidgetsList($forcedirwidget=null)
Return list of widget.
Class to manage utility methods.
dol_filemtime($pathoffile)
Return time of a file.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_is_file($pathoffile)
Return if path is a file.
dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0, $arrayreplacementisregex=0)
Make replacement of strings into a file.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null)
Copy a dir to another dir.
dol_is_dir($folder)
Test if filename is a directory.
dol_is_dir_empty($dir)
Return if path is empty.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
deletePropsFromDoc($file, $objectname)
Delete property from documentation if we delete object.
writePermsInAsciiDoc($file, $destfile)
Write all permissions of each object in AsciiDoc format.
reWriteAllMenus($file, $menus, $menuWantTo, $key, $action)
rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null, $moduletype='external')
Save data into a memory area shared by all users, all sessions on server.
addObjectsToApiFile($file, $objects, $modulename)
Add Object in ModuleApi File.
dolGetListOfObjectClasses($destdir)
Get list of existing objects from directory.
writePropsInAsciiDoc($file, $objectname, $destfile)
Write all properties of the object in AsciiDoc format.
removeObjectFromApiFile($file, $objectname, $modulename)
Remove Object variables and methods from API_Module File.
rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array(), $delfieldentry='')
Regenerate files .class.php.
getFromFile($file, $start, $end)
Search a string and return all lines needed from file.
reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $module, $action)
Rewriting all permissions after any actions.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.