225 $error = error_get_last();
226 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
228 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
230 if (headers_sent()) {
235register_shutdown_function(
"moduleBuilderShutdownFunction");
242if ($dirins && $action ==
'initmodule' && $modulename) {
243 $modulename = ucfirst($modulename);
245 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
247 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
251 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
252 $destdir = $dirins.
'/'.strtolower($modulename);
254 $arrayreplacement = array(
255 'mymodule' => strtolower($modulename),
256 'MyModule' => $modulename
258 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
263 $langs->load(
"errors");
264 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
267 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
273 $tryToCopyFromSetupClass =
true;
274 $backportDest = $destdir .
'/backport/v16/core/class';
275 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
276 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
281 $langs->load(
"errors");
282 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
283 $tryToCopyFromSetupClass =
false;
286 if ($tryToCopyFromSetupClass) {
287 $result =
dol_copy($backportFileSrc, $backportFileDest);
291 $langs->load(
"errors");
292 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
294 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
317 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
318 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
336 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
337 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
339 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
340 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
341 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
342 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
357 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
358 foreach ($listofphpfilestoedit as $phpfileval) {
360 $arrayreplacement = array(
361 'mymodule' => strtolower($modulename),
362 'MyModule' => $modulename,
363 'MYMODULE' => strtoupper($modulename),
364 'My module' => $modulename,
365 'my module' => $modulename,
366 'Mon module' => $modulename,
367 'mon module' => $modulename,
368 'htdocs/modulebuilder/template' => strtolower($modulename),
369 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
370 'Editor name' => $editorname,
371 'https://www.example.com' => $editorurl,
372 '$this->version = \'1.0\'' =>
'$this->version = \''.$version.
'\'',
373 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
374 "modulefamily" => $family,
375 '500000' => $idmodule
379 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
386 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
391 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
393 file_put_contents($destdir.
'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README);
404 $module = $modulename;
406 clearstatcache(
true);
407 if (function_exists(
'opcache_invalidate')) {
411 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
418if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module)) {
419 $modulename = ucfirst($module);
420 $objectname = $tabobj;
421 $varnametoupdate =
'';
422 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
423 $destdir = $dirins.
'/'.strtolower($module);
429 if ($action ==
'initapi') {
430 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
431 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php', 0, 1);
433 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
434 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
435 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
436 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
437 } elseif ($action ==
'initphpunit') {
438 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
439 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
440 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
441 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
442 } elseif ($action ==
'initpagecontact') {
443 dol_mkdir($dirins.
'/'.strtolower($module));
444 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
445 $srcfile = $srcdir.
'/myobject_contact.php';
446 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
447 $varnametoupdate =
'showtabofpagecontact';
448 } elseif ($action ==
'initpagedocument') {
449 dol_mkdir($dirins.
'/'.strtolower($module));
450 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
451 $srcfile = $srcdir.
'/myobject_document.php';
452 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
453 $varnametoupdate =
'showtabofpagedocument';
454 } elseif ($action ==
'initpagenote') {
455 dol_mkdir($dirins.
'/'.strtolower($module));
456 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
457 $srcfile = $srcdir.
'/myobject_note.php';
458 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
459 $varnametoupdate =
'showtabofpagenote';
460 } elseif ($action ==
'initpageagenda') {
461 dol_mkdir($dirins.
'/'.strtolower($module));
462 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
463 $srcfile = $srcdir.
'/myobject_agenda.php';
464 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
465 $varnametoupdate =
'showtabofpageagenda';
470 if (!file_exists($destfile)) {
471 $result =
dol_copy($srcfile, $destfile, 0, 0);
476 $arrayreplacement = array(
477 'mymodule' => strtolower($modulename),
478 'MyModule' => $modulename,
479 'MYMODULE' => strtoupper($modulename),
480 'My module' => $modulename,
481 'my module' => $modulename,
482 'Mon module' => $modulename,
483 'mon module' => $modulename,
484 'htdocs/modulebuilder/template' => strtolower($modulename),
485 'myobject' => strtolower($objectname),
486 'MyObject' => $objectname,
487 'MYOBJECT' => strtoupper($objectname),
488 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
491 if ($action ==
'initapi') {
492 if (count($objects) >= 1) {
500 if ($varnametoupdate) {
502 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
503 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
508 $langs->load(
"errors");
509 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
515if ($dirins && $action ==
'initsqlextrafields' && !empty($module)) {
516 $modulename = ucfirst($module);
517 $objectname = $tabobj;
519 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
520 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
521 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
522 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
525 $result1 =
dol_copy($srcfile1, $destfile1, 0, 0);
526 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
527 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
530 $result2 =
dol_copy($srcfile2, $destfile2, 0, 0);
532 if ($result1 > 0 && $result2 > 0) {
533 $modulename = ucfirst($module);
536 $arrayreplacement = array(
537 'mymodule' => strtolower($modulename),
538 'MyModule' => $modulename,
539 'MYMODULE' => strtoupper($modulename),
540 'My module' => $modulename,
541 'my module' => $modulename,
542 'Mon module' => $modulename,
543 'mon module' => $modulename,
544 'htdocs/modulebuilder/template' => strtolower($modulename),
545 'My Object' => $objectname,
546 'MyObject' => $objectname,
547 'my object' => strtolower($objectname),
548 'myobject' => strtolower($objectname),
549 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
555 $langs->load(
"errors");
557 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
560 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
565 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
566 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
572if ($dirins && $action ==
'inithook' && !empty($module)) {
573 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
574 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
575 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
576 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
579 $result =
dol_copy($srcfile, $destfile, 0, 0);
582 $modulename = ucfirst($module);
585 $arrayreplacement = array(
586 'mymodule' => strtolower($modulename),
587 'MyModule' => $modulename,
588 'MYMODULE' => strtoupper($modulename),
589 'My module' => $modulename,
590 'my module' => $modulename,
591 'Mon module' => $modulename,
592 'mon module' => $modulename,
593 'htdocs/modulebuilder/template' => strtolower($modulename),
594 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
600 $langs->load(
"errors");
601 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
607if ($dirins && $action ==
'inittrigger' && !empty($module)) {
608 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
609 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
610 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
611 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
614 $result =
dol_copy($srcfile, $destfile, 0, 0);
617 $modulename = ucfirst($module);
620 $arrayreplacement = array(
621 'mymodule' => strtolower($modulename),
622 'MyModule' => $modulename,
623 'MYMODULE' => strtoupper($modulename),
624 'My module' => $modulename,
625 'my module' => $modulename,
626 'Mon module' => $modulename,
627 'mon module' => $modulename,
628 'htdocs/modulebuilder/template' => strtolower($modulename),
629 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
635 $langs->load(
"errors");
636 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
642if ($dirins && $action ==
'initwidget' && !empty($module)) {
643 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
644 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
645 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
646 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
649 $result =
dol_copy($srcfile, $destfile, 0, 0);
652 $modulename = ucfirst($module);
655 $arrayreplacement = array(
656 'mymodule' => strtolower($modulename),
657 'MyModule' => $modulename,
658 'MYMODULE' => strtoupper($modulename),
659 'My module' => $modulename,
660 'my module' => $modulename,
661 'Mon module' => $modulename,
662 'mon module' => $modulename,
663 'htdocs/modulebuilder/template' => strtolower($modulename),
664 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
670 $langs->load(
"errors");
671 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
677if ($dirins && $action ==
'initemailing' && !empty($module)) {
678 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
679 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
680 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
681 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
684 $result =
dol_copy($srcfile, $destfile, 0, 0);
687 $modulename = ucfirst($module);
690 $arrayreplacement = array(
691 'mymodule' => strtolower($modulename),
692 'MyModule' => $modulename,
693 'MYMODULE' => strtoupper($modulename),
694 'My module' => $modulename,
695 'my module' => $modulename,
696 'Mon module' => $modulename,
697 'mon module' => $modulename,
698 'htdocs/modulebuilder/template' => strtolower($modulename),
699 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
705 $langs->load(
"errors");
706 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
712if ($dirins && $action ==
'initcss' && !empty($module)) {
713 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
714 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
715 $srcfile = $srcdir.
'/css/mymodule.css.php';
716 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
719 $result =
dol_copy($srcfile, $destfile, 0, 0);
722 $modulename = ucfirst($module);
725 $arrayreplacement = array(
726 'mymodule' => strtolower($modulename),
727 'MyModule' => $modulename,
728 'MYMODULE' => strtoupper($modulename),
729 'My module' => $modulename,
730 'my module' => $modulename,
731 'Mon module' => $modulename,
732 'mon module' => $modulename,
733 'htdocs/modulebuilder/template' => strtolower($modulename),
734 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
741 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
742 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
745 $langs->load(
"errors");
746 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
752if ($dirins && $action ==
'initjs' && !empty($module)) {
753 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
754 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
755 $srcfile = $srcdir.
'/js/mymodule.js.php';
756 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
759 $result =
dol_copy($srcfile, $destfile, 0, 0);
762 $modulename = ucfirst($module);
765 $arrayreplacement = array(
766 'mymodule' => strtolower($modulename),
767 'MyModule' => $modulename,
768 'MYMODULE' => strtoupper($modulename),
769 'My module' => $modulename,
770 'my module' => $modulename,
771 'Mon module' => $modulename,
772 'mon module' => $modulename,
773 'htdocs/modulebuilder/template' => strtolower($modulename),
774 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
781 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
782 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
785 $langs->load(
"errors");
786 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
792if ($dirins && $action ==
'initcli' && !empty($module)) {
793 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
794 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
795 $srcfile = $srcdir.
'/scripts/mymodule.php';
796 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
799 $result =
dol_copy($srcfile, $destfile, 0, 0);
802 $modulename = ucfirst($module);
805 $arrayreplacement = array(
806 'mymodule' => strtolower($modulename),
807 'MyModule' => $modulename,
808 'MYMODULE' => strtoupper($modulename),
809 'My module' => $modulename,
810 'my module' => $modulename,
811 'Mon module' => $modulename,
812 'mon module' => $modulename,
813 'htdocs/modulebuilder/template' => strtolower($modulename),
814 '__MYCOMPANY_NAME__' => $mysoc->name,
815 '__KEYWORDS__' => $modulename,
816 '__USER_FULLNAME__' => $user->getFullName($langs),
817 '__USER_EMAIL__' => $user->email,
819 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
825 $langs->load(
"errors");
826 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
832if ($dirins && $action ==
'initdoc' && !empty($module)) {
833 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
834 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
835 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
836 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
839 $result =
dol_copy($srcfile, $destfile, 0, 0);
842 $modulename = ucfirst($module);
843 $modulelowercase = strtolower($module);
846 $arrayreplacement = array(
847 'mymodule' => strtolower($modulename),
848 'MyModule' => $modulename,
849 'MYMODULE' => strtoupper($modulename),
850 'My module' => $modulename,
851 'my module' => $modulename,
852 'Mon module' => $modulename,
853 'mon module' => $modulename,
854 'htdocs/modulebuilder/template' => strtolower($modulename),
855 '__MYCOMPANY_NAME__' => $mysoc->name,
856 '__KEYWORDS__' => $modulename,
857 '__USER_FULLNAME__' => $user->getFullName($langs),
858 '__USER_EMAIL__' => $user->email,
860 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
867 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
868 $destdir = $dirins.
'/'.strtolower($module);
870 foreach ($objects as $path => $obj) {
875 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
879 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
880 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
885 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
886 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
887 $string = file_get_contents($changeLog);
889 $replace = explode(
"\n", $string);
890 $strreplace = array();
891 foreach ($replace as $line) {
895 if (strpos($line,
'##') !==
false) {
896 $strreplace[$line] = str_replace(
'##',
'', $line);
898 $strreplace[$line] = $line;
901 $stringLog = implode(
"\n", $strreplace);
903 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
907 $FILENAMEDOC = $modulelowercase.
'.html';
908 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
909 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
910 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
911 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
912 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
917 $langs->load(
"errors");
918 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
924if ($dirins && $action ==
'addlanguage' && !empty($module)) {
925 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
928 $modulelowercase = strtolower($module);
933 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
935 $diroflang = $dolibarr_main_document_root;
937 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
938 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
940 $result =
dol_copy($srcfile, $destfile, 0, 0);
942 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
945 $srcdir = $diroflang.
'/langs/en_US';
946 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
947 $destdir = $diroflang.
'/langs/'.$newlangcode;
949 $arrayofreplacement = array();
951 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
952 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
954 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayofreplacement);
957 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
963if ($dirins && $action ==
'confirm_removefile' && !empty($module)) {
964 $objectname = $tabobj;
965 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
966 $destdir = $dirins.
'/'.strtolower($module);
971 if ($relativefilename) {
972 $dirnametodelete = dirname($relativefilename);
973 $filetodelete = $dirins.
'/'.$relativefilename;
974 $dirtodelete = $dirins.
'/'.$dirnametodelete;
979 $keyofobjecttodelete = array_search($objectname, $objects);
980 if ($keyofobjecttodelete !==
false) {
981 unset($objects[$keyofobjecttodelete]);
985 if (strpos($relativefilename,
'api') !==
false) {
986 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
990 if (count($objects) == 0) {
1002 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1005 if (preg_match(
'/\.sql$/', $relativefilename)) {
1006 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1007 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1008 $filetodelete = $dirins.
'/'.$relativefilename;
1010 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1011 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1012 $filetodelete = $dirins.
'/'.$relativefilename;
1022 if (in_array($tab, array(
'css',
'js'))) {
1023 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1024 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1028 if (preg_match(
'/_extrafields/', $relativefilename)) {
1030 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1031 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1036 $varnametoupdate =
'';
1038 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1039 $varnametoupdate =
'showtabofpage'.$reg[1];
1041 if ($varnametoupdate) {
1042 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1043 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1051if ($dirins && $action ==
'initobject' && $module && $objectname) {
1054 $objectname = ucfirst($objectname);
1056 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1057 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1059 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1061 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1062 $tabobj =
'newobject';
1064 if (class_exists($objectname)) {
1067 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1068 $tabobj =
'newobject';
1071 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1072 $destdir = $dirins.
'/'.strtolower($module);
1083 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1084 $alreadyfound =
false;
1085 foreach ($dirlist as $key => $val) {
1086 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1087 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1088 $alreadyfound =
true;
1090 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1097 $stringforproperties =
'';
1098 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1100 $_results = $db->DDLDescTable($tablename);
1101 if (empty($_results)) {
1103 $langs->load(
"errors");
1104 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1153 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1154 $stringforproperties .=
'public $fields=array('.
"\n";
1156 while ($obj = $db->fetch_object($_results)) {
1158 $fieldname = $obj->Field;
1161 if ($type ==
'int(11)') {
1164 if ($type ==
'float') {
1167 if (strstr($type,
'tinyint')) {
1170 if ($obj->Field ==
'fk_soc') {
1171 $type =
'integer:Societe:societe/class/societe.class.php';
1173 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1174 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1176 if (preg_match(
'/^fk_prod/', $obj->Field)) {
1177 $type =
'integer:Product:product/class/product.class.php:1';
1179 if ($obj->Field ==
'fk_warehouse') {
1180 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1182 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1183 $type =
'integer:User:user/class/user.class.php';
1187 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1188 if ($fieldname ==
'fk_user_modif') {
1192 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1193 if ($fieldname ==
'rowid') {
1194 $label =
'TechnicalID';
1196 if ($fieldname ==
'import_key') {
1197 $label =
'ImportId';
1199 if ($fieldname ==
'fk_soc') {
1200 $label =
'ThirdParty';
1202 if ($fieldname ==
'tms') {
1203 $label =
'DateModification';
1205 if ($fieldname ==
'datec') {
1206 $label =
'DateCreation';
1208 if ($fieldname ==
'date_valid') {
1209 $label =
'DateValidation';
1211 if ($fieldname ==
'datev') {
1212 $label =
'DateValidation';
1214 if ($fieldname ==
'note_private') {
1215 $label =
'NotePublic';
1217 if ($fieldname ==
'note_public') {
1218 $label =
'NotePrivate';
1220 if ($fieldname ==
'fk_user_creat') {
1221 $label =
'UserAuthor';
1223 if ($fieldname ==
'fk_user_modif') {
1224 $label =
'UserModif';
1226 if ($fieldname ==
'fk_user_valid') {
1227 $label =
'UserValidation';
1231 if ($fieldname ==
'entity') {
1234 if ($fieldname ==
'import_key') {
1237 if ($fieldname ==
'fk_user_creat') {
1240 if ($fieldname ==
'fk_user_modif') {
1243 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1250 if ($fieldname ==
'entity') {
1255 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1258 if ($fieldname ==
'import_key') {
1263 if ($fieldname ==
'label') {
1264 $alwayseditable = 1;
1268 if ($fieldname ==
'entity') {
1275 if (preg_match(
'/^fk_/', $fieldname)) {
1276 $css =
'maxwidth500 widthcentpercentminusxx';
1278 if ($fieldname ==
'label') {
1279 $css =
'minwidth300';
1280 $cssview =
'wordbreak';
1282 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1283 $cssview =
'wordbreak';
1285 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1286 $csslist =
'tdoverflowmax150';
1290 if (isset($obj->Picto)) {
1291 $picto = $obj->Picto;
1293 if ($obj->Field ==
'fk_soc') {
1296 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1301 $stringforproperties .=
"'".$obj->Field.
"'=>array('type'=>'".$type.
"', 'label'=>'".$label.
"',";
1302 if ($default !=
'') {
1303 $stringforproperties .=
" 'default'=>".$default.
",";
1305 $stringforproperties .=
" 'enabled'=>".$enabled.
",";
1306 $stringforproperties .=
" 'visible'=>".$visible;
1308 $stringforproperties .=
", 'notnull'=>".$notnull;
1310 if ($alwayseditable) {
1311 $stringforproperties .=
", 'alwayseditable'=>1";
1313 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1314 $stringforproperties .=
", 'showoncombobox'=>1";
1316 $stringforproperties .=
", 'position'=>".$position;
1318 $stringforproperties .=
", 'index'=>".$index;
1321 $stringforproperties .=
", 'picto'=>'".$picto.
"'";
1324 $stringforproperties .=
", 'css'=>'".$css.
"'";
1327 $stringforproperties .=
", 'cssview'=>'".$cssview.
"'";
1330 $stringforproperties .=
", 'csslist'=>'".$csslist.
"'";
1332 $stringforproperties .=
"),\n";
1335 $stringforproperties .=
');'.
"\n";
1336 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1342 $filetogenerate = array(
1343 'myobject_card.php' => strtolower($objectname).
'_card.php',
1344 'myobject_note.php' => strtolower($objectname).
'_note.php',
1345 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1346 'myobject_document.php' => strtolower($objectname).
'_document.php',
1347 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1348 'myobject_list.php' => strtolower($objectname).
'_list.php',
1349 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1350 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1352 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1353 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1354 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1355 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1357 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1361 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1362 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1364 $filetogenerate += array(
1365 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1366 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1367 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1370 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1371 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1372 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1374 $filetogenerate += array(
1375 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1376 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1379 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1380 $firstobjectname =
'myobject';
1381 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1383 $class =
'mod'.$module;
1384 if (class_exists($class)) {
1386 $moduleobj =
new $class($db);
1392 $rights = $moduleobj->rights;
1393 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1395 if ($checkComment < 0) {
1396 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1398 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1399 if ($generatePerms < 0) {
1400 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1406 foreach ($filetogenerate as $srcfile => $destfile) {
1407 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1411 $langs->load(
"errors");
1412 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1415 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1418 $arrayreplacement = array(
1419 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1420 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1428 if (!$error && $stringforproperties) {
1430 $arrayreplacement = array(
1431 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1434 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1438 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1440 $arrayreplacement = array(
1441 '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' =>
"'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"
1445 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1447 $arrayreplacement = array(
1448 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1450 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1454 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1456 $arrayreplacement = array(
1457 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1459 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1460 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'', 0, 0, 1);
1462 $arrayreplacement = array(
1463 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1466 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1473 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1475 $firstobjectname =
'';
1476 foreach ($listofobject as $fileobj) {
1477 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1480 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1484 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1486 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1487 $objectnameloop = $reg[1];
1488 if (empty($firstobjectname)) {
1489 $firstobjectname = $objectnameloop;
1495 \$this->menu[\$r++]=array(
1496 'fk_menu'=>'fk_mainmenu=mymodule',
1498 'titre'=>'MyObject',
1499 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1500 'mainmenu'=>'mymodule',
1501 'leftmenu'=>'myobject',
1502 'url'=>'/mymodule/myobject_list.php',
1503 'langs'=>'mymodule@mymodule',
1504 'position'=>1000+\$r,
1505 'enabled'=>'isModEnabled(\"mymodule\")',
1506 'perms'=>'".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1509 'object'=>'MyObject'
1511 \$this->menu[\$r++]=array(
1512 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1514 'titre'=>'List MyObject',
1515 'mainmenu'=>'mymodule',
1516 'leftmenu'=>'mymodule_myobject_list',
1517 'url'=>'/mymodule/myobject_list.php',
1518 'langs'=>'mymodule@mymodule',
1519 'position'=>1000+\$r,
1520 'enabled'=>'isModEnabled(\"mymodule\")',
1521 'perms'=>'".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1524 'object'=>'MyObject'
1526 \$this->menu[\$r++]=array(
1527 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1529 'titre'=>'New MyObject',
1530 'mainmenu'=>'mymodule',
1531 'leftmenu'=>'mymodule_myobject_new',
1532 'url'=>'/mymodule/myobject_card.php?action=create',
1533 'langs'=>'mymodule@mymodule',
1534 'position'=>1000+\$r,
1535 'enabled'=>'isModEnabled(\"mymodule\")',
1536 'perms'=>'".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1539 'object'=>'MyObject'
1541 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1542 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1543 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1545 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1551 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1553 $class =
'mod'.$module;
1554 if (class_exists($class)) {
1556 $moduleobj =
new $class($db);
1562 $menus = $moduleobj->menu;
1564 foreach ($menus as $menu) {
1565 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1571 if ($checkComment < 0) {
1573 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1575 $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 */');
1580 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1585 foreach ($filetogenerate as $destfile) {
1586 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1589 $arrayreplacement = array(
1590 'mymodule' => strtolower($module),
1591 'MyModule' => $module,
1592 'MYMODULE' => strtoupper($module),
1593 'My module' => $module,
1594 'my module' => $module,
1595 'mon module' => $module,
1596 'Mon module' => $module,
1597 'htdocs/modulebuilder/template/' => strtolower($modulename),
1598 'myobject' => strtolower($objectname),
1599 'MyObject' => $objectname,
1601 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
1605 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1611 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1620 if (is_numeric($object) && $object <= 0) {
1621 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1622 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1626 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1627 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1629 if (file_exists($destfile)) {
1635 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1644 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1645 $tabobj = $objectname;
1647 $tabobj =
'newobject';
1651 if (isModEnabled(strtolower($module))) {
1657 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1658 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1664if ($dirins && $action ==
'initdic' && $module && empty($cancel)) {
1665 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1666 $destdir = $dirins.
'/'.strtolower($module);
1667 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1671 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1675 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1678 $newdicname = $dicname;
1679 if (!preg_match(
'/^c_/', $newdicname)) {
1680 $newdicname =
'c_'.$dicname;
1683 $class =
'mod'.$module;
1685 if (class_exists($class)) {
1687 $moduleobj =
new $class($db);
1694 $langs->load(
"errors");
1695 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1698 $dictionaries = $moduleobj->dictionaries;
1700 if ($checkComment < 0) {
1701 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1704 if (function_exists(
'opcache_invalidate')) {
1707 clearstatcache(
true);
1708 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1715if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj)) {
1716 $objectname = $tabobj;
1718 $arrayoftables = array();
1719 if ($action ==
'droptable') {
1720 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1722 if ($action ==
'droptableextrafields') {
1723 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1726 foreach ($arrayoftables as $tabletodrop) {
1728 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1729 $resql = $db->query($sql);
1731 $obj = $db->fetch_object($resql);
1736 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1737 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1743 $resql = $db->DDLDropTable($tabletodrop);
1745 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1746 } elseif ($nb > 0) {
1747 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1752if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj')))) {
1757 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1758 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1760 $srcdir = $dirread.
'/'.strtolower($module);
1761 $destdir = $dirins.
'/'.strtolower($module);
1765 if (!in_array($objectname, array_values($objects))) {
1767 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1770 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1771 if (!
GETPOST(
'propname',
'aZ09')) {
1773 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1775 if (!
GETPOST(
'proplabel',
'alpha')) {
1777 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1779 if (!
GETPOST(
'proptype',
'alpha')) {
1781 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1784 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1785 $addfieldentry = array(
1786 'name' =>
GETPOST(
'propname',
'aZ09'),
1787 'label' =>
GETPOST(
'proplabel',
'alpha'),
1788 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1789 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'alphawithlgt'),
1790 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1791 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1795 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1797 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1798 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1799 'help' =>
GETPOST(
'prophelp',
'alpha'),
1800 'css' =>
GETPOST(
'propcss',
'alpha'),
1801 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1802 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1803 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1804 'noteditable' => intval(
GETPOSTINT(
'propnoteditable')),
1809 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1810 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1812 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1815 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1820 $addfieldentry = array();
1829 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1835 if (is_numeric($object) && $object <= 0) {
1836 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1837 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1844 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1847 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1853 clearstatcache(
true);
1855 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1860 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1865if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey) {
1866 $objectname = $tabobj;
1868 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1869 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1871 $srcdir = $dirread.
'/'.strtolower($module);
1872 $destdir = $dirins.
'/'.strtolower($module);
1879 if (is_numeric($object) && $object <= 0) {
1880 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1881 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1888 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1891 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1897 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1899 clearstatcache(
true);
1902 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1907if ($dirins && $action ==
'confirm_deletemodule') {
1908 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1910 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1914 $modulelowercase = strtolower($module);
1917 $dir = $dirins.
'/'.$modulelowercase;
1919 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1929 $class =
'mod'.$module;
1931 if (class_exists($class)) {
1933 $moduleobj =
new $class($db);
1940 $langs->load(
"errors");
1941 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
1945 $moduleobj->remove();
1953 clearstatcache(
true);
1954 if (function_exists(
'opcache_invalidate')) {
1958 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
1966 $module =
'deletemodule';
1969if ($dirins && $action ==
'confirm_deleteobject' && $objectname) {
1970 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1972 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1976 $modulelowercase = strtolower($module);
1977 $objectlowercase = strtolower($objectname);
1980 $dir = $dirins.
'/'.$modulelowercase;
1983 $filetodelete = array(
1984 'myobject_card.php' => strtolower($objectname).
'_card.php',
1985 'myobject_note.php' => strtolower($objectname).
'_note.php',
1986 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1987 'myobject_document.php' => strtolower($objectname).
'_document.php',
1988 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1989 'myobject_list.php' => strtolower($objectname).
'_list.php',
1990 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1991 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1992 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
1993 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1994 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1995 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1996 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1997 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
1998 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1999 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2000 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2001 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2002 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2003 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2004 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2009 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2011 $class =
'mod'.$module;
2012 if (class_exists($class)) {
2014 $moduleobj =
new $class($db);
2020 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2023 $menus = $moduleobj->menu;
2026 if ($rewriteMenu < 0) {
2027 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2029 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2033 $permissions = $moduleobj->rights;
2035 if ($rewritePerms < 0) {
2036 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2040 if ($rewritePerms && $rewriteMenu) {
2042 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2045 clearstatcache(
true);
2046 if (function_exists(
'opcache_invalidate')) {
2050 foreach ($filetodelete as $tmpfiletodelete) {
2052 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2058 if ($resultko == 0) {
2061 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2068 $tabobj =
'newobject';
2070 $tabobj =
'deleteobject';
2074 if (isModEnabled(strtolower($module))) {
2076 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2080 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2081 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2086if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey'))) {
2087 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2088 $destdir = $dirins.
'/'.strtolower($module);
2089 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2091 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2093 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2096 if (!empty($dicname)) {
2097 $newdicname = $dicname;
2098 if (!preg_match(
'/^c_/', $newdicname)) {
2099 $newdicname =
'c_'.strtolower($dicname);
2104 $class =
'mod'.$module;
2106 if (class_exists($class)) {
2108 $moduleobj =
new $class($db);
2115 $langs->load(
"errors");
2116 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2120 $dicts = $moduleobj->dictionaries;
2122 if ($checkComment < 0) {
2124 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2127 if (!empty(
GETPOST(
'dictionnarykey'))) {
2128 $newdicname = $dicts[
'tabname'][
GETPOST(
'dictionnarykey') - 1];
2132 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2133 if ($checkTable && $db->num_rows($checkTable) <= 0) {
2138 $keyToDelete =
null;
2139 foreach ($dicts[
'tabname'] as $key => $table) {
2141 if (strtolower($table) === $newdicname) {
2142 $keyToDelete = $key;
2147 if ($keyToDelete !==
null) {
2148 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2149 foreach ($keysToDelete as $key) {
2150 unset($dicts[$key][$keyToDelete]);
2154 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2158 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2159 if ($_results < 0) {
2161 $langs->load(
"errors");
2162 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2167 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2169 if (function_exists(
'opcache_invalidate')) {
2172 clearstatcache(
true);
2173 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2177if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey')) {
2178 $keydict =
GETPOST(
'dictionnarykey') - 1 ;
2180 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2181 $destdir = $dirins.
'/'.strtolower($module);
2182 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2184 $class =
'mod'.$module;
2186 if (class_exists($class)) {
2188 $moduleobj =
new $class($db);
2195 $langs->load(
"errors");
2196 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2200 $dicts = $moduleobj->dictionaries;
2201 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2202 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2204 if ($checkComment < 0) {
2205 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2208 if ($updateDict > 0) {
2211 if (function_exists(
'opcache_invalidate')) {
2214 clearstatcache(
true);
2215 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2221if ($dirins && $action ==
'generatedoc') {
2222 $modulelowercase = strtolower($module);
2227 $FILENAMEDOC = strtolower($module).
'.html';
2229 $util =
new Utils($db);
2230 $result = $util->generateDoc($module);
2233 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2239if ($dirins && $action ==
'generatepackage') {
2240 $modulelowercase = strtolower($module);
2242 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2252 $class =
'mod'.$module;
2254 if (class_exists($class)) {
2256 $moduleobj =
new $class($db);
2263 $langs->load(
"errors");
2264 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2268 $arrayversion = explode(
'.', $moduleobj->version, 3);
2269 if (count($arrayversion)) {
2270 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2273 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2279 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2285 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2288 $langs->load(
"errors");
2289 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2293 $langs->load(
"errors");
2294 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2299if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel)) {
2303 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2305 $class =
'mod'.$module;
2306 if (class_exists($class)) {
2308 $moduleobj =
new $class($db);
2316 if (!
GETPOST(
'label',
'alpha')) {
2318 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2320 if (!
GETPOST(
'permissionObj',
'alpha')) {
2322 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2326 $label =
GETPOST(
'label',
'alpha');
2327 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2328 $crud =
GETPOST(
'crud',
'alpha');
2332 $permsForObject = array();
2333 $permissions = $moduleobj->rights;
2334 $allObject = array();
2336 $countPerms = count($permissions);
2338 for ($i = 0; $i < $countPerms; $i++) {
2339 if ($permissions[$i][4] == $objectForPerms) {
2341 if (count($permsForObject) < 3) {
2342 $permsForObject[] = $permissions[$i];
2345 $allObject[] = $permissions[$i][4];
2349 $countPermsObj = count($permsForObject);
2350 for ($j = 0; $j < $countPermsObj; $j++) {
2351 if (in_array($crud, $permsForObject[$j])) {
2353 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2358 $key = $countPerms + 1;
2363 4 => $objectForPerms,
2367 if (isModEnabled(strtolower($module))) {
2369 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2373 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2376 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2380 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2385 clearstatcache(
true);
2386 if (function_exists(
'opcache_invalidate')) {
2389 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2396if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel)) {
2399 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2401 $class =
'mod'.$module;
2402 if (class_exists($class)) {
2404 $moduleobj =
new $class($db);
2411 if (!
GETPOST(
'label',
'alpha')) {
2413 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2415 if (!
GETPOST(
'permissionObj',
'alpha')) {
2417 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2420 $label =
GETPOST(
'label',
'alpha');
2421 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2422 $crud =
GETPOST(
'crud',
'alpha');
2425 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2429 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2433 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2438 $permissions = $moduleobj->rights;
2439 $key = (int)
GETPOST(
'counter') - 1;
2441 $x1 = $permissions[$key][1];
2442 $x2 = $permissions[$key][4];
2443 $x3 = $permissions[$key][5];
2446 $permsForObject = array();
2447 $permissions = $moduleobj->rights;
2450 $allObject = array();
2452 $countPerms = count($permissions);
2453 for ($i = 0; $i < $countPerms; $i++) {
2454 if ($permissions[$i][4] == $objectForPerms) {
2456 if (count($permsForObject) < 3) {
2457 $permsForObject[] = $permissions[$i];
2460 $allObject[] = $permissions[$i][4];
2463 if ($label != $x1 && $crud != $x3) {
2464 $countPermsObj = count($permsForObject);
2465 for ($j = 0; $j < $countPermsObj; $j++) {
2466 if (in_array($label, $permsForObject[$j])) {
2468 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2474 if (isModEnabled(strtolower($module))) {
2476 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2480 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2483 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2487 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2491 clearstatcache(
true);
2492 if (function_exists(
'opcache_invalidate')) {
2495 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2501if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey')) {
2504 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2506 $class =
'mod'.$module;
2507 if (class_exists($class)) {
2509 $moduleobj =
new $class($db);
2516 $permissions = $moduleobj->rights;
2521 if (isModEnabled(strtolower($module))) {
2523 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2527 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2528 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2533 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2536 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2541 clearstatcache(
true);
2542 if (function_exists(
'opcache_invalidate')) {
2546 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2552if ($action ==
'savefile' && empty($cancel)) {
2553 $relofcustom = basename($dirins);
2557 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2558 $file = $relofcustom.
'/'.$file;
2566 dol_copy($pathoffile, $pathoffilebackup, 0, 1);
2569 $check =
'restricthtml';
2571 if ($srclang ==
'md') {
2572 $check =
'restricthtml';
2574 if ($srclang ==
'lang') {
2575 $check =
'restricthtml';
2577 if ($srclang ==
'php') {
2581 $content =
GETPOST(
'editfilecontent', $check);
2586 $result = file_put_contents($pathoffile, $content);
2603if ($action ==
'set' && $user->admin) {
2606 $param .=
'&module='.urlencode($module);
2609 $param .=
'&tab='.urlencode($tab);
2612 $param .=
'&tabobj='.urlencode($tabobj);
2615 $value =
GETPOST(
'value',
'alpha');
2617 if (!empty($resarray[
'errors'])) {
2621 if ($resarray[
'nbperms'] > 0) {
2622 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2623 $resqltmp = $db->query($tmpsql);
2625 $obj = $db->fetch_object($resqltmp);
2627 if ($obj && $obj->nb > 1) {
2628 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2636 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2641if ($action ==
'reset' && $user->admin) {
2644 $param .=
'&module='.urlencode($module);
2647 $param .=
'&tab='.urlencode($tab);
2650 $param .=
'&tabobj='.urlencode($tabobj);
2653 $value =
GETPOST(
'value',
'alpha');
2658 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2663if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey')) {
2665 if (isModEnabled(strtolower($module))) {
2667 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2671 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2672 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2676 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2678 $class =
'mod'.$module;
2679 if (class_exists($class)) {
2681 $moduleobj =
new $class($db);
2688 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2689 $destdir = $dir.
'/'.strtolower($module);
2691 $result = array_map(
'strtolower', $objects);
2693 $menus = $moduleobj->menu;
2695 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2698 if ($checkcomment < 0) {
2699 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2701 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2702 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2703 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2711 clearstatcache(
true);
2712 if (function_exists(
'opcache_invalidate')) {
2717 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2723if ($dirins && $action ==
'addmenu' && empty($cancel)) {
2725 if (isModEnabled(strtolower($module))) {
2727 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2731 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2732 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2738 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2740 $class =
'mod'.$module;
2741 if (class_exists($class)) {
2743 $moduleobj =
new $class($db);
2750 $menus = $moduleobj->menu;
2753 if (!
GETPOST(
'type',
'alpha')) {
2755 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2757 if (!
GETPOST(
'titre',
'alpha')) {
2759 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2761 if (!
GETPOST(
'user',
'alpha')) {
2763 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2765 if (!
GETPOST(
'url',
'alpha')) {
2767 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2769 if (!empty(
GETPOST(
'target'))) {
2770 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2771 if (!in_array(
GETPOST(
'target'), $targets)) {
2773 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2780 foreach ($menus as $menu) {
2783 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2786 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2788 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2793 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2794 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2796 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2799 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2800 $destdir = $dirins.
'/'.strtolower($module);
2803 if (
GETPOST(
'type',
'alpha') ==
'left') {
2804 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2806 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2809 if (
GETPOST(
'type',
'alpha') ==
'top') {
2811 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2814 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2818 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2819 'type' =>
GETPOST(
'type',
'alpha'),
2820 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2822 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2823 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2824 'url' =>
GETPOST(
'url',
'alpha'),
2825 'langs' => strtolower($module).
"@".strtolower($module),
2827 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2828 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2829 'target' =>
GETPOST(
'target',
'alpha'),
2830 'user' =>
GETPOST(
'user',
'alpha'),
2833 if (
GETPOST(
'type') ==
'left') {
2834 unset($menuToAdd[
'prefix']);
2835 if (empty(
GETPOST(
'fk_menu'))) {
2836 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2838 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2841 if (
GETPOST(
'enabled') ==
'1') {
2842 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2844 $menuToAdd[
'enabled'] =
"0";
2846 if (empty(
GETPOST(
'objects'))) {
2847 $menuToAdd[
'perms'] =
'1';
2851 if ($checkcomment < 0) {
2852 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2855 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2857 clearstatcache(
true);
2858 if (function_exists(
'opcache_invalidate')) {
2867 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2875if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj')) {
2876 $objectname =
GETPOST(
'tabobj');
2877 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2878 $destdir = $dirins.
'/'.strtolower($module);
2881 if (empty($cancel)) {
2882 if (isModEnabled(strtolower($module))) {
2884 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2888 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2889 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2894 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2896 $class =
'mod'.$module;
2897 if (class_exists($class)) {
2899 $moduleobj =
new $class($db);
2905 $menus = $moduleobj->menu;
2908 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2910 $menuModify = array(
2911 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2912 'type' =>
GETPOST(
'type',
'alpha'),
2913 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2914 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2915 'leftmenu' => $menus[$key][
'leftmenu'],
2916 'url' =>
GETPOST(
'url',
'alpha'),
2917 'langs' => strtolower($module).
"@".strtolower($module),
2919 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2920 'perms' =>
GETPOST(
'perms',
'alpha'),
2921 'target' =>
GETPOST(
'target',
'alpha'),
2922 'user' =>
GETPOST(
'user',
'alpha'),
2924 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
2925 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2926 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
2927 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
2929 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
2931 if ($menuModify[
'enabled'] ===
'') {
2932 $menuModify[
'enabled'] =
'1';
2934 if ($menuModify[
'perms'] ===
'') {
2935 $menuModify[
'perms'] =
'1';
2938 if (
GETPOST(
'type',
'alpha') ==
'top') {
2940 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2947 if ($checkComment < 0) {
2948 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2951 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
2953 clearstatcache(
true);
2954 if (function_exists(
'opcache_invalidate')) {
2961 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));
2966 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2971 $_POST[
'type'] =
'';
2972 $_POST[
'titre'] =
'';
2973 $_POST[
'fk_menu'] =
'';
2974 $_POST[
'leftmenu'] =
'';
2980if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel)) {
2981 if (isModEnabled(strtolower($module))) {
2983 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2987 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2988 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2991 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2992 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2993 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
2997 $class =
'mod'.$module;
2998 if (class_exists($class)) {
3000 $moduleobj =
new $class($db);
3007 $keydescription =
GETPOST(
'keydescription',
'alpha');
3008 switch ($keydescription) {
3010 $propertyToUpdate =
'description';
3017 $propertyToUpdate = $keydescription;
3020 $error =
GETPOST(
'keydescription');
3024 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3025 $newValue =
GETPOST(
'propsmodule');
3026 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3027 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3030 if ($propertyToUpdate ===
'version') {
3031 dolReplaceInFile($modulelogfile, array(
"## ".$moduleobj->$propertyToUpdate => $newValue));
3034 $fileLines = file($moduledescriptorfile);
3035 foreach ($fileLines as &$line) {
3036 if (strpos($line, $lineToReplace) === 0) {
3042 clearstatcache(
true);
3043 if (function_exists(
'opcache_invalidate')) {
3046 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3047 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3057$form =
new Form($db);
3068 '/includes/ace/src/ace.js',
3069 '/includes/ace/src/ext-statusbar.js',
3070 '/includes/ace/src/ext-language_tools.js',
3075llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3078$text = $langs->trans(
"ModuleBuilder");
3082print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
3083print
'<br class="hideonsmartphone">';
3092 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3097 $langs->load(
"errors");
3098 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3102 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3111$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3115$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3116$allowonlineinstall =
true;
3117if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3118 $allowonlineinstall =
false;
3120if (empty($allowonlineinstall)) {
3123 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3126 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0, 1,
'warning');
3141if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3142 $modulelowercase = strtolower($module);
3143 $loadclasserrormessage =
'';
3147 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3152 $class =
'mod'.$module;
3153 }
catch (Throwable $e) {
3154 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3155 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3156 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3159 if (class_exists($class)) {
3161 $moduleobj =
new $class($db);
3164 print $e->getMessage();
3167 if (empty($forceddirread)) {
3170 $langs->load(
"errors");
3171 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3172 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3173 print $loadclasserrormessage;
3184$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3185$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3186$head[$h][2] =
'initmodule';
3189$linktoenabledisable =
'';
3191if (is_array($listofmodules) && count($listofmodules) > 0) {
3193 $modulelowercase = strtolower($module);
3197 $param .=
'&tab='.urlencode($tab);
3200 $param .=
'&module='.urlencode($module);
3203 $param .=
'&tabobj='.urlencode($tabobj);
3206 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3209 if (isModEnabled($modulelowercase)) {
3210 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3211 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'',
false, 0, 0,
'',
'', 1);
3212 $linktoenabledisable .=
'</a>';
3214 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3216 $objMod = $moduleobj;
3217 $backtourlparam =
'';
3218 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3220 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3222 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3225 if (is_array($objMod->config_page_url)) {
3227 foreach ($objMod->config_page_url as $page) {
3230 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3233 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3234 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3235 $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>';
3239 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3240 $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>';
3244 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3245 $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>';
3248 if (!empty($moduleobj)) {
3249 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3250 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"',
false, 0, 0,
'',
'classfortooltip', 1);
3251 $linktoenabledisable .=
"</a>\n";
3256 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3257 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3258 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3259 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3261 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3262 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3269$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3270$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3271$head[$h][2] =
'deletemodule';
3277if ($module ==
'initmodule') {
3279 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3281 print
'<input type="hidden" name="action" value="initmodule">';
3282 print
'<input type="hidden" name="module" value="initmodule">';
3287 print
'<div class="tagtable">';
3289 print
'<div class="tagtr"><div class="tagtd paddingright">';
3290 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3291 print
'</div><div class="tagtd">';
3292 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
3293 print
'<span class="opacitymedium">';
3295 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3297 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3300 print
'</div></div>';
3302 print
'<div class="tagtr"><div class="tagtd paddingright">';
3303 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3304 print
'</div><div class="tagtd">';
3305 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3306 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3307 print
'</div></div>';
3309 print
'<div class="tagtr"><div class="tagtd paddingright">';
3310 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3311 print
'</div><div class="tagtd">';
3312 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3313 print
'</div></div>';
3315 print
'<div class="tagtr"><div class="tagtd paddingright">';
3316 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3317 print
'</div><div class="tagtd">';
3318 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")).
'">';
3319 print
'</div></div>';
3321 print
'<div class="tagtr"><div class="tagtd paddingright">';
3322 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3323 print
'</div><div class="tagtd">';
3324 print
'<select name="family" id="family" class="minwidth400">';
3325 $arrayoffamilies = array(
3326 'hr' =>
"ModuleFamilyHr",
3327 'crm' =>
"ModuleFamilyCrm",
3328 'srm' =>
"ModuleFamilySrm",
3329 'financial' =>
'ModuleFamilyFinancial',
3330 'products' =>
'ModuleFamilyProducts',
3331 'projects' =>
'ModuleFamilyProjects',
3332 'ecm' =>
'ModuleFamilyECM',
3333 'technic' =>
'ModuleFamilyTechnic',
3334 'portal' =>
'ModuleFamilyPortal',
3335 'interface' =>
'ModuleFamilyInterface',
3336 'base' =>
'ModuleFamilyBase',
3337 'other' =>
'ModuleFamilyOther'
3339 foreach ($arrayoffamilies as $key => $value) {
3340 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>';
3344 print
'</div></div>';
3346 print
'<div class="tagtr"><div class="tagtd paddingright">';
3347 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3348 print
'</div><div class="tagtd">';
3349 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file-o')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3350 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3351 print
'</div></div>';
3353 print
'<div class="tagtr"><div class="tagtd paddingright">';
3354 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3355 print
'</div><div class="tagtd">';
3356 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>';
3357 print
'</div></div>';
3359 print
'<div class="tagtr"><div class="tagtd paddingright">';
3360 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3361 print
'</div><div class="tagtd">';
3362 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>';
3363 print
'</div></div>';
3365 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3367} elseif ($module ==
'deletemodule') {
3368 print
'<!-- Form to init a module -->'.
"\n";
3369 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3370 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3371 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3372 print
'<input type="hidden" name="module" value="deletemodule">';
3374 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3376 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3377 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3379} elseif (!empty($module)) {
3382 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3383 $destdir = $dirread.
'/'.strtolower($module);
3387 $countDictionaries = (!empty($moduleobj->dictionaries) ? count($moduleobj->dictionaries[
'tabname']) : 0);
3388 $countRights = count($moduleobj->rights);
3389 $countMenus = count($moduleobj->menu);
3401 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3402 $head2[$h][1] = $langs->trans(
"Description");
3403 $head2[$h][2] =
'description';
3406 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3407 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3408 $head2[$h][2] =
'objects';
3411 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3412 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3413 $head2[$h][2] =
'languages';
3416 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3417 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3418 $head2[$h][2] =
'dictionaries';
3421 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3422 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3423 $head2[$h][2] =
'permissions';
3426 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3427 $head2[$h][1] = $langs->trans(
"Tabs");
3428 $head2[$h][2] =
'tabs';
3431 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3432 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3433 $head2[$h][2] =
'menus';
3436 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3437 $head2[$h][1] = $langs->trans(
"Hooks");
3438 $head2[$h][2] =
'hooks';
3441 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3442 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3443 $head2[$h][2] =
'triggers';
3446 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3447 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3448 $head2[$h][2] =
'widgets';
3451 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3452 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3453 $head2[$h][2] =
'emailings';
3456 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3457 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3458 $head2[$h][2] =
'exportimport';
3461 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3462 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3463 $head2[$h][2] =
'css';
3466 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3467 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3468 $head2[$h][2] =
'js';
3471 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3472 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3473 $head2[$h][2] =
'cli';
3476 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3477 $head2[$h][1] = $langs->trans(
"CronList");
3478 $head2[$h][2] =
'cron';
3481 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3482 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="paddingleft badge">'.$hasDoc.
"</span>");
3483 $head2[$h][2] =
'specifications';
3486 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3487 $head2[$h][1] = $langs->trans(
"BuildPackage");
3488 $head2[$h][2] =
'buildpackage';
3491 $MAXTABFOROBJECT = 15;
3493 print
'<!-- Section for a given module -->';
3497 if ($tab ==
'description') {
3498 print
'<!-- tab=description -->'.
"\n";
3499 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3500 $pathtofilereadme = $modulelowercase.
'/README.md';
3501 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3503 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3505 if ($action !=
'editfile' || empty($file)) {
3506 $morehtmlright =
'';
3507 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3508 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3511 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3513 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3519 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3520 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>';
3524 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3525 foreach ($listofsetuppages as $setuppage) {
3528 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SetupFile").
' : ';
3529 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3530 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>';
3534 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3535 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>';
3538 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3539 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>';
3545 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3547 if (!empty($moduleobj)) {
3548 print
'<div class="underbanner clearboth"></div>';
3549 print
'<div class="fichecenter">';
3550 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3551 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3552 print
'<input type="hidden" name="action" value="update_props_module">';
3553 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3554 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3555 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3556 print
'<table class="border centpercent">';
3557 print
'<tr class="liste_titre"><td class="titlefield">';
3558 print $langs->trans(
"Parameter");
3560 print $langs->trans(
"Value");
3564 print $langs->trans(
"IdModule");
3566 print $moduleobj->numero;
3567 print
'<span class="opacitymedium">';
3569 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3570 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3575 print $langs->trans(
"ModuleName");
3577 print $moduleobj->getName();
3581 print $langs->trans(
"Description");
3583 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3584 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->description).
'">';
3585 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3586 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3588 print $moduleobj->description;
3589 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>';
3591 $moduledescritpionautotrans = $moduleobj->getDesc();
3592 if ($moduledescritpionautotrans !=
"Module".$moduleobj->name.
"Desc") {
3594 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3595 } elseif ($moduledescritpionautotrans !=
"Module".$moduleobj->numero.
"Desc") {
3597 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3603 print $langs->trans(
"Version");
3605 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3606 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->getVersion()).
'">';
3607 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3608 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3610 print $moduleobj->getVersion();
3611 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>';
3616 print $langs->trans(
"Family");
3619 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3620 print
'<select name="propsmodule" id="family" class="minwidth400">';
3621 $arrayoffamilies = array(
3622 'hr' =>
"ModuleFamilyHr",
3623 'crm' =>
"ModuleFamilyCrm",
3624 'srm' =>
"ModuleFamilySrm",
3625 'financial' =>
'ModuleFamilyFinancial',
3626 'products' =>
'ModuleFamilyProducts',
3627 'projects' =>
'ModuleFamilyProjects',
3628 'ecm' =>
'ModuleFamilyECM',
3629 'technic' =>
'ModuleFamilyTechnic',
3630 'portal' =>
'ModuleFamilyPortal',
3631 'interface' =>
'ModuleFamilyInterface',
3632 'base' =>
'ModuleFamilyBase',
3633 'other' =>
'ModuleFamilyOther'
3635 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>';
3636 foreach ($arrayoffamilies as $key => $value) {
3637 if ($key != $moduleobj->family) {
3638 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3642 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3643 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3645 print $moduleobj->family;
3646 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>';
3651 print $langs->trans(
"Picto");
3653 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3654 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->picto).
'">';
3655 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3656 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3658 print $moduleobj->picto;
3659 print
' '.img_picto(
'', $moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3660 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>';
3665 print $langs->trans(
"EditorName");
3667 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3668 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_name).
'">';
3669 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3670 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3672 print $moduleobj->editor_name;
3673 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>';
3678 print $langs->trans(
"EditorUrl");
3680 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3681 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_url).
'">';
3682 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3683 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3685 if (!empty($moduleobj->editor_url)) {
3686 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3688 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>';
3695 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3698 if (!empty($moduleobj)) {
3702 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3704 print
'<!-- readme file -->';
3705 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3706 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3708 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3714 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3716 print
'<!-- changelog file -->';
3718 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3720 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3728 if ($fullpathoffile) {
3729 $content = file_get_contents($fullpathoffile);
3733 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3734 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3735 print
'<input type="hidden" name="action" value="savefile">';
3736 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3737 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3738 print
'<input type="hidden" name="module" value="'.$module.
'">';
3742 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
3743 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3744 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3749 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3751 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3757 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3760 if ($tab ==
'languages') {
3761 print
'<!-- tab=languages -->'.
"\n";
3762 if ($action !=
'editfile' || empty($file)) {
3763 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3767 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3768 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3769 print
'<input type="hidden" name="action" value="addlanguage">';
3770 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3771 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3772 print
'<input type="hidden" name="module" value="'.$module.
'">';
3773 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, 0, 1, 0, 0,
'minwidth300', 1);
3774 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3780 $modulelowercase = strtolower($module);
3784 $diroflang .=
'/langs';
3785 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3787 if (!preg_match(
'/custom/', $dirread)) {
3789 $diroflang = $dirread;
3790 $diroflang .=
'/langs';
3791 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3794 print
'<table class="none">';
3795 foreach ($langfiles as $langfile) {
3796 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3797 if (!preg_match(
'/custom/', $dirread)) {
3798 $pathtofile =
'langs/'.$langfile[
'relativename'];
3800 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3801 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>';
3802 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>';
3813 $content = file_get_contents($fullpathoffile);
3816 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3817 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3818 print
'<input type="hidden" name="action" value="savefile">';
3819 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3820 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3821 print
'<input type="hidden" name="module" value="'.$module.
'">';
3823 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3824 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3827 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3829 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3836 if ($tab ==
'objects') {
3837 print
'<!-- tab=objects -->'.
"\n";
3842 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3844 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3845 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3846 $head3[$h][2] =
'newobject';
3850 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3852 $firstobjectname =
'';
3853 foreach ($listofobject as $fileobj) {
3854 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3857 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3861 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3862 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3864 $objectname = $reg[1];
3865 if (empty($firstobjectname)) {
3866 $firstobjectname = $objectname;
3868 $pictoname =
'generic';
3869 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3870 $pictoname = $reg[1];
3873 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3874 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3875 $head3[$h][2] = $objectname;
3881 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
3882 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3883 $head3[$h][2] =
'deleteobject';
3888 if ($tabobj ==
'newobjectifnoobj') {
3889 if ($firstobjectname) {
3890 $tabobj = $firstobjectname;
3892 $tabobj =
'newobject';
3896 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
3899 if ($tabobj ==
'newobject') {
3901 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3902 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3903 print
'<input type="hidden" name="action" value="initobject">';
3904 print
'<input type="hidden" name="tab" value="objects">';
3905 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3907 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
3909 print
'<div class="tagtable">';
3911 print
'<div class="tagtr"><div class="tagtd">';
3912 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
3913 print
'</div><div class="tagtd">';
3914 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
3915 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
3916 print
'</div></div>';
3918 print
'<div class="tagtr"><div class="tagtd">';
3919 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
3920 print
'</div><div class="tagtd">';
3921 print
'<input type="text" name="idpicto" value="fa-file-o" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3922 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3923 print
'</div></div>';
3925 print
'<div class="tagtr"><div class="tagtd">';
3926 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
3927 print
'</div><div class="tagtd">';
3928 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
3929 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
3930 print
'</div></div>';
3935 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>';
3936 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
3937 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
3939 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3955 } elseif ($tabobj ==
'createproperty') {
3956 $attributesUnique = array(
3957 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
3958 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
3959 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
3960 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
3961 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
3962 'propdefault' => $langs->trans(
"DefaultValue"),
3963 'propindex' => $langs->trans(
"DatabaseIndex"),
3964 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
3965 'propposition' => $langs->trans(
"Position"),
3966 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
3967 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
3968 'propnoteditable' => $langs->trans(
"NotEditable"),
3970 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
3971 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
3972 'propcss' => $langs->trans(
"CSSClass"),
3973 'propcssview' => $langs->trans(
"CSSViewClass"),
3974 'propcsslist' => $langs->trans(
"CSSListClass"),
3975 'prophelp' => $langs->trans(
"KeyForTooltip"),
3976 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
3978 'propcomment' => $langs->trans(
"Comment"),
3980 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
3981 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3982 print
'<input type="hidden" name="action" value="addproperty">';
3983 print
'<input type="hidden" name="tab" value="objects">';
3984 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3985 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
3987 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
3989 foreach ($attributesUnique as $key => $attribute) {
3990 if ($counter % 2 === 0) {
3993 if ($key ==
'propname' || $key ==
'proplabel') {
3994 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>';
3995 } elseif ($key ==
'proptype') {
3996 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
3997 print
'<input class="maxwidth200" id="'.$key.
'" list="datalist'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
3999 print
'<datalist id="datalist'.$key.
'">';
4000 print
'<option>varchar(128)</option>';
4001 print
'<option>email</option>';
4002 print
'<option>phone</option>';
4003 print
'<option>ip</option>';
4004 print
'<option>url</option>';
4005 print
'<option>password</option>';
4006 print
'<option>text</option>';
4007 print
'<option>html</option>';
4008 print
'<option>date</option>';
4009 print
'<option>datetime</option>';
4010 print
'<option>integer</option>';
4011 print
'<option>double(28,4)</option>';
4012 print
'<option>real</option>';
4013 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4022 print
'</datalist>';
4026 } elseif ($key ==
'propvisible') {
4027 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>';
4028 } elseif ($key ==
'propenabled') {
4031 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>';
4032 } elseif ($key ==
'proparrayofkeyval') {
4033 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>';
4035 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>';
4038 if ($counter % 2 === 0) {
4042 if ($counter % 2 !== 0) {
4043 while ($counter % 2 !== 0) {
4049 print
'</table><br>'.
"\n";
4050 print
'<div class="center">';
4051 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4052 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4058 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4059 window.location.href = url;
4061 $(document).ready(function() {
4062 $("#proplabel").on("keyup", function() {
4063 console.log("key up on label");
4064 s = cleanString($("#proplabel").val());
4065 $("#propname").val(s);
4068 function cleanString( stringtoclean )
4070 // allow "a-z", "A-Z", "0-9" and "_"
4071 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4072 stringtoclean = stringtoclean.toLowerCase();
4073 if (!isNaN(stringtoclean)) {
4076 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4077 stringtoclean = stringtoclean.substr(1)
4079 if (stringtoclean.length > 28) {
4080 stringtoclean = stringtoclean.substring(0, 27);
4082 return stringtoclean;
4087 } elseif ($tabobj ==
'deleteobject') {
4089 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4090 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4091 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4092 print
'<input type="hidden" name="tab" value="objects">';
4093 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4094 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4096 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4098 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4099 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4103 if ($action ==
'deleteproperty') {
4104 $formconfirm = $form->formconfirm(
4105 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4106 $langs->trans(
'Delete'),
4107 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4108 'confirm_deleteproperty',
4117 if ($action !=
'editfile' || empty($file)) {
4121 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4122 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4123 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4124 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4125 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4126 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4127 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4128 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4129 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4132 clearstatcache(
true);
4133 if (function_exists(
'opcache_invalidate')) {
4134 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4137 if (empty($forceddirread) && empty($dirread)) {
4139 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4141 $result = include_once $dirread.
'/'.$pathtoclass;
4142 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4145 if (class_exists($tabobj)) {
4147 $tmpobject = @
new $tabobj($db);
4149 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4152 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4156 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4159 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4162 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4165 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4168 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4169 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4172 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4175 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4178 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4181 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4183 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4185 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4186 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4188 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4189 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4191 $tmpobject = $tmpobject ??
null;
4192 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4193 $pathtopicto = $tmpobject->picto;
4194 $realpathtopicto =
'';
4196 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4197 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4202 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4203 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4204 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4205 $realpathtocard = $dirread.
'/'.$pathtocard;
4206 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4207 $realpathtolist = $dirread.
'/'.$pathtolist;
4208 $realpathtonote = $dirread.
'/'.$pathtonote;
4209 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4210 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4211 $realpathtosql = $dirread.
'/'.$pathtosql;
4212 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4213 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4214 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4215 $realpathtolib = $dirread.
'/'.$pathtolib;
4216 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4218 if (empty($realpathtoapi)) {
4219 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4220 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4228 print
'<!-- section for object -->';
4229 print
'<div class="fichehalfleft smallxxx">';
4231 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>';
4232 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>';
4235 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4236 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>';
4239 } elseif (!empty($tmpobject)) {
4240 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4246 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>';
4248 $file = file_get_contents($realpathtoapi);
4249 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4250 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>';
4252 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>';
4253 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4256 if ($modulelowercase !==
null && !isModEnabled($modulelowercase)) {
4257 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4259 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4262 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>';
4265 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>';
4269 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>';
4271 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>';
4273 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>';
4275 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>';
4281 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>';
4282 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>';
4284 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>';
4285 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>';
4289 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>';
4290 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>';
4291 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>';
4294 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>';
4295 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>';
4298 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>';
4300 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>';
4302 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>';
4304 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>';
4306 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>';
4310 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>';
4312 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>';
4314 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>';
4316 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>';
4321 print
'<div class="fichehalfleft smallxxxx">';
4322 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>';
4323 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>';
4325 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>';
4326 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>';
4329 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>';
4330 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>';
4333 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>';
4335 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>';
4339 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>';
4340 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>';
4343 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>';
4345 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>';
4349 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>';
4350 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>';
4353 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>';
4355 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>';
4359 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>';
4360 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>';
4363 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>';
4365 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>';
4372 print
'<br><br><br>';
4374 if (!empty($tmpobject)) {
4375 $reflector =
new ReflectionClass($tabobj);
4376 $reflectorproperties = $reflector->getProperties();
4377 $reflectorpropdefault = $reflector->getDefaultProperties();
4381 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4382 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4383 print
'<input type="hidden" name="action" value="addproperty">';
4384 print
'<input type="hidden" name="tab" value="objects">';
4385 print
'<input type="hidden" name="page_y" value="">';
4386 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4387 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4389 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4392 $mod = strtolower($module);
4393 $obj = strtolower($tabobj);
4394 $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));
4395 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4397 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'', $nbOfProperties,
'', 0, $newproperty,
'',
'', 0, 0, 1);
4400 print
'<!-- Table with properties of object -->'.
"\n";
4401 print
'<div class="div-table-responsive">';
4402 print
'<table class="noborder small">';
4403 print
'<tr class="liste_titre">';
4404 print
'<th class="tdsticky tdstickygray">';
4405 $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>';
4406 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4409 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4411 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4412 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4413 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4414 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4415 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4416 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4417 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4418 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4419 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4420 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4422 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4423 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4424 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4425 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4426 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4427 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4428 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4430 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4431 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4432 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4438 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4439 if (!empty($properties)) {
4441 foreach ($properties as $propkey => $propval) {
4456 $propname = $propkey;
4457 $proplabel = $propval[
'label'];
4458 $proptype = $propval[
'type'];
4459 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4460 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4461 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4462 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4463 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4464 $propposition = $propval[
'position'];
4465 $propenabled = $propval[
'enabled'];
4466 $propvisible = $propval[
'visible'];
4467 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4469 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4470 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4471 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4472 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4473 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4474 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4475 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4477 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4478 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4480 print
'<!-- line for object property -->'.
"\n";
4481 print
'<tr class="oddeven">';
4483 print
'<td class="tdsticky tdstickygray">';
4486 if ($action ==
'editproperty' && $propname == $propertykey) {
4488 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4489 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4491 print
'<td class="tdoverflowmax150">';
4492 print
'<input name="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'"></input>';
4494 print
'<td class="tdoverflowmax200">';
4495 print
'<textarea name="proparrayofkeyval">';
4496 if (isset($proparrayofkeyval)) {
4497 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4501 print
'</textarea>';
4504 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4507 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4509 print
'<td class="center">';
4510 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4513 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4516 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4519 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4522 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4525 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4531 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4534 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4537 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4540 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4543 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4546 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4549 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4552 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4555 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4557 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4558 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4559 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4562 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4565 print
'<td class="tdoverflowmax200">';
4568 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4569 $pictoType =
'varchar';
4570 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4571 $pictoType =
'link';
4572 } elseif (strpos($proptype,
'integer') === 0) {
4573 $pictoType = substr($proptype, 0, 3);
4574 } elseif (strpos($proptype,
'timestamp') === 0) {
4575 $pictoType =
'datetime';
4576 } elseif (strpos($proptype,
'real') === 0) {
4577 $pictoType =
'double';
4581 print
'<td class="tdoverflowmax200">';
4582 if ($proparrayofkeyval) {
4583 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4588 print
'<td class="center">';
4594 print
'<td class="center">';
4595 print $propindex ?
'1' :
'';
4597 print
'<td class="center">';
4600 print
'<td class="right">';
4603 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4607 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4611 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4617 print
'<td class="center">';
4618 print $propsearchall ?
'1' :
'';
4620 print
'<td class="center">';
4623 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4626 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4629 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4633 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4636 print
'<td class="center">';
4642 print
'<td class="center">';
4645 print
'<td class="tdoverflowmax200">';
4646 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4650 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4651 if ($propname !=
'rowid') {
4652 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>';
4653 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>';
4660 if ($tab ==
'specifications') {
4661 if ($action !=
'editfile' || empty($file)) {
4662 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4667 foreach ($specs as $spec) {
4668 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4669 $format =
'asciidoc';
4670 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4671 $format =
'markdown';
4673 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4674 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>';
4684 $content = file_get_contents($fullpathoffile);
4687 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4688 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4689 print
'<input type="hidden" name="action" value="savefile">';
4690 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4691 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4692 print
'<input type="hidden" name="module" value="'.$module.
'">';
4694 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4695 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4698 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4700 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4706 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>';
4713 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4717 print $e->getMessage();
4721 if (empty($forceddirread)) {
4724 $fullpathoffile = $dirread.
'/'.$file;
4727 $content = file_get_contents($fullpathoffile);
4730 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4731 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4732 print
'<input type="hidden" name="action" value="savefile">';
4733 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4734 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4735 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4736 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4738 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4739 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4742 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4744 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4754 if ($tab ==
'dictionaries') {
4755 print
'<!-- tab=dictionaries -->'.
"\n";
4756 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4758 $dicts = $moduleobj->dictionaries;
4760 if ($action ==
'deletedict') {
4761 $formconfirm = $form->formconfirm(
4762 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
4763 $langs->trans(
'Delete'),
4764 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
4765 'confirm_deletedictionary',
4773 if ($action !=
'editfile' || empty($file)) {
4774 print
'<span class="opacitymedium">';
4775 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4776 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4777 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4781 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4782 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=DICTIONARIES">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4784 if (is_array($dicts) && !empty($dicts)) {
4785 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4786 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
4796 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
4797 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4798 $head3[$h][2] =
'newdictionary';
4839 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).
'&tabdic=newdictionary');
4840 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"),
'', $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 0, $newdict,
'',
'', 0, 0, 1);
4842 if ($tabdic !=
'newdictionary') {
4843 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4844 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4845 print
'<input type="hidden" name="action" value="addDictionary">';
4846 print
'<input type="hidden" name="tab" value="dictionaries">';
4847 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4848 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
4850 print
'<div class="div-table-responsive">';
4851 print
'<table class="noborder">';
4853 print
'<tr class="liste_titre">';
4854 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
4867 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
4869 $maxi = count($dicts[
'tabname']);
4870 while ($i < $maxi) {
4871 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
4872 print
'<tr class="oddeven">';
4873 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4874 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4875 print
'<input type="hidden" name="tab" value="dictionaries">';
4876 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4877 print
'<input type="hidden" name="action" value="updatedictionary">';
4878 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
4880 print
'<td class="tdsticky tdstickygray">';
4885 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
4889 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
4893 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
4897 print
'<select name="tabsqlsort">';
4898 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
4902 print
'<td><select name="tabfield" >';
4903 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
4904 print
'</select></td>';
4906 print
'<td><select name="tabfieldvalue" >';
4907 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
4908 print
'</select></td>';
4910 print
'<td><select name="tabfieldinsert" >';
4911 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
4912 print
'</select></td>';
4915 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
4919 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
4922 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4923 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
4925 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4931 print
'<tr class="oddeven">';
4933 print
'<td class="tdsticky tdstickygray">';
4938 print $dicts[
'tabname'][$i];
4942 print $dicts[
'tablib'][$i];
4946 print $dicts[
'tabsql'][$i];
4950 print $dicts[
'tabsqlsort'][$i];
4954 print $dicts[
'tabfield'][$i];
4958 print $dicts[
'tabfieldvalue'][$i];
4962 print $dicts[
'tabfieldinsert'][$i];
4966 print $dicts[
'tabrowid'][$i];
4970 print $dicts[
'tabcond'][$i];
4973 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4974 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdict&token='.
newToken().
'&dictionnarykey='.urlencode((
string) ($i + 1)).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'">'.
img_edit().
'</a>';
4975 print
'<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deletedict&token='.
newToken().
'&dictionnarykey='.urlencode((
string) ($i + 1)).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'">'.
img_delete().
'</a>';
4983 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
4992 if ($tabdic ==
'newdictionary') {
4994 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4995 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4996 print
'<input type="hidden" name="action" value="initdic">';
4997 print
'<input type="hidden" name="tab" value="dictionaries">';
4998 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5000 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5002 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5005 print
'<table class="border centpercent">';
5007 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Table").
'</td><td><input type="text" name="dicname" maxlength="64" value="'.
dol_escape_htmltag(
GETPOST(
'dicname',
'alpha') ?
GETPOST(
'dicname',
'alpha') : $modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'" autofocus></td>';
5008 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td><input type="text" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label',
'alpha')).
'"></td></tr>';
5009 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SQL").
'</td><td><input type="text" style="width:50%;" name="sql" value="'.
dol_escape_htmltag(
GETPOST(
'sql',
'alpha')).
'"></td></tr>';
5010 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SQLSort").
'</td><td><input type="text" name="sqlsort" value="'.
dol_escape_htmltag(
GETPOST(
'sqlsort',
'alpha')).
'" readonly></td></tr>';
5011 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5012 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5013 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5014 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5016 print
'</tbody></table>';
5017 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5018 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5022 $(document).ready(function() {
5023 $("input[name=\'dicname\']").on("blur", function() {
5024 if ($(this).val().length > 0) {
5025 $("input[name=\'label\']").val($(this).val());
5026 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5027 $("input[name=\'sqlsort\']").val("label ASC");
5028 $("input[name=\'field\']").val("code,label");
5029 $("input[name=\'fieldvalue\']").val("code,label");
5030 $("input[name=\'fieldinsert\']").val("code,label");
5031 $("input[name=\'rowid\']").val("rowid");
5033 $("input[name=\'label\']").val("");
5034 $("input[name=\'sql\']").val("");
5035 $("input[name=\'sqlsort\']").val("");
5036 $("input[name=\'field\']").val("");
5037 $("input[name=\'fieldvalue\']").val("");
5038 $("input[name=\'fieldinsert\']").val("");
5039 $("input[name=\'rowid\']").val("");
5042 $("input[id=\'cancel\']").click(function() {
5043 window.history.back();
5060 } elseif ($tabdic ==
'deletedictionary') {
5062 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5063 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5064 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5065 print
'<input type="hidden" name="tab" value="dictionaries">';
5066 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5068 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5070 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5071 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5079 $content = file_get_contents($fullpathoffile);
5082 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5083 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5084 print
'<input type="hidden" name="action" value="savefile">';
5085 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5086 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5087 print
'<input type="hidden" name="module" value="'.$module.
'">';
5089 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
5090 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5091 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5094 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5096 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5103 if ($tab ==
'menus') {
5104 print
'<!-- tab=menus -->'.
"\n";
5105 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5106 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
5107 $destdir = $dirins.
'/'.strtolower($module);
5108 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5111 $leftmenus = array();
5113 $menus = $moduleobj->menu;
5115 $permissions = $moduleobj->rights;
5116 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5119 $groupedRights = array();
5120 foreach ($permissions as $right) {
5122 if (!isset($groupedRights[$key])) {
5123 $groupedRights[$key] = array();
5125 $groupedRights[$key][] = $right;
5127 $groupedRights_json = json_encode($groupedRights);
5129 if ($action ==
'deletemenu') {
5130 $formconfirms = $form->formconfirm(
5131 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5132 $langs->trans(
'Delete'),
5133 ($menus[
GETPOST(
'menukey')][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module) ? $langs->trans(
'Warning: you will delete all menus linked to this one.',
GETPOSTINT(
'menukey')) : $langs->trans(
'Confirm Delete Menu',
GETPOSTINT(
'menukey'))),
5134 'confirm_deletemenu',
5139 print $formconfirms;
5141 if ($action !=
'editfile' || empty($file)) {
5142 print
'<span class="opacitymedium">';
5143 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5144 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/menus/index.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Menus').
'</a>', $htmlhelp);
5145 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5149 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5150 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=TOPMENU">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5156 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5157 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5158 print
'<input type="hidden" name="action" value="addmenu">';
5159 print
'<input type="hidden" name="tab" value="menus">';
5160 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5161 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5163 print
'<div class="div-table-responsive">';
5164 print
'<table class="noborder small">';
5166 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5167 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5168 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5169 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(strtolower($module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5170 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5171 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5172 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(strtolower($module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5174 print
'<tr class="liste_titre">';
5175 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5178 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5181 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5183 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5184 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5185 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5186 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5187 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5188 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5191 $r = count($menus) + 1;
5194 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5195 print
'<td class="center">';
5196 print
'<select class="maxwidth50" name="type">';
5197 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5198 print
'</select></td>';
5199 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5200 print
'<td class="left">';
5201 print
'<select name="fk_menu">';
5202 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5203 foreach ($menus as $obj) {
5204 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5205 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5210 print
'<td class="left"><input type="text" class="left maxwidth50" name="mainmenu" value="'.(empty(
GETPOST(
'mainmenu')) ? strtolower($module) :
dol_escape_htmltag(
GETPOST(
'mainmenu',
'alpha'))).
'"></td>';
5211 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5213 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5214 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5216 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5218 print
'<td class="center">';
5219 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.$module.
'\')').
'">';
5228 print
'<td class="left">';
5229 print
'<select class="maxwidth" name="objects" id="objects">';
5230 print
'<option value=""></option>';
5231 if (is_array($objects)) {
5232 foreach ($objects as $value) {
5233 print
'<option value="'.strtolower($value).
'">'.
dol_escape_htmltag(strtolower($value)).
'</option>';
5237 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5240 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5241 print
'<td class="center"><select class="maxwidth10" name="user"><option value="2">'.$langs->trans(
"AllMenus").
'</option><option value="0">'.$langs->trans(
"Internal").
'</option><option value="1">'.$langs->trans(
"External").
'</option></select></td>';
5243 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5244 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5252 if (count($menus)) {
5254 foreach ($menus as $menu) {
5258 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
5260 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5261 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5262 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5263 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5264 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5265 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5266 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5267 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5268 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5270 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5271 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5275 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5277 print
'<tr class="oddeven">';
5278 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5280 print
'<input type="hidden" name="action" value="update_menu">';
5281 print
'<input type="hidden" name="tab" value="menus">';
5282 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5283 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5285 print
'<td class="tdsticky tdstickygray">';
5289 print
'<td class="center">
5290 <select class="center maxwidth50" name="type">
5291 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5294 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5295 if ($menu[
'type'] ==
'left') {
5300 print
'</option></select></td>';
5302 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5313 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5315 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5316 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5318 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5319 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5321 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5323 print
'<td class="nowraponall">';
5324 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag($module).
"')").
'">';
5325 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5326 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5327 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5328 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag($module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5329 print $form->textwithpicto('', $htmltext);
5331 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5332 print '<option value=
"1">1 (always enabled)</option>
';
5333 print '<option value=
"0">0 (always
disabled)</option>
';
5334 print '<option value=
"isModEnabled(\''.dol_escape_htmltag($module).'\')" >isModEnabled(\
''.
dol_escape_htmltag($module).
'\')</option>
';
5339 print '<td
class=
"nowraponall">
';
5340 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5342 if (!empty($objPerms)) {
5343 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5344 print '<select
class=
"center maxwidth50" name=
"perms">
';
5345 if (!empty($valPerms)) {
5346 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5347 foreach ($crud as $key => $val) {
5348 if ($valPerms != $key) {
5349 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5355 print '<select
class=
"center maxwidth50" name=
"objects">
';
5356 print '<option></option>
';
5357 foreach ($objects as $obj) {
5358 print '<option value=
"'.dol_escape_htmltag(strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5361 print '<select
class=
"center maxwidth50" name=
"perms">
';
5362 foreach ($crud as $key => $val) {
5363 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5369 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5370 print '<td
class=
"center"><select
class=
"center maxwidth10" name=
"user"><option value=
"2">
'.$langs->trans("AllMenus").'</option><option value=
"0">
'.$langs->trans("Internal").'</option><option value=
"1">
'.$langs->trans("External").'</option></select></td>
';
5371 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5372 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5373 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5378 print '<tr
class=
"oddeven">
';
5380 print '<td
class=
"tdsticky tdstickygray">
';
5384 print '<td
class=
"center">
';
5385 print dol_escape_htmltag($menu['type']);
5390 print dol_escape_htmltag($menu['titre
']);
5394 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5395 print dol_escape_htmltag($menu['fk_menu
']);
5399 print dol_escape_htmltag($menu['mainmenu
']);
5403 print dol_escape_htmltag($menu['leftmenu
']);
5406 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5407 print dol_escape_htmltag($menu['url
']);
5411 print dol_escape_htmltag($menu['langs
']);
5415 print '<td
class=
"center">
';
5416 print dol_escape_htmltag($menu['position']);
5420 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5421 print dol_escape_htmltag($menu['enabled
']);
5425 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5426 print dol_escape_htmltag($langs->trans($menu['perms
']));
5430 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5431 print dol_escape_htmltag($menu['target
']);
5434 print '<td
class=
"center">
';
5435 if ($menu['user'] == 2) {
5436 print $langs->trans("AllMenus");
5437 } elseif ($menu['user'] == 0) {
5438 print $langs->trans('Internal
');
5439 } elseif ($menu['user'] == 1) {
5440 print $langs->trans('External
');
5442 print $menu['user']; // should not happen
5445 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
5446 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
5447 print '<a
class=
"editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href=
"'.$_SERVER["PHP_SELF
"].'?action=editmenu&token='.newToken().'&menukey='.urlencode((string) ($i)).'&tab='.urlencode((string) ($tab)).'&module='.urlencode((string) ($module)).'&tabobj='.urlencode((string) ($tabobj)).'">
'.img_edit().'</a>
';
5448 print '<a
class=
"deletefielda reposition marginleftonly marginrighttonly paddingright paddingleft" href=
"'.$_SERVER["PHP_SELF
"].'?action=deletemenu&token='.newToken().'&menukey='.urlencode((string) ($i - 1)).'&tab='.urlencode((string) ($tab)).'&module='.urlencode((string) ($module)).'">
'.img_delete().'</a>
';
5455 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
5464 $(document).ready(
function() {
5466 $(
"#leftmenu").on(
"input",
function() {
5467 var inputLeftMenu = $(
"#leftmenu").val();
5468 if (inputLeftMenu !== \
'\') {
5469 var url = \
''.dol_escape_js(strtolower($module)).
'\' + inputLeftMenu + \
'.php\';
5476 var groupedRights = ' . $groupedRights_json .
';
5477 var objectsSelect = $("select[id=\'objects\']");
5478 var permsSelect = $("select[id=\'perms\']");
5480 objectsSelect.change(function() {
5481 var selectedObject = $(this).val();
5483 permsSelect.empty();
5485 var rights = groupedRights[selectedObject];
5488 for (var i = 0; i < rights.length; i++) {
5489 var right = rights[i];
5490 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
5491 permsSelect.append(option);
5494 var option = $("<option></option>").attr("value", "read").text("read");
5495 permsSelect.append(option);
5498 if (selectedObject !== "" && selectedObject !== null && rights) {
5503 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
5514 $content = file_get_contents($fullpathoffile);
5517 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5518 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5519 print
'<input type="hidden" name="action" value="savefile">';
5520 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5521 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5522 print
'<input type="hidden" name="module" value="'.$module.
'">';
5524 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
5525 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5526 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5529 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5531 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5538 if ($tab ==
'permissions') {
5539 print
'<!-- tab=permissions -->'.
"\n";
5540 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5542 $perms = $moduleobj->rights;
5545 $dir = $dirread.
'/'.$modulelowercase.
'/class';
5546 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
5547 $objects = array(
'myobject');
5549 foreach ($listofobject as $fileobj) {
5550 $tmpcontent = file_get_contents($fileobj[
'fullname']);
5551 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
5552 $objects[$fileobj[
'fullname']] = $reg[1];
5557 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5558 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
5560 $action =
GETPOST(
'action',
'alpha');
5562 if ($action ==
'deleteright') {
5563 $formconfirm = $form->formconfirm(
5564 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)),
5565 $langs->trans(
'Delete'),
5566 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
5567 'confirm_deleteright',
5575 if ($action !=
'editfile' || empty($file)) {
5576 print
'<!-- Tab to manage permissions -->'.
"\n";
5577 print
'<span class="opacitymedium">';
5578 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
5579 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
5580 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5584 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5585 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=PERMISSIONS">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5591 print
'<!-- form to add permissions -->'.
"\n";
5592 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5593 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5594 print
'<input type="hidden" name="action" value="addright">';
5595 print
'<input type="hidden" name="tab" value="permissions">';
5596 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5597 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5599 print
'<div class="div-table-responsive">';
5600 print
'<table class="noborder">';
5602 print
'<tr class="liste_titre">';
5604 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
5611 print
'<tr class="small">';
5612 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
5614 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
5615 print
'<option value=""></option>';
5616 foreach ($objects as $obj) {
5617 if ($obj !=
'myobject') {
5618 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
5621 print
'</select></td>';
5623 print
'<td><select class="maxwidth75" name="crud" id="crud">';
5624 print
'<option value=""></option>';
5625 foreach ($crud as $key => $val) {
5626 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
5631 print
'<input type="text" name="label" id="label" class="minwidth200">';
5634 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5635 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5639 if (count($perms)) {
5641 foreach ($perms as $perm) {
5645 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
5646 print
'<tr class="oddeven">';
5647 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
5648 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5649 print
'<input type="hidden" name="tab" value="permissions">';
5650 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5651 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5652 print
'<input type="hidden" name="action" value="update_right">';
5653 print
'<input type="hidden" name="counter" value="'.$i.
'">';
5655 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
5657 print
'<td class="tdsticky tdstickygray">';
5658 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
5662 print
'<select name="crud">';
5663 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
5664 foreach ($crud as $i => $x) {
5665 if ($perm[5] != $i) {
5666 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
5672 print
'<td><select name="permissionObj" >';
5673 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
5674 print
'</select></td>';
5677 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
5680 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5681 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
5683 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5690 print
'<tr class="oddeven">';
5697 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5705 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5706 print ucfirst($langs->trans($perm[5]));
5708 print ucfirst($langs->trans($perm[4]));
5713 print $langs->trans($perm[1]);
5716 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5717 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_right&token='.
newToken().
'&permskey='.urlencode($perm[0]).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_edit().
'</a>';
5718 print
'<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteright&token='.
newToken().
'&permskey='.urlencode((
string) ($i)).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)).
'">'.
img_delete().
'</a>';
5726 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5734 function updateInputField() {
5735 value1 = $("#crud").val();
5736 value2 = $("#permissionObj").val();
5738 // Vérifie si les deux sélections sont faites
5739 if (value1 && value2) {
5740 switch(value1.toLowerCase()){
5742 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
5745 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
5748 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
5756 $("#crud, #permissionObj").change(function(){
5757 console.log("We change selection");
5765 $content = file_get_contents($fullpathoffile);
5768 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5769 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5770 print
'<input type="hidden" name="action" value="savefile">';
5771 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5772 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5773 print
'<input type="hidden" name="module" value="'.$module.
'">';
5775 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
5776 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5777 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5780 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5782 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5789 if ($tab ==
'hooks') {
5790 print
'<!-- tab=hooks -->'.
"\n";
5791 if ($action !=
'editfile' || empty($file)) {
5792 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
5797 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5799 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5801 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=HOOKSCONTEXTS">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5805 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
5806 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"HooksFile").
' : ';
5808 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5810 print
'<td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a> ';
5811 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5813 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5814 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inithook&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</td>';
5821 $content = file_get_contents($fullpathoffile);
5824 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5825 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5826 print
'<input type="hidden" name="action" value="savefile">';
5827 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5828 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5829 print
'<input type="hidden" name="module" value="'.$module.
'">';
5831 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
5832 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5833 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5836 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5838 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5845 if ($tab ==
'triggers') {
5846 print
'<!-- tab=triggers -->'.
"\n";
5847 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
5850 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
5852 if ($action !=
'editfile' || empty($file)) {
5853 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
5858 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5860 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5862 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=module_parts">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
5865 if (!empty($triggers)) {
5866 foreach ($triggers as $trigger) {
5867 $pathtofile = $trigger[
'relpath'];
5870 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5871 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5872 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5877 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TriggersFile");
5878 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5879 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inittrigger&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5888 $content = file_get_contents($fullpathoffile);
5891 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5892 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5893 print
'<input type="hidden" name="action" value="savefile">';
5894 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5895 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5896 print
'<input type="hidden" name="module" value="'.$module.
'">';
5898 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
5899 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5900 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5903 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5905 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5912 if ($tab ==
'css') {
5913 print
'<!-- tab=css -->'.
"\n";
5914 if ($action !=
'editfile' || empty($file)) {
5915 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
5921 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
5922 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"CSSFile").
' : ';
5924 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5925 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5926 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5928 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5929 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcss&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5935 $content = file_get_contents($fullpathoffile);
5938 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5939 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5940 print
'<input type="hidden" name="action" value="savefile">';
5941 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5942 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5943 print
'<input type="hidden" name="module" value="'.$module.
'">';
5945 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5946 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5949 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5951 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5959 print
'<!-- tab=js -->'.
"\n";
5960 if ($action !=
'editfile' || empty($file)) {
5961 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
5967 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
5968 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"JSFile").
' : ';
5970 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5971 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
5972 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
5974 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5975 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initjs&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
5981 $content = file_get_contents($fullpathoffile);
5984 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5985 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5986 print
'<input type="hidden" name="action" value="savefile">';
5987 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5988 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5989 print
'<input type="hidden" name="module" value="'.$module.
'">';
5991 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5992 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5995 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5997 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6004 if ($tab ==
'widgets') {
6005 print
'<!-- tab=widgets -->'.
"\n";
6006 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6010 if ($action !=
'editfile' || empty($file)) {
6011 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6015 if (!empty($widgets)) {
6016 foreach ($widgets as $widget) {
6017 $pathtofile = $widget[
'relpath'];
6019 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6020 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6021 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
6025 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6026 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initwidget&token='.
newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
6033 $content = file_get_contents($fullpathoffile);
6036 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6037 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6038 print
'<input type="hidden" name="action" value="savefile">';
6039 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6040 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6041 print
'<input type="hidden" name="module" value="'.$module.
'">';
6043 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6044 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6047 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6049 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6056 if ($tab ==
'emailings') {
6057 print
'<!-- tab=emailings -->'.
"\n";
6058 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6062 if ($action !=
'editfile' || empty($file)) {
6063 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6067 if (!empty($emailingselectors)) {
6068 foreach ($emailingselectors as $emailingselector) {
6069 $pathtofile = $emailingselector[
'relpath'];
6071 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6072 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6073 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
6077 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6078 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initemailing&token='.
newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
6085 $content = file_get_contents($fullpathoffile);
6088 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6089 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6090 print
'<input type="hidden" name="action" value="savefile">';
6091 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6092 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6093 print
'<input type="hidden" name="module" value="'.$module.
'">';
6095 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6096 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6099 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6101 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6108 if ($tab ==
'exportimport') {
6109 print
'<!-- tab=exportimport -->'.
"\n";
6110 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6112 $exportlist = $moduleobj->export_label;
6113 $importlist = $moduleobj->import_label;
6115 if ($action !=
'editfile' || empty($file)) {
6116 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6119 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6120 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=EXPORT">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6122 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6123 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=IMPORT">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6128 $content = file_get_contents($fullpathoffile);
6131 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6132 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6133 print
'<input type="hidden" name="action" value="savefile">';
6134 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6135 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6136 print
'<input type="hidden" name="module" value="'.$module.
'">';
6138 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
6139 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6140 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6143 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6145 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6152 if ($tab ==
'cli') {
6153 print
'<!-- tab=cli -->'.
"\n";
6154 $clifiles = array();
6157 $dircli = array(
'/'.strtolower($module).
'/scripts');
6159 foreach ($dircli as $reldir) {
6164 if (!is_dir($newdir)) {
6168 $handle = opendir($newdir);
6170 if (is_resource($handle)) {
6171 while (($tmpfile = readdir($handle)) !==
false) {
6172 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6173 if (preg_match(
'/\.back$/', $tmpfile)) {
6177 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6186 if ($action !=
'editfile' || empty($file)) {
6187 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6191 if (!empty($clifiles)) {
6192 foreach ($clifiles as $clifile) {
6193 $pathtofile = $clifile[
'relpath'];
6195 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6196 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
6197 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
6201 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6202 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcli&token='.
newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
6209 $content = file_get_contents($fullpathoffile);
6212 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6214 print
'<input type="hidden" name="action" value="savefile">';
6215 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6216 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6217 print
'<input type="hidden" name="module" value="'.$module.
'">';
6219 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6220 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6223 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6225 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6232 if ($tab ==
'cron') {
6233 print
'<!-- tab=cron -->'.
"\n";
6234 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6236 $cronjobs = $moduleobj->cronjobs;
6238 if ($action !=
'editfile' || empty($file)) {
6239 print
'<span class="opacitymedium">'.str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/cron/list.php">'.$langs->transnoentities(
'CronList').
'</a>', $langs->trans(
"CronJobDefDesc",
'{s1}')).
'</span><br>';
6242 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6243 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=CRON">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6249 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6251 print
'<input type="hidden" name="action" value="addproperty">';
6252 print
'<input type="hidden" name="tab" value="objects">';
6253 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6254 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6256 print
'<div class="div-table-responsive">';
6257 print
'<table class="noborder">';
6259 print
'<tr class="liste_titre">';
6267 if (count($cronjobs)) {
6268 foreach ($cronjobs as $cron) {
6269 print
'<tr class="oddeven">';
6272 print $cron[
'label'];
6276 if ($cron[
'jobtype'] ==
'method') {
6277 $text = $langs->trans(
"CronClass");
6278 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
6279 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6280 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6281 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6282 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6283 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6284 } elseif ($cron[
'jobtype'] ==
'command') {
6285 $text = $langs->trans(
'CronCommand');
6286 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6287 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6288 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6290 print $form->textwithpicto($text, $texttoshow, 1);
6294 if ($cron[
'unitfrequency'] ==
"60") {
6295 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6297 if ($cron[
'unitfrequency'] ==
"3600") {
6298 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6300 if ($cron[
'unitfrequency'] ==
"86400") {
6301 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6303 if ($cron[
'unitfrequency'] ==
"604800") {
6304 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6309 print $cron[
'status'];
6313 if (!empty($cron[
'comment'])) {
6314 print $cron[
'comment'];
6321 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6331 $content = file_get_contents($fullpathoffile);
6334 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6335 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6336 print
'<input type="hidden" name="action" value="savefile">';
6337 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6338 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6339 print
'<input type="hidden" name="module" value="'.$module.
'">';
6341 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
6342 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6343 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6346 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6348 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6355 if ($tab ==
'specifications') {
6356 print
'<!-- tab=specifications -->'.
"\n";
6359 if ($action !=
'editfile' || empty($file)) {
6360 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6364 if (is_array($specs) && !empty($specs)) {
6365 foreach ($specs as $spec) {
6366 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6367 $format =
'asciidoc';
6368 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6369 $format =
'markdown';
6372 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6373 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
6374 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
6379 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6380 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initdoc&token='.
newToken().
'&format=php">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
6391 $content = file_get_contents($fullpathoffile);
6394 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6395 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6396 print
'<input type="hidden" name="action" value="savefile">';
6397 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6398 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6399 print
'<input type="hidden" name="module" value="'.$module.
'">';
6401 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6402 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6405 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6407 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6413 print
'<br><br><br>';
6415 $FILENAMEDOC = $modulelowercase.
'.html';
6416 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6417 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6418 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6419 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6420 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6421 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6422 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6425 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6427 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6430 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6431 print $outputfiledoc;
6434 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6435 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($outputfiledocrel).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
6437 print
'</strong><br>';
6440 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
6442 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6445 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
6446 print $outputfiledocpdf;
6449 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
6450 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($outputfiledocrelpdf).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
6452 print
'</strong><br>';
6456 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
6457 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6458 print
'<input type="hidden" name="action" value="generatedoc">';
6459 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6460 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6461 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
6462 if (!is_array($specs) || empty($specs)) {
6463 print
' disabled="disabled"';
6469 if ($tab ==
'buildpackage') {
6470 print
'<!-- tab=buildpackage -->'.
"\n";
6471 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
6474 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
6475 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
6479 $modulelowercase = strtolower($module);
6485 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6487 $class =
'mod'.$module;
6489 if (class_exists($class)) {
6491 $moduleobj =
new $class($db);
6498 $langs->load(
"errors");
6499 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
6503 $arrayversion = explode(
'.', $moduleobj->version, 3);
6504 if (count($arrayversion)) {
6505 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
6506 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
6511 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
6513 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6515 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
6516 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
6517 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
6518 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($relativepath).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
6526 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
6527 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6528 print
'<input type="hidden" name="action" value="generatepackage">';
6529 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6530 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6531 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
6535 if ($tab ==
'tabs') {
6536 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6538 $tabs = $moduleobj->tabs;
6540 if ($action !=
'editfile' || empty($file)) {
6541 print
'<span class="opacitymedium">';
6542 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
6543 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/menus/index.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Tabs').
'</a>', $htmlhelp);
6544 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6548 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
6549 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'&find=TABS">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
6555 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6556 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6557 print
'<input type="hidden" name="action" value="addproperty">';
6558 print
'<input type="hidden" name="tab" value="objects">';
6559 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6560 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6562 print
'<div class="div-table-responsive">';
6563 print
'<table class="noborder small">';
6565 print
'<tr class="liste_titre">';
6575 foreach ($tabs as $tab) {
6576 $parts = explode(
':', $tab[
'data']);
6578 $objectType = $parts[0];
6579 $tabName = $parts[1];
6580 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
6581 $langFile = isset($parts[3]) ? $parts[3] :
'';
6582 $condition = isset($parts[4]) ? $parts[4] :
'';
6583 $path = isset($parts[5]) ? $parts[5] :
'';
6587 if ($tabName[0] ===
'-') {
6589 $condition = isset($parts[2]) ? $parts[2] :
'';
6592 print
'<tr class="oddeven">';
6599 if ($tabName[0] ===
"+") {
6600 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6602 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6625 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6635 $content = file_get_contents($fullpathoffile);
6638 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6639 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6640 print
'<input type="hidden" name="action" value="savefile">';
6641 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6642 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6643 print
'<input type="hidden" name="module" value="'.$module.
'">';
6645 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
6646 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6647 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6650 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6652 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6659 if ($tab !=
'description') {