250 $licInfo = $user->getFullName($langs);
251 $emailTabs = str_repeat(
"\t", (
int) (max(0, (31 - mb_strlen($licInfo)) / 4)));
252 $licInfo .= ($user->email ? $emailTabs.
'<'.$user->email.
'>' :
'');
261if ($dirins && $action ==
'initmodule' && $modulename && $user->hasRight(
"modulebuilder",
"run")) {
262 $modulename = ucfirst($modulename);
263 $destdir =
'/not_set/';
265 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
267 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
271 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
272 $destdir = $dirins.
'/'.strtolower($modulename);
274 $arrayreplacement = array(
275 'mymodule' => strtolower($modulename),
276 'MyModule' => $modulename
278 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayreplacement);
283 $langs->load(
"errors");
284 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
287 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
293 $tryToCopyFromSetupClass =
true;
294 $backportDest = $destdir .
'/backport/v16/core/class';
295 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
296 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
301 $langs->load(
"errors");
302 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
303 $tryToCopyFromSetupClass =
false;
306 if ($tryToCopyFromSetupClass) {
307 $result =
dol_copy($backportFileSrc, $backportFileDest);
311 $langs->load(
"errors");
312 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
314 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
337 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
338 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
356 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
357 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
359 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
360 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
361 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
362 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
377 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
380 foreach ($listofphpfilestoedit as $phpfileval) {
382 $arrayreplacement = array(
383 'mymodule' => strtolower($modulename),
384 'MyModule' => $modulename,
385 'MYMODULE' => strtoupper($modulename),
386 'My module' => $modulename,
387 'my module' => $modulename,
388 'Mon module' => $modulename,
389 'mon module' => $modulename,
390 'htdocs/modulebuilder/template' => strtolower($modulename),
391 '---Put here your own copyright and developer email---' => $licInfo,
392 '---Replace with your own copyright and developer email---' => $licInfo,
393 'Editor name' => $editorname,
394 'https://www.example.com' => $editorurl,
395 '$this->version = \'1.0\'' =>
'$this->version = \''.$version.
'\'',
396 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
397 "modulefamily" => $family,
398 '500000' => $idmodule
402 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
"\t\t" .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
409 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
414 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
416 file_put_contents($destdir.
'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README);
427 $module = $modulename;
429 clearstatcache(
true);
430 if (function_exists(
'opcache_invalidate')) {
434 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
439$destdir =
'/not_set/';
440$destfile =
'/not_set/';
441$srcfile =
'/not_set/';
444if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
445 $modulename = ucfirst($module);
446 $objectname = $tabobj;
447 $varnametoupdate =
'';
448 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
449 $destdir = $dirins.
'/'.strtolower($module);
455 if ($action ==
'initapi') {
456 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
457 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php',
'0', 1);
459 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
460 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
461 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
462 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
463 } elseif ($action ==
'initphpunit') {
464 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
465 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
466 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
467 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
468 } elseif ($action ==
'initpagecontact') {
469 dol_mkdir($dirins.
'/'.strtolower($module));
470 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
471 $srcfile = $srcdir.
'/myobject_contact.php';
472 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
473 $varnametoupdate =
'showtabofpagecontact';
474 } elseif ($action ==
'initpagedocument') {
475 dol_mkdir($dirins.
'/'.strtolower($module));
476 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
477 $srcfile = $srcdir.
'/myobject_document.php';
478 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
479 $varnametoupdate =
'showtabofpagedocument';
480 } elseif ($action ==
'initpagenote') {
481 dol_mkdir($dirins.
'/'.strtolower($module));
482 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
483 $srcfile = $srcdir.
'/myobject_note.php';
484 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
485 $varnametoupdate =
'showtabofpagenote';
486 } elseif ($action ==
'initpageagenda') {
487 dol_mkdir($dirins.
'/'.strtolower($module));
488 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
489 $srcfile = $srcdir.
'/myobject_agenda.php';
490 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
491 $varnametoupdate =
'showtabofpageagenda';
494 if (!file_exists($destfile)) {
495 $result =
dol_copy($srcfile, $destfile,
'0', 0);
500 $arrayreplacement = array(
501 'mymodule' => strtolower($modulename),
502 'MyModule' => $modulename,
503 'MYMODULE' => strtoupper($modulename),
504 'My module' => $modulename,
505 'my module' => $modulename,
506 'Mon module' => $modulename,
507 'mon module' => $modulename,
508 'htdocs/modulebuilder/template' => strtolower($modulename),
509 'myobject' => strtolower($objectname),
510 'MyObject' => $objectname,
511 'MYOBJECT' => strtoupper($objectname),
513 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
516 if ($action ==
'initapi') {
517 if (count($objects) >= 1) {
525 if ($varnametoupdate) {
527 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
528 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
533 $langs->load(
"errors");
534 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
540if ($dirins && $action ==
'initsqlextrafields' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
541 $modulename = ucfirst($module);
542 $objectname = $tabobj;
544 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
545 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
546 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
547 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
548 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
549 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
550 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
551 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
553 if ($result1 > 0 && $result2 > 0) {
554 $modulename = ucfirst($module);
557 $arrayreplacement = array(
558 'mymodule' => strtolower($modulename),
559 'MyModule' => $modulename,
560 'MYMODULE' => strtoupper($modulename),
561 'My module' => $modulename,
562 'my module' => $modulename,
563 'Mon module' => $modulename,
564 'mon module' => $modulename,
565 'htdocs/modulebuilder/template' => strtolower($modulename),
566 'My Object' => $objectname,
567 'MyObject' => $objectname,
568 'my object' => strtolower($objectname),
569 'myobject' => strtolower($objectname),
570 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
576 $langs->load(
"errors");
578 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
581 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
586 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
587 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
593if ($dirins && $action ==
'inithook' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
594 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
595 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
596 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
597 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
598 $result =
dol_copy($srcfile, $destfile,
'0', 0);
601 $modulename = ucfirst($module);
604 $arrayreplacement = array(
605 'mymodule' => strtolower($modulename),
606 'MyModule' => $modulename,
607 'MYMODULE' => strtoupper($modulename),
608 'My module' => $modulename,
609 'my module' => $modulename,
610 'Mon module' => $modulename,
611 'mon module' => $modulename,
612 'htdocs/modulebuilder/template' => strtolower($modulename),
613 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
619 $langs->load(
"errors");
620 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
626if ($dirins && $action ==
'inittrigger' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
627 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
628 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
629 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
630 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
631 $result =
dol_copy($srcfile, $destfile,
'0', 0);
634 $modulename = ucfirst($module);
637 $arrayreplacement = array(
638 'mymodule' => strtolower($modulename),
639 'MyModule' => $modulename,
640 'MYMODULE' => strtoupper($modulename),
641 'My module' => $modulename,
642 'my module' => $modulename,
643 'Mon module' => $modulename,
644 'mon module' => $modulename,
645 'htdocs/modulebuilder/template' => strtolower($modulename),
646 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
652 $langs->load(
"errors");
653 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
659if ($dirins && $action ==
'initwidget' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
660 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
661 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
662 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
663 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
664 $result =
dol_copy($srcfile, $destfile,
'0', 0);
667 $modulename = ucfirst($module);
670 $arrayreplacement = array(
671 'mymodule' => strtolower($modulename),
672 'MyModule' => $modulename,
673 'MYMODULE' => strtoupper($modulename),
674 'My module' => $modulename,
675 'my module' => $modulename,
676 'Mon module' => $modulename,
677 'mon module' => $modulename,
678 'htdocs/modulebuilder/template' => strtolower($modulename),
679 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
685 $langs->load(
"errors");
686 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
692if ($dirins && $action ==
'initemailing' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
693 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
694 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
695 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
696 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
697 $result =
dol_copy($srcfile, $destfile,
'0', 0);
700 $modulename = ucfirst($module);
703 $arrayreplacement = array(
704 'mymodule' => strtolower($modulename),
705 'MyModule' => $modulename,
706 'MYMODULE' => strtoupper($modulename),
707 'My module' => $modulename,
708 'my module' => $modulename,
709 'Mon module' => $modulename,
710 'mon module' => $modulename,
711 'htdocs/modulebuilder/template' => strtolower($modulename),
712 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
718 $langs->load(
"errors");
719 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
725if ($dirins && $action ==
'initcss' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
726 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
727 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
728 $srcfile = $srcdir.
'/css/mymodule.css.php';
729 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
730 $result =
dol_copy($srcfile, $destfile,
'0', 0);
733 $modulename = ucfirst($module);
736 $arrayreplacement = array(
737 'mymodule' => strtolower($modulename),
738 'MyModule' => $modulename,
739 'MYMODULE' => strtoupper($modulename),
740 'My module' => $modulename,
741 'my module' => $modulename,
742 'Mon module' => $modulename,
743 'mon module' => $modulename,
744 'htdocs/modulebuilder/template' => strtolower($modulename),
745 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
752 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
753 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
756 $langs->load(
"errors");
757 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
763if ($dirins && $action ==
'initjs' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
764 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
765 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
766 $srcfile = $srcdir.
'/js/mymodule.js.php';
767 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
768 $result =
dol_copy($srcfile, $destfile,
'0', 0);
771 $modulename = ucfirst($module);
774 $arrayreplacement = array(
775 'mymodule' => strtolower($modulename),
776 'MyModule' => $modulename,
777 'MYMODULE' => strtoupper($modulename),
778 'My module' => $modulename,
779 'my module' => $modulename,
780 'Mon module' => $modulename,
781 'mon module' => $modulename,
782 'htdocs/modulebuilder/template' => strtolower($modulename),
783 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
790 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
791 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
794 $langs->load(
"errors");
795 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
801if ($dirins && $action ==
'initcli' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
802 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
803 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
804 $srcfile = $srcdir.
'/scripts/mymodule.php';
805 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
806 $result =
dol_copy($srcfile, $destfile,
'0', 0);
809 $modulename = ucfirst($module);
812 $arrayreplacement = array(
813 'mymodule' => strtolower($modulename),
814 'MyModule' => $modulename,
815 'MYMODULE' => strtoupper($modulename),
816 'My module' => $modulename,
817 'my module' => $modulename,
818 'Mon module' => $modulename,
819 'mon module' => $modulename,
820 'htdocs/modulebuilder/template' => strtolower($modulename),
821 '__MYCOMPANY_NAME__' => $mysoc->name,
822 '__KEYWORDS__' => $modulename,
823 '__USER_FULLNAME__' => $user->getFullName($langs),
824 '__USER_EMAIL__' => $user->email,
826 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
832 $langs->load(
"errors");
833 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
838$moduledescriptorfile =
'/not_set/';
841if ($dirins && $action ==
'initdoc' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
842 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
843 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
844 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
845 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
846 $result =
dol_copy($srcfile, $destfile,
'0', 0);
849 $modulename = ucfirst($module);
850 $modulelowercase = strtolower($module);
853 $arrayreplacement = array(
854 'mymodule' => strtolower($modulename),
855 'MyModule' => $modulename,
856 'MYMODULE' => strtoupper($modulename),
857 'My module' => $modulename,
858 'my module' => $modulename,
859 'Mon module' => $modulename,
860 'mon module' => $modulename,
861 'htdocs/modulebuilder/template' => strtolower($modulename),
862 '__MYCOMPANY_NAME__' => $mysoc->name,
863 '__KEYWORDS__' => $modulename,
864 '__USER_FULLNAME__' => $user->getFullName($langs),
865 '__USER_EMAIL__' => $user->email,
867 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
874 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
875 $destdir = $dirins.
'/'.strtolower($module);
877 foreach ($objects as $path => $obj) {
882 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
886 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
887 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
892 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
893 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
894 $string = file_get_contents($changeLog);
896 $replace = explode(
"\n", $string);
897 $strreplace = array();
898 foreach ($replace as $line) {
902 if (strpos($line,
'##') !==
false) {
903 $strreplace[$line] = str_replace(
'##',
'', $line);
905 $strreplace[$line] = $line;
908 $stringLog = implode(
"\n", $strreplace);
910 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
914 $FILENAMEDOC = $modulelowercase.
'.html';
915 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
916 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
917 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
918 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
919 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
924 $langs->load(
"errors");
925 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
931if ($dirins && $action ==
'addlanguage' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
932 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
935 $modulelowercase = strtolower($module);
940 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
942 $diroflang = $dolibarr_main_document_root;
944 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
945 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
947 $result =
dol_copy($srcfile, $destfile,
'0', 0);
949 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
952 $srcdir = $diroflang.
'/langs/en_US';
953 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
954 $destdir = $diroflang.
'/langs/'.$newlangcode;
956 $arrayofreplacement = array();
958 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
959 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
961 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
964 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
970if ($dirins && $action ==
'confirm_removefile' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
971 $objectname = $tabobj;
972 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
973 $destdir = $dirins.
'/'.strtolower($module);
978 if ($relativefilename) {
979 $dirnametodelete = dirname($relativefilename);
980 $filetodelete = $dirins.
'/'.$relativefilename;
981 $dirtodelete = $dirins.
'/'.$dirnametodelete;
986 $keyofobjecttodelete = array_search($objectname, $objects);
987 if ($keyofobjecttodelete !==
false) {
988 unset($objects[$keyofobjecttodelete]);
992 if (strpos($relativefilename,
'api') !==
false) {
993 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
997 if (count($objects) == 0) {
1009 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1012 if (preg_match(
'/\.sql$/', $relativefilename)) {
1013 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1014 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1015 $filetodelete = $dirins.
'/'.$relativefilename;
1017 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1018 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1019 $filetodelete = $dirins.
'/'.$relativefilename;
1029 if (in_array($tab, array(
'css',
'js'))) {
1030 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1031 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1035 if (preg_match(
'/_extrafields/', $relativefilename)) {
1037 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1038 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1043 $varnametoupdate =
'';
1045 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1046 $varnametoupdate =
'showtabofpage'.$reg[1];
1048 if ($varnametoupdate) {
1049 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1050 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1058if ($dirins && $action ==
'initobject' && $module && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
1061 $objectname = ucfirst($objectname);
1063 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1064 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1066 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1068 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1069 $tabobj =
'newobject';
1071 if (class_exists($objectname)) {
1074 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1075 $tabobj =
'newobject';
1078 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1079 $destdir = $dirins.
'/'.strtolower($module);
1090 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1091 $alreadyfound =
false;
1092 foreach ($dirlist as $key => $val) {
1093 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1094 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1095 $alreadyfound =
true;
1097 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1105 $stringforproperties =
'';
1106 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1108 $_results = $db->DDLDescTable($tablename);
1109 if (empty($_results)) {
1111 $langs->load(
"errors");
1112 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1161 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1162 $stringforproperties .=
'public $fields = array('.
"\n";
1164 while ($obj = $db->fetch_object($_results)) {
1166 $fieldname = $obj->Field;
1169 if ($type ==
'int(11)') {
1172 if ($type ==
'float') {
1175 if (strstr($type,
'tinyint')) {
1178 if ($obj->Field ==
'fk_soc') {
1179 $type =
'integer:Societe:societe/class/societe.class.php';
1181 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1182 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1184 if (preg_match(
'/^fk_prod/', $obj->Field)) {
1185 $type =
'integer:Product:product/class/product.class.php:1';
1187 if ($obj->Field ==
'fk_warehouse') {
1188 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1190 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1191 $type =
'integer:User:user/class/user.class.php';
1195 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1196 if ($fieldname ==
'fk_user_modif') {
1200 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1201 if ($fieldname ==
'rowid') {
1202 $label =
'TechnicalID';
1204 if ($fieldname ==
'import_key') {
1205 $label =
'ImportId';
1207 if ($fieldname ==
'fk_soc') {
1208 $label =
'ThirdParty';
1210 if ($fieldname ==
'tms') {
1211 $label =
'DateModification';
1213 if ($fieldname ==
'datec') {
1214 $label =
'DateCreation';
1216 if ($fieldname ==
'date_valid') {
1217 $label =
'DateValidation';
1219 if ($fieldname ==
'datev') {
1220 $label =
'DateValidation';
1222 if ($fieldname ==
'note_private') {
1223 $label =
'NotePublic';
1225 if ($fieldname ==
'note_public') {
1226 $label =
'NotePrivate';
1228 if ($fieldname ==
'fk_user_creat') {
1229 $label =
'UserAuthor';
1231 if ($fieldname ==
'fk_user_modif') {
1232 $label =
'UserModif';
1234 if ($fieldname ==
'fk_user_valid') {
1235 $label =
'UserValidation';
1239 if (in_array($fieldname, array(
'ref',
'label'))) {
1242 if ($fieldname ==
'entity') {
1245 if ($fieldname ==
'entity') {
1248 if ($fieldname ==
'import_key') {
1251 if ($fieldname ==
'fk_user_creat') {
1254 if ($fieldname ==
'fk_user_modif') {
1257 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1264 if ($fieldname ==
'entity') {
1269 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1272 if ($fieldname ==
'import_key') {
1276 if ($fieldname ==
'label') {
1277 $alwayseditable = 1;
1279 $alwayseditable = 0;
1283 if ($fieldname ==
'entity') {
1290 if (preg_match(
'/^fk_/', $fieldname)) {
1291 $css =
'maxwidth500 widthcentpercentminusxx';
1293 if ($fieldname ==
'label') {
1294 $css =
'minwidth300';
1295 $cssview =
'wordbreak';
1297 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1298 $cssview =
'wordbreak';
1300 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1301 $csslist =
'tdoverflowmax150';
1305 $picto = $obj->Picto;
1306 if ($obj->Field ==
'fk_soc') {
1309 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1314 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1315 if ($default !=
'') {
1316 $stringforproperties .=
" 'default' => ".$default.
",";
1318 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1319 $stringforproperties .=
" 'visible' => ".$visible;
1321 $stringforproperties .=
", 'notnull' => ".$notnull;
1323 if ($alwayseditable) {
1324 $stringforproperties .=
", 'alwayseditable' => 1";
1326 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1327 $stringforproperties .=
", 'showoncombobox' => 1";
1329 $stringforproperties .=
", 'position' => ".$position;
1331 $stringforproperties .=
", 'index' => ".$index;
1334 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1337 $stringforproperties .=
", 'css' => '".$css.
"'";
1340 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1343 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1345 $stringforproperties .=
"),\n";
1348 $stringforproperties .=
');'.
"\n";
1349 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1353 $filetogenerate = array();
1356 $filetogenerate = array(
1357 'myobject_card.php' => strtolower($objectname).
'_card.php',
1358 'myobject_note.php' => strtolower($objectname).
'_note.php',
1359 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1360 'myobject_document.php' => strtolower($objectname).
'_document.php',
1361 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1362 'myobject_list.php' => strtolower($objectname).
'_list.php',
1363 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1364 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1366 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1367 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1368 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1369 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1371 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1375 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1376 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1378 $filetogenerate += array(
1379 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1380 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1381 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1384 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1385 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1386 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1388 $filetogenerate += array(
1389 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1390 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1393 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1394 $firstobjectname =
'myobject';
1395 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1397 $class =
'mod'.$module;
1399 if (class_exists($class)) {
1401 $moduleobj =
new $class($db);
1402 '@phan-var-force DolibarrModules $moduleobj';
1408 if (is_object($moduleobj)) {
1409 $rights = $moduleobj->rights;
1413 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1415 if ($checkComment < 0) {
1416 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1418 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1419 if ($generatePerms < 0) {
1420 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1426 foreach ($filetogenerate as $srcfile => $destfile) {
1427 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1431 $langs->load(
"errors");
1432 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1435 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1438 $arrayreplacement = array(
1439 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1440 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1443 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1448 if (!$error && $stringforproperties) {
1450 $arrayreplacement = array(
1451 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1454 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1458 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1460 $arrayreplacement = array(
1461 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1465 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1467 $arrayreplacement = array(
1468 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1470 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1474 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1476 $arrayreplacement = array(
1477 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1479 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1480 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'',
'0', 0, 1);
1482 $arrayreplacement = array(
1483 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1486 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1493 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1495 $firstobjectname =
'';
1496 foreach ($listofobject as $fileobj) {
1497 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1500 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1504 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1506 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1507 $objectnameloop = $reg[1];
1508 if (empty($firstobjectname)) {
1509 $firstobjectname = $objectnameloop;
1515 \$this->menu[\$r++] = array(
1516 'fk_menu' => 'fk_mainmenu=mymodule',
1518 'titre' => 'MyObject',
1519 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1520 'mainmenu' => 'mymodule',
1521 'leftmenu' => 'myobject',
1522 'url' => '/mymodule/myobject_list.php',
1523 'langs' => 'mymodule@mymodule',
1524 'position' => 1000 + \$r,
1525 'enabled' => 'isModEnabled(\"mymodule\")',
1526 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1529 'object' => 'MyObject'
1531 \$this->menu[\$r++] = array(
1532 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1534 'titre' => 'List MyObject',
1535 'mainmenu' => 'mymodule',
1536 'leftmenu' => 'mymodule_myobject_list',
1537 'url' => '/mymodule/myobject_list.php',
1538 'langs' => 'mymodule@mymodule',
1539 'position' => 1000 + \$r,
1540 'enabled' => 'isModEnabled(\"mymodule\")',
1541 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1544 'object' => 'MyObject'
1546 \$this->menu[\$r++] = array(
1547 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1549 'titre' => 'New MyObject',
1550 'mainmenu' => 'mymodule',
1551 'leftmenu' => 'mymodule_myobject_new',
1552 'url' => '/mymodule/myobject_card.php?action=create',
1553 'langs' => 'mymodule@mymodule',
1554 'position' => 1000 + \$r,
1555 'enabled' => 'isModEnabled(\"mymodule\")',
1556 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1559 'object' => 'MyObject'
1561 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1562 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1563 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1565 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1571 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1573 $class =
'mod'.$module;
1575 if (class_exists($class)) {
1577 $moduleobj =
new $class($db);
1578 '@phan-var-force DolibarrModules $moduleobj';
1584 if (is_object($moduleobj)) {
1585 $menus = $moduleobj->menu;
1590 foreach ($menus as $menu) {
1591 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1597 if ($checkComment < 0) {
1599 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1601 $arrayofreplacement = array(
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */' =>
'/* BEGIN MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.$stringtoadd.
"\n\t\t".
'/* END MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.
"\n\t\t".
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */');
1606 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1611 foreach ($filetogenerate as $destfile) {
1612 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1615 $arrayreplacement = array(
1616 'mymodule' => strtolower($module),
1617 'MyModule' => $module,
1618 'MYMODULE' => strtoupper($module),
1619 'My module' => $module,
1620 'my module' => $module,
1621 'mon module' => $module,
1622 'Mon module' => $module,
1623 'htdocs/modulebuilder/template/' => strtolower($modulename),
1624 'myobject' => strtolower($objectname),
1625 'MyObject' => $objectname,
1627 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
1631 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1637 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1646 if (is_numeric($object) && $object <= 0) {
1647 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1648 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1652 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1653 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1655 if (file_exists($destfile)) {
1661 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1670 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1671 $tabobj = $objectname;
1673 $tabobj =
'newobject';
1677 if (isModEnabled(strtolower($module))) {
1683 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1684 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1690if ($dirins && $action ==
'initdic' && $module && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
1691 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1692 $destdir = $dirins.
'/'.strtolower($module);
1693 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1697 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1701 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1704 $newdicname = $dicname;
1705 if (!preg_match(
'/^c_/', $newdicname)) {
1706 $newdicname =
'c_'.$dicname;
1709 $class =
'mod'.$module;
1711 if (class_exists($class)) {
1713 $moduleobj =
new $class($db);
1714 '@phan-var-force DolibarrModules $moduleobj';
1721 $langs->load(
"errors");
1722 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1725 $dictionaries = $moduleobj->dictionaries;
1727 if ($checkComment < 0) {
1728 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1731 if (function_exists(
'opcache_invalidate')) {
1734 clearstatcache(
true);
1735 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1742if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj) && $user->hasRight(
"modulebuilder",
"run")) {
1743 $objectname = $tabobj;
1745 $arrayoftables = array();
1746 if ($action ==
'droptable') {
1747 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1749 if ($action ==
'droptableextrafields') {
1750 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1753 foreach ($arrayoftables as $tabletodrop) {
1755 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1756 $resql = $db->query($sql);
1758 $obj = $db->fetch_object($resql);
1763 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1764 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1770 $resql = $db->DDLDropTable($tabletodrop);
1772 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1773 } elseif ($nb > 0) {
1774 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1779if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) && $user->hasRight(
"modulebuilder",
"run")) {
1784 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1785 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1787 $srcdir = $dirread.
'/'.strtolower($module);
1788 $destdir = $dirins.
'/'.strtolower($module);
1792 if (!in_array($objectname, array_values($objects))) {
1794 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1797 $addfieldentry = array();
1800 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1801 if (!
GETPOST(
'propname',
'aZ09')) {
1803 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1805 if (!
GETPOST(
'proplabel',
'alpha')) {
1807 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1809 if (!
GETPOST(
'proptype',
'alpha')) {
1811 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1815 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1816 $addfieldentry = array(
1817 'name' =>
GETPOST(
'propname',
'aZ09'),
1818 'label' =>
GETPOST(
'proplabel',
'alpha'),
1819 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1820 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'alphawithlgt'),
1821 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1822 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1826 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1828 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1829 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1830 'help' =>
GETPOST(
'prophelp',
'alpha'),
1831 'css' =>
GETPOST(
'propcss',
'alpha'),
1832 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1833 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1834 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1835 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
1840 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1841 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1843 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1846 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1858 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1864 if (is_numeric($object) && $object <= 0) {
1865 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1866 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1873 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1876 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1882 clearstatcache(
true);
1884 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1889 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1894if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey && $user->hasRight(
"modulebuilder",
"run")) {
1895 $objectname = $tabobj;
1897 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1898 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1900 $srcdir = $dirread.
'/'.strtolower($module);
1901 $destdir = $dirins.
'/'.strtolower($module);
1908 if (is_numeric($object) && $object <= 0) {
1909 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1910 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1917 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1920 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1926 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1928 clearstatcache(
true);
1931 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1936if ($dirins && $action ==
'confirm_deletemodule' && $user->hasRight(
"modulebuilder",
"run")) {
1937 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1939 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1943 $modulelowercase = strtolower($module);
1946 $dir = $dirins.
'/'.$modulelowercase;
1948 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1958 $class =
'mod'.$module;
1962 if (class_exists($class)) {
1964 $moduleobj =
new $class($db);
1965 '@phan-var-force DolibarrMOdules $moduleobj';
1972 $langs->load(
"errors");
1973 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
1977 $moduleobj->remove();
1985 clearstatcache(
true);
1986 if (function_exists(
'opcache_invalidate')) {
1990 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
1998 $module =
'deletemodule';
2001if ($dirins && $action ==
'confirm_deleteobject' && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
2002 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2004 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2008 $modulelowercase = strtolower($module);
2009 $objectlowercase = strtolower($objectname);
2012 $dir = $dirins.
'/'.$modulelowercase;
2015 $filetodelete = array(
2016 'myobject_card.php' => strtolower($objectname).
'_card.php',
2017 'myobject_note.php' => strtolower($objectname).
'_note.php',
2018 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
2019 'myobject_document.php' => strtolower($objectname).
'_document.php',
2020 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
2021 'myobject_list.php' => strtolower($objectname).
'_list.php',
2022 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
2023 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
2024 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
2025 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
2026 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
2027 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
2028 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
2029 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
2030 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
2031 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2032 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2033 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2034 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2035 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2036 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2041 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2043 $class =
'mod'.$module;
2045 if (class_exists($class)) {
2047 $moduleobj =
new $class($db);
2048 '@phan-var-force DolibarrMOdules $moduleobj';
2054 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2057 $menus = $moduleobj->menu;
2060 if ($rewriteMenu < 0) {
2061 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2063 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2067 $permissions = $moduleobj->rights;
2069 if ($rewritePerms < 0) {
2070 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2074 if ($rewritePerms && $rewriteMenu) {
2076 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2079 clearstatcache(
true);
2080 if (function_exists(
'opcache_invalidate')) {
2084 foreach ($filetodelete as $tmpfiletodelete) {
2086 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2092 if ($resultko == 0) {
2095 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2102 $tabobj =
'newobject';
2104 $tabobj =
'deleteobject';
2108 if (isModEnabled(strtolower($module))) {
2114 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2115 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2120if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) && $user->hasRight(
"modulebuilder",
"run")) {
2121 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2122 $destdir = $dirins.
'/'.strtolower($module);
2123 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2125 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2127 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2130 if (!empty($dicname)) {
2131 $newdicname = $dicname;
2132 if (!preg_match(
'/^c_/', $newdicname)) {
2133 $newdicname =
'c_'.strtolower($dicname);
2140 $class =
'mod'.$module;
2142 if (class_exists($class)) {
2144 $moduleobj =
new $class($db);
2145 '@phan-var-force DolibarrModules $moduleobj';
2152 $langs->load(
"errors");
2153 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2157 $dicts = $moduleobj->dictionaries;
2159 if ($checkComment < 0) {
2161 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2164 if (!empty(
GETPOST(
'dictionnarykey'))) {
2165 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2169 $checkTable =
false;
2170 if ($newdicname !==
null) {
2171 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2174 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2179 $keyToDelete =
null;
2180 foreach ($dicts[
'tabname'] as $key => $table) {
2182 if (strtolower($table) === $newdicname) {
2183 $keyToDelete = $key;
2188 if ($keyToDelete !==
null) {
2189 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2190 foreach ($keysToDelete as $key) {
2191 unset($dicts[$key][$keyToDelete]);
2195 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2199 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2200 if ($_results < 0) {
2202 $langs->load(
"errors");
2203 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2208 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2210 if (function_exists(
'opcache_invalidate')) {
2213 clearstatcache(
true);
2214 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2218if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') && $user->hasRight(
"modulebuilder",
"run")) {
2219 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2221 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2222 $destdir = $dirins.
'/'.strtolower($module);
2223 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2225 $class =
'mod'.$module;
2227 if (class_exists($class)) {
2229 $moduleobj =
new $class($db);
2230 '@phan-var-force DolibarrMOdules $moduleobj';
2237 $langs->load(
"errors");
2238 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2242 $dicts = $moduleobj->dictionaries;
2243 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2244 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2246 if ($checkComment < 0) {
2247 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2250 if ($updateDict > 0) {
2253 if (function_exists(
'opcache_invalidate')) {
2256 clearstatcache(
true);
2257 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2263if ($dirins && $action ==
'generatedoc' && $user->hasRight(
"modulebuilder",
"run")) {
2264 $modulelowercase = strtolower($module);
2269 $FILENAMEDOC = strtolower($module).
'.html';
2271 $util =
new Utils($db);
2272 $result = $util->generateDoc($module);
2275 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2281if ($dirins && $action ==
'generatepackage' && $user->hasRight(
"modulebuilder",
"run")) {
2282 $modulelowercase = strtolower($module);
2284 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2294 $class =
'mod'.$module;
2296 if (class_exists($class)) {
2298 $moduleobj =
new $class($db);
2299 '@phan-var-force DolibarrMOdules $moduleobj';
2306 $langs->load(
"errors");
2307 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2311 $arrayversion = explode(
'.', $moduleobj->version, 3);
2312 if (count($arrayversion)) {
2313 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2316 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2322 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2328 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2331 $langs->load(
"errors");
2332 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2336 $langs->load(
"errors");
2337 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2342if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2346 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2348 $class =
'mod'.$module;
2350 if (class_exists($class)) {
2352 $moduleobj =
new $class($db);
2353 '@phan-var-force DolibarrModules $moduleobj';
2361 if (!
GETPOST(
'label',
'alpha')) {
2363 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2365 if (!
GETPOST(
'permissionObj',
'alpha')) {
2367 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2371 $label =
GETPOST(
'label',
'alpha');
2372 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2373 $crud =
GETPOST(
'crud',
'alpha');
2377 $permsForObject = array();
2378 if (is_object($moduleobj)) {
2379 $permissions = $moduleobj->rights;
2381 $permissions = array();
2383 $allObject = array();
2385 $countPerms = count($permissions);
2387 for ($i = 0; $i < $countPerms; $i++) {
2388 if ($permissions[$i][4] == $objectForPerms) {
2390 if (count($permsForObject) < 3) {
2391 $permsForObject[] = $permissions[$i];
2394 $allObject[] = $permissions[$i][4];
2398 $countPermsObj = count($permsForObject);
2399 for ($j = 0; $j < $countPermsObj; $j++) {
2400 if (in_array($crud, $permsForObject[$j])) {
2402 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2406 $rightToAdd = array();
2408 $key = $countPerms + 1;
2410 $rightToAdd = array(
2413 4 => $objectForPerms,
2417 if (isModEnabled(strtolower($module))) {
2423 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2426 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2430 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2435 clearstatcache(
true);
2436 if (function_exists(
'opcache_invalidate')) {
2439 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2446if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2449 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2451 $class =
'mod'.$module;
2453 if (class_exists($class)) {
2455 $moduleobj =
new $class($db);
2456 '@phan-var-force DolibarrModules $moduleobj';
2463 if (!
GETPOST(
'label',
'alpha')) {
2465 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2467 if (!
GETPOST(
'permissionObj',
'alpha')) {
2469 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2472 $label =
GETPOST(
'label',
'alpha');
2473 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2474 $crud =
GETPOST(
'crud',
'alpha');
2477 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2481 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2485 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2490 if (is_object($moduleobj)) {
2491 $permissions = $moduleobj->rights;
2497 if (array_key_exists($key, $permissions)) {
2498 $x1 = $permissions[$key][1];
2499 $x2 = $permissions[$key][4];
2500 $x3 = $permissions[$key][5];
2508 $permsForObject = array();
2512 $allObject = array();
2514 $countPerms = count($permissions);
2515 for ($i = 0; $i < $countPerms; $i++) {
2516 if ($permissions[$i][4] == $objectForPerms) {
2518 if (count($permsForObject) < 3) {
2519 $permsForObject[] = $permissions[$i];
2522 $allObject[] = $permissions[$i][4];
2525 if ($label != $x1 && $crud != $x3) {
2526 $countPermsObj = count($permsForObject);
2527 for ($j = 0; $j < $countPermsObj; $j++) {
2528 if (in_array($label, $permsForObject[$j])) {
2530 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2536 if (isModEnabled(strtolower($module))) {
2542 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2545 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2549 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2551 $rightUpdated =
null;
2554 clearstatcache(
true);
2555 if (function_exists(
'opcache_invalidate')) {
2558 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2564if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey') && $user->hasRight(
"modulebuilder",
"run")) {
2567 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2569 $class =
'mod'.$module;
2571 if (class_exists($class)) {
2573 $moduleobj =
new $class($db);
2574 '@phan-var-force DolibarrMOdules $moduleobj';
2581 $permissions = $moduleobj->rights;
2586 if (isModEnabled(strtolower($module))) {
2592 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2593 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2598 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2601 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2606 clearstatcache(
true);
2607 if (function_exists(
'opcache_invalidate')) {
2611 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2617if ($action ==
'savefile' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2618 $relofcustom = basename($dirins);
2622 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2623 $file = $relofcustom.
'/'.$file;
2631 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2634 $check =
'restricthtml';
2636 if ($srclang ==
'md') {
2637 $check =
'restricthtml';
2639 if ($srclang ==
'lang') {
2640 $check =
'restricthtml';
2642 if ($srclang ==
'php') {
2646 $content =
GETPOST(
'editfilecontent', $check);
2651 $result = file_put_contents($pathoffile, $content);
2668if ($action ==
'set' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2671 $param .=
'&module='.urlencode($module);
2674 $param .=
'&tab='.urlencode($tab);
2677 $param .=
'&tabobj='.urlencode($tabobj);
2680 $value =
GETPOST(
'value',
'alpha');
2682 if (!empty($resarray[
'errors'])) {
2686 if ($resarray[
'nbperms'] > 0) {
2687 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2688 $resqltmp = $db->query($tmpsql);
2690 $obj = $db->fetch_object($resqltmp);
2692 if ($obj && $obj->nb > 1) {
2693 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2701 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2706if ($action ==
'reset' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2709 $param .=
'&module='.urlencode($module);
2712 $param .=
'&tab='.urlencode($tab);
2715 $param .=
'&tabobj='.urlencode($tabobj);
2718 $value =
GETPOST(
'value',
'alpha');
2723 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2728if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') && $user->hasRight(
"modulebuilder",
"run")) {
2730 if (isModEnabled(strtolower($module))) {
2736 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2737 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2741 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2743 $class =
'mod'.$module;
2745 if (class_exists($class)) {
2747 $moduleobj =
new $class($db);
2748 '@phan-var-force DolibarrMOdules $moduleobj';
2755 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2756 $destdir = $dir.
'/'.strtolower($module);
2758 $result = array_map(
'strtolower', $objects);
2760 $menus = $moduleobj->menu;
2762 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2765 if ($checkcomment < 0) {
2766 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2768 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2769 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2770 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2778 clearstatcache(
true);
2779 if (function_exists(
'opcache_invalidate')) {
2784 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2790if ($dirins && $action ==
'addmenu' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2792 if (isModEnabled(strtolower($module))) {
2798 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2799 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2805 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2807 $class =
'mod'.$module;
2809 if (class_exists($class)) {
2811 $moduleobj =
new $class($db);
2812 '@phan-var-force DolibarrMOdules $moduleobj';
2819 $menus = $moduleobj->menu;
2822 if (!
GETPOST(
'type',
'alpha')) {
2824 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2826 if (!
GETPOST(
'titre',
'alpha')) {
2828 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2830 if (!
GETPOST(
'user',
'alpha')) {
2832 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2834 if (!
GETPOST(
'url',
'alpha')) {
2836 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2838 if (!empty(
GETPOST(
'target'))) {
2839 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2840 if (!in_array(
GETPOST(
'target'), $targets)) {
2842 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2849 foreach ($menus as $menu) {
2852 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2855 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2857 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2862 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2863 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2865 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2868 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2869 $destdir = $dirins.
'/'.strtolower($module);
2872 if (
GETPOST(
'type',
'alpha') ==
'left') {
2873 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2875 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2878 if (
GETPOST(
'type',
'alpha') ==
'top') {
2880 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2883 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2887 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2888 'type' =>
GETPOST(
'type',
'alpha'),
2889 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2891 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2892 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2893 'url' =>
GETPOST(
'url',
'alpha'),
2894 'langs' => strtolower($module).
"@".strtolower($module),
2896 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2897 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2898 'target' =>
GETPOST(
'target',
'alpha'),
2899 'user' =>
GETPOST(
'user',
'alpha'),
2902 if (
GETPOST(
'type') ==
'left') {
2903 unset($menuToAdd[
'prefix']);
2904 if (empty(
GETPOST(
'fk_menu'))) {
2905 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2907 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2910 if (
GETPOST(
'enabled') ==
'1') {
2911 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2913 $menuToAdd[
'enabled'] =
"0";
2915 if (empty(
GETPOST(
'objects'))) {
2916 $menuToAdd[
'perms'] =
'1';
2920 if ($checkcomment < 0) {
2921 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2924 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2926 clearstatcache(
true);
2927 if (function_exists(
'opcache_invalidate')) {
2936 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2944if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') && $user->hasRight(
"modulebuilder",
"run")) {
2945 $objectname =
GETPOST(
'tabobj');
2946 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2947 $destdir = $dirins.
'/'.strtolower($module);
2950 if (empty($cancel)) {
2951 if (isModEnabled(strtolower($module))) {
2957 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2958 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2963 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2965 $class =
'mod'.$module;
2967 if (class_exists($class)) {
2969 $moduleobj =
new $class($db);
2970 '@phan-var-force DolibarrMOdules $moduleobj';
2976 $menus = $moduleobj->menu;
2979 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2981 $menuModify = array(
2982 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2983 'type' =>
GETPOST(
'type',
'alpha'),
2984 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2985 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2986 'leftmenu' => $menus[$key][
'leftmenu'],
2987 'url' =>
GETPOST(
'url',
'alpha'),
2988 'langs' => strtolower($module).
"@".strtolower($module),
2990 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2991 'perms' =>
GETPOST(
'perms',
'alpha'),
2992 'target' =>
GETPOST(
'target',
'alpha'),
2993 'user' =>
GETPOST(
'user',
'alpha'),
2995 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
2996 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2997 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
2998 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3000 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3002 if ($menuModify[
'enabled'] ===
'') {
3003 $menuModify[
'enabled'] =
'1';
3005 if ($menuModify[
'perms'] ===
'') {
3006 $menuModify[
'perms'] =
'1';
3009 if (
GETPOST(
'type',
'alpha') ==
'top') {
3011 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3018 if ($checkComment < 0) {
3019 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3022 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3024 clearstatcache(
true);
3025 if (function_exists(
'opcache_invalidate')) {
3032 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?action=editmenu&token='.
newToken().
'&menukey='.urlencode((
string) ($key + 1)).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.($key + 1));
3037 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3042 $_POST[
'type'] =
'';
3043 $_POST[
'titre'] =
'';
3044 $_POST[
'fk_menu'] =
'';
3045 $_POST[
'leftmenu'] =
'';
3051if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
3052 if (isModEnabled(strtolower($module))) {
3058 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3059 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3062 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3063 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3064 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
3068 $class =
'mod'.$module;
3070 if (class_exists($class)) {
3072 $moduleobj =
new $class($db);
3073 '@phan-var-force DolibarrMOdules $moduleobj';
3080 $keydescription =
GETPOST(
'keydescription',
'alpha');
3081 switch ($keydescription) {
3083 $propertyToUpdate =
'description';
3090 $propertyToUpdate = $keydescription;
3093 $error =
GETPOST(
'keydescription');
3097 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3098 $newValue =
GETPOST(
'propsmodule');
3099 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3100 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3103 if ($propertyToUpdate ===
'version') {
3104 dolReplaceInFile($modulelogfile, array(
"## ".$moduleobj->$propertyToUpdate => $newValue));
3107 $fileLines = file($moduledescriptorfile);
3108 foreach ($fileLines as &$line) {
3109 if (strpos($line, $lineToReplace) === 0) {
3115 clearstatcache(
true);
3116 if (function_exists(
'opcache_invalidate')) {
3119 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3120 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3130$form =
new Form($db);
3141 '/includes/ace/src/ace.js',
3142 '/includes/ace/src/ext-statusbar.js',
3143 '/includes/ace/src/ext-language_tools.js',
3148llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3151$text = $langs->trans(
"ModuleBuilder");
3155print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
3156print
'<br class="hideonsmartphone">';
3165 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3170 $langs->load(
"errors");
3171 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3175 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3184$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3188$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3189$allowonlineinstall =
true;
3190if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3191 $allowonlineinstall =
false;
3193if (empty($allowonlineinstall)) {
3196 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3199 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3214if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3215 $modulelowercase = strtolower($module);
3216 $loadclasserrormessage =
'';
3220 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3225 $class =
'mod'.$module;
3226 }
catch (Throwable $e) {
3227 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3228 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3229 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3233 if (class_exists($class)) {
3235 $moduleobj =
new $class($db);
3236 '@phan-var-force DolibarrMOdules $moduleobj';
3239 print $e->getMessage();
3242 if (empty($forceddirread)) {
3245 $langs->load(
"errors");
3246 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3247 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3248 print $loadclasserrormessage;
3259$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3260$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3261$head[$h][2] =
'initmodule';
3264$linktoenabledisable =
'';
3266if (is_array($listofmodules) && count($listofmodules) > 0) {
3268 $modulelowercase = strtolower($module);
3272 $param .=
'&tab='.urlencode($tab);
3275 $param .=
'&module='.urlencode($module);
3278 $param .=
'&tabobj='.urlencode($tabobj);
3281 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3284 if (isModEnabled($modulelowercase)) {
3285 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3286 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'', 0, 0, 0,
'',
'', 1);
3287 $linktoenabledisable .=
'</a>';
3289 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3291 $objMod = $moduleobj;
3292 $backtourlparam =
'';
3293 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3295 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3297 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3300 if (is_array($objMod->config_page_url)) {
3302 foreach ($objMod->config_page_url as $page) {
3305 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3308 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3309 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3310 $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>';
3314 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3315 $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>';
3319 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3320 $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>';
3323 if (is_object($moduleobj)) {
3324 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3325 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip', 1);
3326 $linktoenabledisable .=
"</a>\n";
3331 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3332 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3333 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3334 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3336 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3337 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3344$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3345$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3346$head[$h][2] =
'deletemodule';
3352if ($module ==
'initmodule') {
3354 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3355 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3356 print
'<input type="hidden" name="action" value="initmodule">';
3357 print
'<input type="hidden" name="module" value="initmodule">';
3362 print
'<div class="tagtable">';
3364 print
'<div class="tagtr"><div class="tagtd paddingright">';
3365 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3366 print
'</div><div class="tagtd">';
3367 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
3368 print
'<span class="opacitymedium">';
3370 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3372 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3375 print
'</div></div>';
3377 print
'<div class="tagtr"><div class="tagtd paddingright">';
3378 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3379 print
'</div><div class="tagtd">';
3380 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3381 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3382 print
'</div></div>';
3384 print
'<div class="tagtr"><div class="tagtd paddingright">';
3385 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3386 print
'</div><div class="tagtd">';
3387 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3388 print
'</div></div>';
3390 print
'<div class="tagtr"><div class="tagtd paddingright">';
3391 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3392 print
'</div><div class="tagtd">';
3393 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")).
'">';
3394 print
'</div></div>';
3396 print
'<div class="tagtr"><div class="tagtd paddingright">';
3397 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3398 print
'</div><div class="tagtd">';
3399 print
'<select name="family" id="family" class="minwidth400">';
3400 $arrayoffamilies = array(
3401 'hr' =>
"ModuleFamilyHr",
3402 'crm' =>
"ModuleFamilyCrm",
3403 'srm' =>
"ModuleFamilySrm",
3404 'financial' =>
'ModuleFamilyFinancial',
3405 'products' =>
'ModuleFamilyProducts',
3406 'projects' =>
'ModuleFamilyProjects',
3407 'ecm' =>
'ModuleFamilyECM',
3408 'technic' =>
'ModuleFamilyTechnic',
3409 'portal' =>
'ModuleFamilyPortal',
3410 'interface' =>
'ModuleFamilyInterface',
3411 'base' =>
'ModuleFamilyBase',
3412 'other' =>
'ModuleFamilyOther'
3414 foreach ($arrayoffamilies as $key => $value) {
3415 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>';
3419 print
'</div></div>';
3421 print
'<div class="tagtr"><div class="tagtd paddingright">';
3422 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3423 print
'</div><div class="tagtd">';
3424 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file-o')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3425 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3426 print
'</div></div>';
3428 print
'<div class="tagtr"><div class="tagtd paddingright">';
3429 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3430 print
'</div><div class="tagtd">';
3431 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>';
3432 print
'</div></div>';
3434 print
'<div class="tagtr"><div class="tagtd paddingright">';
3435 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3436 print
'</div><div class="tagtd">';
3437 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>';
3438 print
'</div></div>';
3440 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3442} elseif ($module ==
'deletemodule') {
3443 print
'<!-- Form to init a module -->'.
"\n";
3444 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3445 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3446 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3447 print
'<input type="hidden" name="module" value="deletemodule">';
3449 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3451 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3452 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3454} elseif (!empty($module)) {
3457 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3458 $destdir = $dirread.
'/'.strtolower($module);
3462 $countDictionaries = (!empty($moduleobj->dictionaries) ? count($moduleobj->dictionaries[
'tabname']) : 0);
3463 $countRights = count($moduleobj->rights);
3464 $countMenus = count($moduleobj->menu);
3476 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3477 $head2[$h][1] = $langs->trans(
"Description");
3478 $head2[$h][2] =
'description';
3481 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3482 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3483 $head2[$h][2] =
'objects';
3486 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3487 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3488 $head2[$h][2] =
'languages';
3491 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3492 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3493 $head2[$h][2] =
'dictionaries';
3496 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3497 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3498 $head2[$h][2] =
'permissions';
3501 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3502 $head2[$h][1] = $langs->trans(
"Tabs");
3503 $head2[$h][2] =
'tabs';
3506 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3507 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3508 $head2[$h][2] =
'menus';
3511 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3512 $head2[$h][1] = $langs->trans(
"Hooks");
3513 $head2[$h][2] =
'hooks';
3516 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3517 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3518 $head2[$h][2] =
'triggers';
3521 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3522 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3523 $head2[$h][2] =
'widgets';
3526 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3527 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3528 $head2[$h][2] =
'emailings';
3531 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3532 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3533 $head2[$h][2] =
'exportimport';
3536 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3537 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3538 $head2[$h][2] =
'css';
3541 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3542 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3543 $head2[$h][2] =
'js';
3546 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3547 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3548 $head2[$h][2] =
'cli';
3551 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3552 $head2[$h][1] = $langs->trans(
"CronList");
3553 $head2[$h][2] =
'cron';
3556 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3557 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="paddingleft badge">'.$hasDoc.
"</span>");
3558 $head2[$h][2] =
'specifications';
3561 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3562 $head2[$h][1] = $langs->trans(
"BuildPackage");
3563 $head2[$h][2] =
'buildpackage';
3566 $MAXTABFOROBJECT = 15;
3568 print
'<!-- Section for a given module -->';
3572 if ($tab ==
'description') {
3573 print
'<!-- tab=description -->'.
"\n";
3574 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3575 $pathtofilereadme = $modulelowercase.
'/README.md';
3576 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3578 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3580 if ($action !=
'editfile' || empty($file)) {
3581 $morehtmlright =
'';
3582 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3583 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3586 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3588 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3594 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3595 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).
'&find=DESCRIPTION_FLAG">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3599 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3600 foreach ($listofsetuppages as $setuppage) {
3603 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SetupFile").
' : ';
3604 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3605 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($modulelowercase.
'/admin/'.$setuppage[
'relativename']).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3609 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3610 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>';
3613 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3614 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>';
3620 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3622 if (is_object($moduleobj)) {
3623 print
'<div class="underbanner clearboth"></div>';
3624 print
'<div class="fichecenter">';
3625 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3626 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3627 print
'<input type="hidden" name="action" value="update_props_module">';
3628 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3629 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3630 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3631 print
'<table class="border centpercent">';
3632 print
'<tr class="liste_titre"><td class="titlefield">';
3633 print $langs->trans(
"Parameter");
3635 print $langs->trans(
"Value");
3639 print $langs->trans(
"IdModule");
3641 print $moduleobj->numero;
3642 print
'<span class="opacitymedium">';
3644 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3645 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3650 print $langs->trans(
"ModuleName");
3652 print $moduleobj->getName();
3656 print $langs->trans(
"Description");
3658 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3659 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->description).
'">';
3660 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3661 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3663 print $moduleobj->description;
3664 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=desc">'.
img_edit().
'</a>';
3666 $moduledescritpionautotrans = $moduleobj->getDesc();
3667 if ($moduledescritpionautotrans !=
"Module".$moduleobj->name.
"Desc") {
3669 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3670 } elseif ($moduledescritpionautotrans !=
"Module".$moduleobj->numero.
"Desc") {
3672 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3678 print $langs->trans(
"Version");
3680 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3681 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->getVersion()).
'">';
3682 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3683 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3685 print $moduleobj->getVersion();
3686 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=version">'.
img_edit().
'</a>';
3691 print $langs->trans(
"Family");
3694 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3695 print
'<select name="propsmodule" id="family" class="minwidth400">';
3696 $arrayoffamilies = array(
3697 'hr' =>
"ModuleFamilyHr",
3698 'crm' =>
"ModuleFamilyCrm",
3699 'srm' =>
"ModuleFamilySrm",
3700 'financial' =>
'ModuleFamilyFinancial',
3701 'products' =>
'ModuleFamilyProducts',
3702 'projects' =>
'ModuleFamilyProjects',
3703 'ecm' =>
'ModuleFamilyECM',
3704 'technic' =>
'ModuleFamilyTechnic',
3705 'portal' =>
'ModuleFamilyPortal',
3706 'interface' =>
'ModuleFamilyInterface',
3707 'base' =>
'ModuleFamilyBase',
3708 'other' =>
'ModuleFamilyOther'
3710 print
'<option value="'.$moduleobj->family.
'" data-html="'.
dol_escape_htmltag($langs->trans($arrayoffamilies[$moduleobj->family]).
' <span class="opacitymedium">- '.$moduleobj->family.
'</span>').
'">'.$langs->trans($arrayoffamilies[$moduleobj->family]).
'</option>';
3711 foreach ($arrayoffamilies as $key => $value) {
3712 if ($key != $moduleobj->family) {
3713 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3717 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3718 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3720 print $moduleobj->family;
3721 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=family">'.
img_edit().
'</a>';
3726 print $langs->trans(
"Picto");
3728 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3729 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->picto).
'">';
3730 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3731 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3733 print $moduleobj->picto;
3734 print
' '.img_picto(
'', $moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3735 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_modulepicto&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=picto">'.
img_edit().
'</a>';
3740 print $langs->trans(
"EditorName");
3742 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3743 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_name).
'">';
3744 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3745 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3747 print $moduleobj->editor_name;
3748 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=editor_name">'.
img_edit().
'</a>';
3753 print $langs->trans(
"EditorUrl");
3755 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3756 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_url).
'">';
3757 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3758 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3760 if (!empty($moduleobj->editor_url)) {
3761 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3763 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=editor_url">'.
img_edit().
'</a>';
3770 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3773 if (!empty($moduleobj)) {
3777 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3779 print
'<!-- readme file -->';
3780 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3781 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3783 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3789 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3791 print
'<!-- changelog file -->';
3793 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3795 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3803 if ($fullpathoffile) {
3804 $content = file_get_contents($fullpathoffile);
3808 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3809 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3810 print
'<input type="hidden" name="action" value="savefile">';
3811 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3812 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3813 print
'<input type="hidden" name="module" value="'.$module.
'">';
3817 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
3818 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3819 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3824 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3826 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3832 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3835 if ($tab ==
'languages') {
3836 print
'<!-- tab=languages -->'.
"\n";
3837 if ($action !=
'editfile' || empty($file)) {
3838 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3842 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3843 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3844 print
'<input type="hidden" name="action" value="addlanguage">';
3845 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3846 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3847 print
'<input type="hidden" name="module" value="'.$module.
'">';
3848 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
3849 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3855 $modulelowercase = strtolower($module);
3859 $diroflang .=
'/langs';
3860 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3862 if (!preg_match(
'/custom/', $dirread)) {
3864 $diroflang = $dirread;
3865 $diroflang .=
'/langs';
3866 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3869 print
'<table class="none">';
3870 foreach ($langfiles as $langfile) {
3871 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3872 if (!preg_match(
'/custom/', $dirread)) {
3873 $pathtofile =
'langs/'.$langfile[
'relativename'];
3875 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3876 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>';
3877 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>';
3888 $content = file_get_contents($fullpathoffile);
3891 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3892 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3893 print
'<input type="hidden" name="action" value="savefile">';
3894 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3895 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3896 print
'<input type="hidden" name="module" value="'.$module.
'">';
3898 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3899 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3902 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3904 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3911 if ($tab ==
'objects') {
3912 print
'<!-- tab=objects -->'.
"\n";
3917 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3919 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3920 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3921 $head3[$h][2] =
'newobject';
3925 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3927 $firstobjectname =
'';
3928 foreach ($listofobject as $fileobj) {
3929 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3932 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3936 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3937 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3939 $objectname = $reg[1];
3940 if (empty($firstobjectname)) {
3941 $firstobjectname = $objectname;
3943 $pictoname =
'generic';
3944 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3945 $pictoname = $reg[1];
3948 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3949 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3950 $head3[$h][2] = $objectname;
3956 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
3957 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3958 $head3[$h][2] =
'deleteobject';
3963 if ($tabobj ==
'newobjectifnoobj') {
3964 if ($firstobjectname) {
3965 $tabobj = $firstobjectname;
3967 $tabobj =
'newobject';
3971 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
3974 if ($tabobj ==
'newobject') {
3976 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3977 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3978 print
'<input type="hidden" name="action" value="initobject">';
3979 print
'<input type="hidden" name="tab" value="objects">';
3980 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3982 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
3984 print
'<div class="tagtable">';
3986 print
'<div class="tagtr"><div class="tagtd">';
3987 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
3988 print
'</div><div class="tagtd">';
3989 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
3990 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
3991 print
'</div></div>';
3993 print
'<div class="tagtr"><div class="tagtd">';
3994 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
3995 print
'</div><div class="tagtd">';
3996 print
'<input type="text" name="idpicto" value="fa-file-o" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3997 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3998 print
'</div></div>';
4000 print
'<div class="tagtr"><div class="tagtd">';
4001 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4002 print
'</div><div class="tagtd">';
4003 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4004 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4005 print
'</div></div>';
4010 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>';
4011 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4012 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4014 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4030 } elseif ($tabobj ==
'createproperty') {
4031 $attributesUnique = array(
4032 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4033 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4034 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4035 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4036 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4037 'propdefault' => $langs->trans(
"DefaultValue"),
4038 'propindex' => $langs->trans(
"DatabaseIndex"),
4039 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4040 'propposition' => $langs->trans(
"Position"),
4041 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4042 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4043 'propnoteditable' => $langs->trans(
"NotEditable"),
4045 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4046 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4047 'propcss' => $langs->trans(
"CSSClass"),
4048 'propcssview' => $langs->trans(
"CSSViewClass"),
4049 'propcsslist' => $langs->trans(
"CSSListClass"),
4050 'prophelp' => $langs->trans(
"KeyForTooltip"),
4051 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4053 'propcomment' => $langs->trans(
"Comment"),
4055 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4056 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4057 print
'<input type="hidden" name="action" value="addproperty">';
4058 print
'<input type="hidden" name="tab" value="objects">';
4059 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4060 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4062 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4064 foreach ($attributesUnique as $key => $attribute) {
4065 if ($counter % 2 === 0) {
4068 if ($key ==
'propname' || $key ==
'proplabel') {
4069 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50"><input class="maxwidth200" id="'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'"></td>';
4070 } elseif ($key ==
'proptype') {
4071 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4072 print
'<input class="maxwidth200" id="'.$key.
'" list="datalist'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4074 print
'<datalist id="datalist'.$key.
'">';
4075 print
'<option>varchar(128)</option>';
4076 print
'<option>email</option>';
4077 print
'<option>phone</option>';
4078 print
'<option>ip</option>';
4079 print
'<option>url</option>';
4080 print
'<option>password</option>';
4081 print
'<option>text</option>';
4082 print
'<option>html</option>';
4083 print
'<option>date</option>';
4084 print
'<option>datetime</option>';
4085 print
'<option>integer</option>';
4086 print
'<option>double(28,4)</option>';
4087 print
'<option>real</option>';
4088 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4097 print
'</datalist>';
4101 } elseif ($key ==
'propvisible') {
4102 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
"1").
'"></td>';
4103 } elseif ($key ==
'propenabled') {
4106 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') : $default).
'"></td>';
4107 } elseif ($key ==
'proparrayofkeyval') {
4108 print
'<td class="titlefieldcreate tdproparrayofkeyval">'.$attribute.
'</td><td class="valuefieldcreate"><textarea class="maxwidth200" name="'.$key.
'">'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
"").
'</textarea></td>';
4110 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
'').
'"></td>';
4113 if ($counter % 2 === 0) {
4117 if ($counter % 2 !== 0) {
4118 while ($counter % 2 !== 0) {
4124 print
'</table><br>'.
"\n";
4125 print
'<div class="center">';
4126 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4127 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4133 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4134 window.location.href = url;
4136 $(document).ready(function() {
4137 $("#proplabel").on("keyup", function() {
4138 console.log("key up on label");
4139 s = cleanString($("#proplabel").val());
4140 $("#propname").val(s);
4143 function cleanString( stringtoclean )
4145 // allow "a-z", "A-Z", "0-9" and "_"
4146 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4147 stringtoclean = stringtoclean.toLowerCase();
4148 if (!isNaN(stringtoclean)) {
4151 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4152 stringtoclean = stringtoclean.substr(1)
4154 if (stringtoclean.length > 28) {
4155 stringtoclean = stringtoclean.substring(0, 27);
4157 return stringtoclean;
4162 } elseif ($tabobj ==
'deleteobject') {
4164 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4165 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4166 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4167 print
'<input type="hidden" name="tab" value="objects">';
4168 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4169 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4171 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4173 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4174 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4178 if ($action ==
'deleteproperty') {
4179 $formconfirm = $form->formconfirm(
4180 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4181 $langs->trans(
'Delete'),
4182 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4183 'confirm_deleteproperty',
4192 if ($action !=
'editfile' || empty($file)) {
4196 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4197 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4198 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4199 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4200 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4201 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4202 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4203 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4204 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4207 clearstatcache(
true);
4208 if (function_exists(
'opcache_invalidate')) {
4209 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4212 if (empty($forceddirread) && empty($dirread)) {
4214 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4216 $result = include_once $dirread.
'/'.$pathtoclass;
4217 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4220 if (class_exists($tabobj)) {
4222 $tmpobject = @
new $tabobj($db);
4224 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4227 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4231 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4234 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4237 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4240 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4243 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4244 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4247 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4250 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4253 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4256 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4258 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4260 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4261 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4263 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4264 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4266 $tmpobject = $tmpobject ??
null;
4267 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4268 $pathtopicto = $tmpobject->picto;
4269 $realpathtopicto =
'';
4271 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4272 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4277 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4278 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4279 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4280 $realpathtocard = $dirread.
'/'.$pathtocard;
4281 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4282 $realpathtolist = $dirread.
'/'.$pathtolist;
4283 $realpathtonote = $dirread.
'/'.$pathtonote;
4284 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4285 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4286 $realpathtosql = $dirread.
'/'.$pathtosql;
4287 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4288 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4289 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4290 $realpathtolib = $dirread.
'/'.$pathtolib;
4291 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4293 if (empty($realpathtoapi)) {
4294 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4295 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4303 print
'<!-- section for object -->';
4304 print
'<div class="fichehalfleft smallxxx">';
4306 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>';
4307 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>';
4310 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4311 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>';
4314 } elseif (!empty($tmpobject)) {
4315 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4321 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>';
4323 $file = file_get_contents($realpathtoapi);
4324 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4325 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>';
4327 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>';
4328 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4331 if ($modulelowercase !==
null && !isModEnabled($modulelowercase)) {
4332 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4334 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4337 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($langs->trans(
'AddAPIsForThisObject'),
'generate',
'class="paddingleft"').
'</a>';
4340 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>';
4344 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>';
4346 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>';
4348 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>';
4350 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>';
4356 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>';
4357 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>';
4359 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>';
4360 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>';
4364 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>';
4365 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>';
4366 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>';
4369 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>';
4370 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>';
4373 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>';
4375 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>';
4377 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>';
4379 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>';
4381 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>';
4385 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>';
4387 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>';
4389 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>';
4391 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>';
4396 print
'<div class="fichehalfleft smallxxxx">';
4397 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>';
4398 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>';
4400 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>';
4401 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>';
4404 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>';
4405 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>';
4408 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>';
4410 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>';
4414 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>';
4415 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>';
4418 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>';
4420 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>';
4424 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>';
4425 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>';
4428 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>';
4430 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>';
4434 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>';
4435 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>';
4438 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>';
4440 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>';
4447 print
'<br><br><br>';
4449 if (!empty($tmpobject)) {
4450 $reflector =
new ReflectionClass($tabobj);
4451 $reflectorproperties = $reflector->getProperties();
4452 $reflectorpropdefault = $reflector->getDefaultProperties();
4456 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4457 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4458 print
'<input type="hidden" name="action" value="addproperty">';
4459 print
'<input type="hidden" name="tab" value="objects">';
4460 print
'<input type="hidden" name="page_y" value="">';
4461 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4462 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4464 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4467 $mod = strtolower($module);
4468 $obj = strtolower($tabobj);
4469 $newproperty =
dolGetButtonTitle($langs->trans(
'NewProperty'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode($tabobj));
4470 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4472 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'', 0, 0, 0, 1);
4475 print
'<!-- Table with properties of object -->'.
"\n";
4476 print
'<div class="div-table-responsive">';
4477 print
'<table class="noborder small">';
4478 print
'<tr class="liste_titre">';
4479 print
'<th class="tdsticky tdstickygray">';
4480 $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>';
4481 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4484 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4486 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4487 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4488 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4489 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4490 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4491 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4492 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4493 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4494 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4495 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4497 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4498 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4499 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4500 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4501 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4502 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4503 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4505 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4506 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4507 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4513 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4514 if (!empty($properties)) {
4516 foreach ($properties as $propkey => $propval) {
4531 $propname = $propkey;
4532 $proplabel = $propval[
'label'];
4533 $proptype = $propval[
'type'];
4534 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4535 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4536 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4537 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4538 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4539 $propposition = $propval[
'position'];
4540 $propenabled = $propval[
'enabled'];
4541 $propvisible = $propval[
'visible'];
4542 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4544 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4545 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4546 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4547 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4548 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4549 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4550 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4552 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4553 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4555 print
'<!-- line for object property -->'.
"\n";
4556 print
'<tr class="oddeven">';
4558 print
'<td class="tdsticky tdstickygray">';
4561 if ($action ==
'editproperty' && $propname == $propertykey) {
4563 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4564 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4566 print
'<td class="tdoverflowmax150">';
4567 print
'<input name="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'"></input>';
4569 print
'<td class="tdoverflowmax200">';
4570 print
'<textarea name="proparrayofkeyval">';
4571 if (isset($proparrayofkeyval)) {
4572 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4576 print
'</textarea>';
4579 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4582 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4584 print
'<td class="center">';
4585 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4588 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4591 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4594 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4597 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4600 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4606 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4609 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4612 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4615 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4618 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4621 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4624 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4627 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4630 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4632 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4633 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4634 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4637 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4640 print
'<td class="tdoverflowmax200">';
4643 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4644 $pictoType =
'varchar';
4645 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4646 $pictoType =
'link';
4647 } elseif (strpos($proptype,
'integer') === 0) {
4648 $pictoType = substr($proptype, 0, 3);
4649 } elseif (strpos($proptype,
'timestamp') === 0) {
4650 $pictoType =
'datetime';
4651 } elseif (strpos($proptype,
'real') === 0) {
4652 $pictoType =
'double';
4656 print
'<td class="tdoverflowmax200">';
4657 if ($proparrayofkeyval) {
4658 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4663 print
'<td class="center">';
4669 print
'<td class="center">';
4670 print $propindex ?
'1' :
'';
4672 print
'<td class="center">';
4675 print
'<td class="right">';
4678 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4682 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4686 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4692 print
'<td class="center">';
4693 print $propsearchall ?
'1' :
'';
4695 print
'<td class="center">';
4698 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4701 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4704 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4708 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4711 print
'<td class="center">';
4717 print
'<td class="center">';
4720 print
'<td class="tdoverflowmax200">';
4721 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4725 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4726 if ($propname !=
'rowid') {
4727 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>';
4728 print
'<a class="reposition 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>';
4735 if ($tab ==
'specifications') {
4736 if ($action !=
'editfile' || empty($file)) {
4737 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4742 foreach ($specs as $spec) {
4743 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4744 $format =
'asciidoc';
4745 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4746 $format =
'markdown';
4748 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4749 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>';
4759 $content = file_get_contents($fullpathoffile);
4762 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4763 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4764 print
'<input type="hidden" name="action" value="savefile">';
4765 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4766 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4767 print
'<input type="hidden" name="module" value="'.$module.
'">';
4769 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4770 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4773 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4775 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4781 print
'<tr><td><span class="warning">'.$langs->trans(
'Property %s not found in the class. The class was probably not generated by modulebuilder.', $field).
'</warning></td></tr>';
4788 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4792 print $e->getMessage();
4796 if (empty($forceddirread)) {
4799 $fullpathoffile = $dirread.
'/'.$file;
4802 $content = file_get_contents($fullpathoffile);
4805 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4806 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4807 print
'<input type="hidden" name="action" value="savefile">';
4808 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4809 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4810 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4811 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4813 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4814 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4817 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4819 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4829 if ($tab ==
'dictionaries') {
4830 print
'<!-- tab=dictionaries -->'.
"\n";
4831 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4833 $dicts = $moduleobj->dictionaries;
4835 if ($action ==
'deletedict') {
4836 $formconfirm = $form->formconfirm(
4837 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'd