33if (!defined(
'NOSCANPOSTFORINJECTION')) {
34 define(
'NOSCANPOSTFORINJECTION',
'1');
38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions.lib.php';
53@phan-var-force string $dolibarr_main_document_root
54@phan-var-force string $dolibarr_main_document_root_alt
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/modulebuilder.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/modulebuilder/class/NamingContractValidator.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/modulebuilder/class/RightsSyncService.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
66$langs->loadLangs(array(
"admin",
"modulebuilder",
"exports",
"other",
"cron",
"errors",
"uxdocumentation"));
69$action =
GETPOST(
'action',
'aZ09');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$cancel =
GETPOST(
'cancel',
'alpha');
73$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74$sortorder =
GETPOST(
'sortorder',
'aZ09');
77$tab = (string)
GETPOST(
'tab',
'aZ09');
78$tabobj =
GETPOST(
'tabobj',
'alpha');
79$tabdic =
GETPOST(
'tabdic',
'alpha');
80$propertykey =
GETPOST(
'propertykey',
'alpha');
87'@phan-var-force string $tab';
89 $tabobj =
'newobjectifnoobj';
92 $tabdic =
'newdicifnodic';
94$file =
GETPOST(
'file',
'alpha');
95$find =
GETPOST(
'find',
'alpha');
100$editorname = (string)
GETPOST(
'editorname',
'alpha');
101$editorurl = (string)
GETPOST(
'editorurl',
'alpha');
102$version = (string)
GETPOST(
'version',
'alpha');
103$family = (string)
GETPOST(
'family',
'alpha');
104$picto = (string)
GETPOST(
'idpicto',
'alpha');
105$idmodule = (string)
GETPOST(
'idmodule',
'alpha');
112if (!$user->hasRight(
"modulebuilder",
"run")) {
117$tmp = explode(
',', $dolibarr_main_document_root_alt);
122$tmpdir = explode(
'@',
$module);
123if (!empty($tmpdir[1])) {
125 $dirread = $tmpdir[1];
128if (
GETPOST(
'dirins',
'alpha')) {
129 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
133$FILEFLAG =
'modulebuilder.txt';
140if (empty($newmask)) {
149$form =
new Form($db);
152$dirsrootforscan = array($dirread);
156 $dirsrootforscan[] = DOL_DOCUMENT_ROOT;
160$textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
161$listofmodules = array();
162'@phan-var-force array<string,array{modulenamewithcase:string,moduledescriptorrelpath:string,moduledescriptorfullpath:string,moduledescriptorrootpath,moduletype?:string}> $listofmodules';
164foreach ($dirsrootforscan as $tmpdirread) {
165 $moduletype =
'external';
166 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
167 $moduletype =
'internal';
170 $dirsincustom =
dol_dir_list($tmpdirread,
'directories');
171 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
172 foreach ($dirsincustom as $dircustomcursor) {
173 $fullname = $dircustomcursor[
'fullname'];
176 $dirtoscanrel = basename($fullname).
'/core/modules/';
178 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
179 if (empty($descriptorfiles)) {
180 $dirtoscanrel =
'core/modules/';
181 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.dol_strtoupper(basename($fullname)).
'\.class\.php$');
183 $modulenamewithcase =
'';
184 $moduledescriptorrelpath =
'';
185 $moduledescriptorfullpath =
'';
187 foreach ($descriptorfiles as $descriptorcursor) {
188 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
189 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
190 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
191 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
194 if ($modulenamewithcase) {
195 $listofmodules[$dircustomcursor[
'name']] = array(
196 'modulenamewithcase' => $modulenamewithcase,
197 'moduledescriptorrelpath' => $moduledescriptorrelpath,
198 'moduledescriptorfullpath' => $moduledescriptorfullpath,
199 'moduledescriptorrootpath' => $tmpdirread,
200 'moduletype' => $moduletype
208 if ($forceddirread && empty($listofmodules)) {
210 'modulenamewithcase' =>
$module,
211 'moduledescriptorrelpath' =>
'notyetimplemented',
212 'moduledescriptorfullpath' =>
'notyetimplemented',
213 'moduledescriptorrootpath' =>
'notyetimplemented',
218 $newdircustom = $dirins;
219 if (empty($newdircustom)) {
220 $newdircustom = img_warning();
225 $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
227 $textforlistofdirs .=
', ';
229 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$tmpdirread.
'</strong>';
230 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
232 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
235 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
248 $error = error_get_last();
249 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
251 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
253 if (headers_sent()) {
258register_shutdown_function(
"moduleBuilderShutdownFunction");
272 $licInfo = $user->getFullName($langs);
273 $emailTabs = str_repeat(
"\t", (
int) (max(0, (31 - mb_strlen($licInfo)) / 4)));
274 $licInfo .= ($user->email ? $emailTabs.
'<'.$user->email.
'>' :
'');
293 $content = file_get_contents($destfile);
294 if ($content ===
false) {
298 $errors = $validator->validateContent($content, $destfile);
299 if (!empty($errors)) {
301 'ModuleBuilder NamingContract validation warning in ' . $destfile .
': '
302 . implode(
'; ', array_slice($errors, 0, 3)),
305 $safeErrors = array_map(
'dol_escape_htmltag', array_slice($errors, 0, 5));
306 setEventMessages(implode(
'<br>', $safeErrors),
null,
'warnings');
321 $report = $service->sync($cmd);
323 if ($report->hasWarnings()) {
324 $safe = array_map(
'dol_escape_htmltag', array_slice($report->warnings, 0, 5));
325 setEventMessages($langs->trans(
'ModuleBuilderPermissionsNormalized').
'<br>'.implode(
'<br>', $safe),
null,
'warnings');
327 if ($report->hasConflicts()) {
328 $safe = array_map(
'dol_escape_htmltag', array_slice($report->conflicts, 0, 5));
329 setEventMessages($langs->trans(
'ModuleBuilderPermissionsNotChanged').
'<br>'.implode(
'<br>', $safe),
null,
'errors');
335if ($dirins && $action ==
'initmodule' && $modulename) {
337 $destdir =
'/not_set/';
340 if (preg_match(
'/[^a-z0-9]/i', $modulename)) {
342 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
346 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
349 $arrayreplacement = [
350 'mymodule' => $ncModule->moduleNameLower,
351 'MyModule' => $ncModule->moduleNameCase,
353 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayreplacement);
358 $langs->load(
"errors");
359 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
362 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
368 $tryToCopyFromSetupClass =
true;
369 $backportDest = $destdir .
'/backport/v16/core/class';
370 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
371 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
376 $langs->load(
"errors");
377 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
378 $tryToCopyFromSetupClass =
false;
381 if ($tryToCopyFromSetupClass) {
382 $result =
dol_copy($backportFileSrc, $backportFileDest);
386 $langs->load(
"errors");
387 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
389 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
432 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
453 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
456 foreach ($listofphpfilestoedit as $phpfileval) {
458 $arrayreplacement = array_merge(
459 $ncModule->getSubstitutionMap(),
461 'htdocs/modulebuilder/template' => $ncModule->moduleNameLower,
462 '---Put here your own copyright and developer email---' => $licInfo,
463 '---Replace with your own copyright and developer email---' => $licInfo,
464 'Editor name' => $editorname,
465 'https://www.example.com' => $editorurl,
466 '$this->version = \'1.0\'' =>
'$this->version = \'' . $version .
'\'',
467 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \'' . $picto .
'\';',
468 'modulefamily' => $family,
472 '$this->numero = 500000' =>
'$this->numero = '.$idmodule,
477 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
"\t\t" .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
484 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
489 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
491 file_put_contents($destdir.
'/README.md',
getDolGlobalString(
"MODULEBUILDER_SPECIFIC_README"));
502 setEventMessages($langs->trans(
'ModuleInitialized', $destdir),
null);
505 clearstatcache(
true);
506 if (function_exists(
'opcache_invalidate')) {
510 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
515$destdir =
'/not_set/';
516$destfile =
'/not_set/';
517$srcfile =
'/not_set/';
520if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty(
$module) ) {
522 $objectname = $tabobj;
523 $varnametoupdate =
'';
531 if ($action ==
'initapi') {
536 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
537 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
539 } elseif ($action ==
'initphpunit') {
541 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
542 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
544 } elseif ($action ==
'initpagecontact') {
546 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
547 $srcfile = $srcdir.
'/myobject_contact.php';
549 $varnametoupdate =
'showtabofpagecontact';
550 } elseif ($action ==
'initpagedocument') {
552 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
553 $srcfile = $srcdir.
'/myobject_document.php';
555 $varnametoupdate =
'showtabofpagedocument';
556 } elseif ($action ==
'initpagenote') {
558 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
559 $srcfile = $srcdir.
'/myobject_note.php';
561 $varnametoupdate =
'showtabofpagenote';
562 } elseif ($action ==
'initpageagenda') {
564 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
565 $srcfile = $srcdir.
'/myobject_agenda.php';
567 $varnametoupdate =
'showtabofpageagenda';
570 if (!file_exists($destfile)) {
571 $result =
dol_copy($srcfile, $destfile,
'0', 0);
578 }
catch (\InvalidArgumentException $e) {
580 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
584 if (!$error && $ncApiObj !==
null) {
585 $arrayreplacement = array_merge(
586 $ncApiObj->getSubstitutionMap(),
588 'htdocs/modulebuilder/template' => $ncApiObj->moduleNameLower,
589 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now),
593 if ($action ==
'initapi') {
594 if (count($objects) >= 1) {
600 $headerFix = $arrayreplacement;
601 unset($headerFix[
'MYOBJECT']);
612 if ($varnametoupdate) {
615 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
620 $langs->load(
"errors");
621 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
627if ($dirins && $action ==
'initsqlextrafields' && !empty(
$module) ) {
629 $objectname = $tabobj;
632 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
633 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
635 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
636 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
638 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
640 if ($result1 > 0 && $result2 > 0) {
646 }
catch (\InvalidArgumentException $e) {
648 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
652 if (!$error && $ncSqlObj !==
null) {
653 $arrayreplacement = array_merge(
654 $ncSqlObj->getSubstitutionMap(),
656 'htdocs/modulebuilder/template' => $ncSqlObj->moduleNameLower,
657 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now),
667 $langs->load(
"errors");
669 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
672 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
678 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
679 $arrayreplacement = array(
'/\$isextrafieldmanaged = 0;/' =>
'$isextrafieldmanaged = 1;');
685if ($dirins && $action ==
'inithook' && !empty(
$module) ) {
687 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
688 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
690 $result =
dol_copy($srcfile, $destfile,
'0', 0);
696 $arrayreplacement = array(
698 'MyModule' => $modulename,
700 'My module' => $modulename,
701 'my module' => $modulename,
702 'Mon module' => $modulename,
703 'mon module' => $modulename,
705 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
711 $langs->load(
"errors");
712 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
718if ($dirins && $action ==
'inittrigger' && !empty(
$module) ) {
720 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
721 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
723 $result =
dol_copy($srcfile, $destfile,
'0', 0);
729 $arrayreplacement = array(
731 'MyModule' => $modulename,
733 'My module' => $modulename,
734 'my module' => $modulename,
735 'Mon module' => $modulename,
736 'mon module' => $modulename,
738 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
744 $langs->load(
"errors");
745 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
751if ($dirins && $action ==
'initwidget' && !empty(
$module) ) {
753 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
754 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
756 $result =
dol_copy($srcfile, $destfile,
'0', 0);
762 $arrayreplacement = array(
764 'MyModule' => $modulename,
766 'My module' => $modulename,
767 'my module' => $modulename,
768 'Mon module' => $modulename,
769 'mon module' => $modulename,
771 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
777 $langs->load(
"errors");
778 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
784if ($dirins && $action ==
'initemailing' && !empty(
$module) ) {
786 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
787 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
789 $result =
dol_copy($srcfile, $destfile,
'0', 0);
795 $arrayreplacement = array(
797 'MyModule' => $modulename,
799 'My module' => $modulename,
800 'my module' => $modulename,
801 'Mon module' => $modulename,
802 'mon module' => $modulename,
804 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
810 $langs->load(
"errors");
811 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
817if ($dirins && $action ==
'initcss' && !empty(
$module) ) {
819 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
820 $srcfile = $srcdir.
'/css/mymodule.css.php';
822 $result =
dol_copy($srcfile, $destfile,
'0', 0);
828 $arrayreplacement = array(
830 'MyModule' => $modulename,
832 'My module' => $modulename,
833 'my module' => $modulename,
834 'Mon module' => $modulename,
835 'mon module' => $modulename,
837 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
848 $langs->load(
"errors");
849 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
855if ($dirins && $action ==
'initjs' && !empty(
$module) ) {
857 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
858 $srcfile = $srcdir.
'/js/mymodule.js.php';
860 $result =
dol_copy($srcfile, $destfile,
'0', 0);
866 $arrayreplacement = array(
868 'MyModule' => $modulename,
870 'My module' => $modulename,
871 'my module' => $modulename,
872 'Mon module' => $modulename,
873 'mon module' => $modulename,
875 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
886 $langs->load(
"errors");
887 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
893if ($dirins && $action ==
'initcli' && !empty(
$module) ) {
895 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
896 $srcfile = $srcdir.
'/scripts/mymodule.php';
898 $result =
dol_copy($srcfile, $destfile,
'0', 0);
904 $arrayreplacement = array(
906 'MyModule' => $modulename,
908 'My module' => $modulename,
909 'my module' => $modulename,
910 'Mon module' => $modulename,
911 'mon module' => $modulename,
913 '__MYCOMPANY_NAME__' =>
$mysoc->name,
914 '__KEYWORDS__' => $modulename,
915 '__USER_FULLNAME__' => $user->getFullName($langs),
916 '__USER_EMAIL__' => $user->email,
918 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
924 $langs->load(
"errors");
925 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
930$moduledescriptorfile =
'/not_set/';
931$modulelowercase =
null;
934if ($dirins && $action ==
'initdoc' && !empty(
$module) ) {
936 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
937 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
939 $result =
dol_copy($srcfile, $destfile,
'0', 0);
946 $arrayreplacement = array(
948 'MyModule' => $modulename,
950 'My module' => $modulename,
951 'my module' => $modulename,
952 'Mon module' => $modulename,
953 'mon module' => $modulename,
955 '__MYCOMPANY_NAME__' =>
$mysoc->name,
956 '__KEYWORDS__' => $modulename,
957 '__USER_FULLNAME__' => $user->getFullName($langs),
958 '__USER_EMAIL__' => $user->email,
960 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
970 foreach ($objects as $path => $obj) {
987 $string = file_get_contents($changeLog);
989 $replace = explode(
"\n", $string);
990 $strreplace = array();
991 foreach ($replace as $line) {
995 if (strpos($line,
'##') !==
false) {
996 $strreplace[$line] = str_replace(
'##',
'', $line);
998 $strreplace[$line] = $line;
1001 $stringLog = implode(
"\n", $strreplace);
1003 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
1007 $FILENAMEDOC = $modulelowercase.
'.html';
1008 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
1009 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
1010 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
1011 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
1012 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
1017 $langs->load(
"errors");
1018 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
1024if ($dirins && $action ==
'addlanguage' && !empty(
$module) ) {
1025 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
1033 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
1035 $diroflang = $dolibarr_main_document_root;
1037 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
1038 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
1040 $result =
dol_copy($srcfile, $destfile,
'0', 0);
1042 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
1045 $srcdir = $diroflang.
'/langs/en_US';
1046 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
1047 $destdir = $diroflang.
'/langs/'.$newlangcode;
1049 $arrayofreplacement = array();
1051 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
1052 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
1054 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
1057 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
1063if ($dirins && $action ==
'confirm_removefile' && !empty(
$module) ) {
1064 $objectname = $tabobj;
1071 if ($relativefilename) {
1072 $dirnametodelete = dirname($relativefilename);
1073 $filetodelete = $dirins.
'/'.$relativefilename;
1074 $dirtodelete = $dirins.
'/'.$dirnametodelete;
1079 $keyofobjecttodelete = array_search($objectname, $objects);
1080 if ($keyofobjecttodelete !==
false) {
1081 unset($objects[$keyofobjecttodelete]);
1085 if (strpos($relativefilename,
'api') !==
false) {
1090 if (count($objects) == 0) {
1095 setEventMessages($langs->trans(
"ApiObjectDeleted"),
null);
1102 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1105 if (preg_match(
'/\.sql$/', $relativefilename)) {
1106 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1107 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1108 $filetodelete = $dirins.
'/'.$relativefilename;
1110 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1111 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1112 $filetodelete = $dirins.
'/'.$relativefilename;
1122 if (in_array($tab, array(
'css',
'js'))) {
1124 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1128 if (preg_match(
'/_extrafields/', $relativefilename)) {
1131 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1136 $varnametoupdate =
'';
1138 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1139 $varnametoupdate =
'showtabofpage'.$reg[1];
1141 if ($varnametoupdate) {
1143 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1151if ($dirins && $action ==
'initobject' &&
$module && $objectname) {
1159 if (preg_match(
'/[^a-z0-9]/i', $objectname)) {
1161 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1162 $tabobj =
'newobject';
1164 if (class_exists($objectname)) {
1167 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1168 $tabobj =
'newobject';
1173 }
catch (\InvalidArgumentException $e) {
1175 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1179 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1198 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1199 $alreadyfound =
false;
1200 foreach ($dirlist as $key => $val) {
1201 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1203 $alreadyfound =
true;
1205 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1213 $stringforproperties =
'';
1214 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1216 $_results = $db->DDLDescTable($tablename);
1217 if (empty($_results)) {
1219 $langs->load(
"errors");
1220 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1269 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1270 $stringforproperties .=
'public $fields = array('.
"\n";
1272 while ($obj = $db->fetch_object($_results)) {
1274 $fieldname = $obj->Field;
1277 if ($type ==
'int(11)') {
1279 } elseif ($type ==
'float') {
1281 } elseif (strstr($type,
'tinyint')) {
1283 } elseif (strstr($type,
'url')) {
1284 $type =
'varchar(255)';
1285 } elseif ($obj->Field ==
'fk_soc') {
1286 $type =
'integer:Societe:societe/class/societe.class.php';
1287 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1288 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1289 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1290 $type =
'integer:Product:product/class/product.class.php:1';
1291 } elseif ($obj->Field ==
'fk_warehouse') {
1292 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1293 } elseif (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1294 $type =
'integer:User:user/class/user.class.php';
1298 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1299 if ($fieldname ==
'fk_user_modif') {
1303 $label = preg_replace(
'/_/',
'',
dol_ucfirst($fieldname));
1304 if ($fieldname ==
'rowid') {
1305 $label =
'TechnicalID';
1307 if ($fieldname ==
'import_key') {
1308 $label =
'ImportId';
1310 if ($fieldname ==
'fk_soc') {
1311 $label =
'ThirdParty';
1313 if (in_array($fieldname, array(
'tms',
'date_modification'))) {
1314 $label =
'DateModification';
1316 if (in_array($fieldname, array(
'datec',
'date_creation'))) {
1317 $label =
'DateCreation';
1319 if ($fieldname ==
'date_valid') {
1320 $label =
'DateValidation';
1322 if ($fieldname ==
'datev') {
1323 $label =
'DateValidation';
1325 if ($fieldname ==
'note_private') {
1326 $label =
'NotePublic';
1328 if ($fieldname ==
'note_public') {
1329 $label =
'NotePrivate';
1331 if ($fieldname ==
'fk_user_creat') {
1332 $label =
'UserAuthor';
1334 if ($fieldname ==
'fk_user_modif') {
1335 $label =
'UserModif';
1337 if ($fieldname ==
'fk_user_valid') {
1338 $label =
'UserValidation';
1342 if (in_array($fieldname, array(
'ref',
'label'))) {
1345 if ($fieldname ==
'entity') {
1348 if ($fieldname ==
'entity') {
1351 if ($fieldname ==
'import_key') {
1354 if ($fieldname ==
'fk_user_creat') {
1357 if ($fieldname ==
'fk_user_modif') {
1360 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1367 if ($fieldname ==
'entity') {
1372 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1375 if ($fieldname ==
'import_key') {
1379 $alwayseditable = 0;
1380 if ($fieldname ==
'label') {
1381 $alwayseditable = 1;
1383 $alwayseditable = 0;
1387 if ($fieldname ==
'entity') {
1394 if (preg_match(
'/^fk_/', $fieldname)) {
1395 $css =
'maxwidth500 widthcentpercentminusxx';
1397 if ($fieldname ==
'label') {
1398 $css =
'minwidth300';
1399 $cssview =
'wordbreak';
1401 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1402 $cssview =
'wordbreak';
1404 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1405 $csslist =
'tdoverflowmax150';
1410 if (isset($obj->Picto)) {
1411 $picto = $obj->Picto;
1413 if (preg_match(
'/^fk_soc/', $obj->Field)) {
1415 } elseif (preg_match(
'/^fk_contact/', $obj->Field)) {
1417 } elseif (preg_match(
'/^fk_bank/', $obj->Field)) {
1419 } elseif (preg_match(
'/^fk_user/', $obj->Field)) {
1421 } elseif (preg_match(
'/^fk_warehouse/', $obj->Field)) {
1422 $picto =
'warehouse';
1423 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1425 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1427 } elseif (preg_match(
'/^fk_task/', $obj->Field)) {
1435 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1436 if ($default !=
'') {
1437 $stringforproperties .=
" 'default' => ".$default.
",";
1439 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1440 $stringforproperties .=
" 'visible' => ".$visible;
1442 $stringforproperties .=
", 'notnull' => ".$notnull;
1444 if ($alwayseditable) {
1445 $stringforproperties .=
", 'alwayseditable' => 1";
1447 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1448 $stringforproperties .=
", 'showoncombobox' => 1";
1450 $stringforproperties .=
", 'position' => ".$position;
1452 $stringforproperties .=
", 'index' => ".$index;
1455 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1458 $stringforproperties .=
", 'css' => '".$css.
"'";
1461 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1464 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1467 $stringforproperties .=
", 'lang' => '".$lang.
"'";
1469 $stringforproperties .=
"),\n";
1472 $stringforproperties .=
');'.
"\n";
1473 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1477 $filetogenerate = array();
1480 $filetogenerate = [];
1482 'myobject_card.php',
1483 'myobject_note.php',
1484 'myobject_contact.php',
1485 'myobject_document.php',
1486 'myobject_agenda.php',
1487 'myobject_list.php',
1488 'admin/myobject_extrafields.php',
1489 'ajax/myobject.php',
1490 'lib/mymodule_myobject.lib.php',
1492 'sql/llx_mymodule_myobject.sql',
1493 'sql/llx_mymodule_myobject.key.sql',
1494 'sql/llx_mymodule_myobject_extrafields.sql',
1495 'sql/llx_mymodule_myobject_extrafields.key.sql',
1497 'class/myobject.class.php',
1498 'class/myobjectstats.class.php',
1500 'stats/myobject_index.php',
1501 ] as $templateFile) {
1502 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1507 if (!in_array($tabkey, $enabledtabs,
true)) {
1508 unset($filetogenerate[$tabinfo[
'file']]);
1512 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1516 'core/modules/mymodule/mod_myobject_advanced.php',
1517 'core/modules/mymodule/mod_myobject_standard.php',
1518 'core/modules/mymodule/modules_myobject.php',
1519 ] as $templateFile) {
1520 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1523 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1528 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php',
1529 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php',
1530 ] as $templateFile) {
1531 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1535 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1536 $firstobjectname =
'myobject';
1539 $class =
'mod'.$module;
1541 if (class_exists($class)) {
1544 '@phan-var-force DolibarrModules $moduleobj';
1548 dol_print_error($db, $e->getMessage());
1556 $moduledescriptorfile = $destdir.
'/core/modules/mod'.
$module.
'.class.php';
1558 if ($checkComment < 0) {
1559 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1562 if ($reportPerms->skipped > 0) {
1563 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1569 foreach ($filetogenerate as $srcfile => $destfile) {
1570 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1574 $langs->load(
"errors");
1575 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1578 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1581 $arrayreplacement = array(
1582 '/myobject\.class\.php/' =>
dol_strtolower($objectname).
'.class.php',
1583 '/myobject\.lib\.php/' =>
dol_strtolower($objectname).
'.lib.php',
1586 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1591 if (!$error && $stringforproperties) {
1593 $arrayreplacement = array(
1594 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1601 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1603 $arrayreplacement = array(
1604 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1610 $arrayreplacement = array(
1611 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1617 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1619 $arrayreplacement = array(
1620 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1625 $arrayreplacement = array(
1626 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1636 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1638 $firstobjectname =
'';
1640 foreach ($listofobject as $fileobj) {
1641 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1644 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1648 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1650 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1651 $objectnameloop = $reg[1];
1652 if (empty($firstobjectname)) {
1653 $firstobjectname = $objectnameloop;
1659 \$this->menu[\$r++] = array(
1660 'fk_menu' => 'fk_mainmenu=mymodule',
1662 'titre' => 'MyObject',
1663 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1664 'mainmenu' => 'mymodule',
1665 'leftmenu' => 'myobject',
1666 'url' => '/mymodule/myobject_list.php',
1667 'langs' => 'mymodule@mymodule',
1668 'position' => 1000 + \$r,
1669 'enabled' => 'isModEnabled(\"mymodule\")',
1670 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1673 'object' => 'MyObject'
1675 \$this->menu[\$r++] = array(
1676 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1678 'titre' => 'List MyObject',
1679 'mainmenu' => 'mymodule',
1680 'leftmenu' => 'mymodule_myobject_list',
1681 'url' => '/mymodule/myobject_list.php',
1682 'langs' => 'mymodule@mymodule',
1683 'position' => 1000 + \$r,
1684 'enabled' => 'isModEnabled(\"mymodule\")',
1685 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1688 'object' => 'MyObject'
1690 \$this->menu[\$r++] = array(
1691 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1693 'titre' => 'New MyObject',
1694 'mainmenu' => 'mymodule',
1695 'leftmenu' => 'mymodule_myobject_new',
1696 'url' => '/mymodule/myobject_card.php?action=create',
1697 'langs' => 'mymodule@mymodule',
1698 'position' => 1000 + \$r,
1699 'enabled' => 'isModEnabled(\"mymodule\")',
1700 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1703 'object' => 'MyObject'
1705 $stringtoadd = $ncObj->applyTo($stringtoadd);
1707 $moduledescriptorfile = $destdir.
'/core/modules/mod'.
$module.
'.class.php';
1715 $class =
'mod'.$module;
1717 if (class_exists($class)) {
1720 '@phan-var-force DolibarrModules $moduleobj';
1724 dol_print_error($db, $e->getMessage());
1733 foreach ($menus as $menu) {
1740 if ($checkComment < 0) {
1742 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1744 $arrayofreplacement = array(
1745 '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */' =>
'/* BEGIN MODULEBUILDER LEFTMENU '.
dol_strtoupper($objectname).
' */'.$stringtoadd.
"\n\t\t".
'/* END MODULEBUILDER LEFTMENU '.dol_strtoupper($objectname).
' */'.
"\n\t\t".
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */'
1751 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1754 if (! $error &&
GETPOST(
'nogeneratelines',
'aZ09')) {
1756 if ($checkComment < 0) {
1758 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1762 $destdir .
'/class/' .
dol_strtolower($objectname) .
'.class.php',
1769 foreach ($TFilePaths as $filePath) {
1782 $libdestfile = $destdir.
'/'.$ncObj->applyToFilename(
'lib/mymodule_myobject.lib.php');
1784 $marker = $tabinfo[
'marker'];
1785 if (in_array($tabkey, $enabledtabs,
true)) {
1786 $arrayreplacement = array(
1787 '/\$'.$tabinfo[
'var'].
' = getDolGlobalInt\([^;]*\);/' =>
'$'.$tabinfo[
'var'].
' = 1;'
1789 if (
dolReplaceInFile($libdestfile, $arrayreplacement,
'',
'0', 0, 1) < 0) {
1791 dol_syslog(
"modulebuilder: failed to activate tab flag '".$tabkey.
"' in ".$libdestfile, LOG_ERR);
1794 if (!
removePatternFromFile($libdestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TABFLAG '.$marker.
'.*?\/\/ END MODULEBUILDER TABFLAG '.$marker.
'\s*/s')
1795 || !
removePatternFromFile($libdestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TAB '.$marker.
'.*?\/\/ END MODULEBUILDER TAB '.$marker.
'\s*/s')) {
1797 dol_syslog(
"modulebuilder: failed to purge tab '".$tabkey.
"' in ".$libdestfile, LOG_ERR);
1801 $carddestfile = $destdir.
'/'.$ncObj->applyToFilename(
'myobject_card.php');
1804 if (!$error && !in_array(
'agenda', $enabledtabs,
true)) {
1805 if (!
removePatternFromFile($carddestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TAB AGENDA.*?\/\/ END MODULEBUILDER TAB AGENDA\s*/s')) {
1807 dol_syslog(
"modulebuilder: failed to purge agenda widget in ".$carddestfile, LOG_ERR);
1815 if (!in_array($actionkey, $enabledcardactions,
true)) {
1818 dol_syslog(
"modulebuilder: failed to purge card action '".$actionkey.
"' in ".$carddestfile, LOG_ERR);
1820 } elseif ($actioninfo[
'mode'] ==
'activate') {
1824 dol_syslog(
"modulebuilder: failed to activate card action '".$actionkey.
"' in ".$carddestfile, LOG_ERR);
1831 if ($objectalreadyexists) {
1832 setEventMessages($langs->trans(
"WarningTabSelectionOnRegeneration"),
null,
'warnings');
1833 setEventMessages($langs->trans(
"WarningCardActionSelectionOnRegeneration"),
null,
'warnings');
1839 foreach ($filetogenerate as $destfile) {
1840 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1847 $arrayreplacement = array_merge(
1848 $ncObj->getSubstitutionMap(),
1850 'htdocs/modulebuilder/template/' => $ncObj->moduleNameLower,
1851 '---Replace with your own copyright and developer email---' => $licenceValue,
1855 if (basename($phpfileval[
'fullname']) ===
'mod'.
$module.
'.class.php') {
1863 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1870 if (!$error && $ncObj !==
null) {
1878 $moduleReplacementAll = array_merge(
1879 $ncObj->getSubstitutionMap(),
1881 'htdocs/modulebuilder/template/' => $ncObj->moduleNameLower,
1882 '---Replace with your own copyright and developer email---' => $licenceValueAll,
1885 $allModulePhpFiles =
dol_dir_list($destdir,
'files', 1,
'\.php$');
1889 $moduledescriptorbasename =
'mod'.$module.
'.class.php';
1890 if (is_array($allModulePhpFiles) && !empty($allModulePhpFiles)) {
1891 foreach ($allModulePhpFiles as $phpFileval) {
1892 if (basename($phpFileval[
'fullname']) === $moduledescriptorbasename) {
1895 $result =
dolReplaceInFile($phpFileval[
'fullname'], $moduleReplacementAll);
1897 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpFileval[
'fullname']),
null,
'warnings');
1904 $destdir .
'/stats/myobject_index.php',
1905 $destdir .
'/lib/' . $moduleLowerForPlaceholder .
'_myobject.lib.php',
1906 ] as $placeholder) {
1907 if (file_exists($placeholder)) {
1918 if (is_numeric($object) && $object <= 0) {
1919 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
1920 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1924 $file = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
1925 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1927 if (file_exists($destfile)) {
1931 if (!$error && $object !==
null) {
1936 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null);
1942 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1943 $tabobj = $objectname;
1945 $tabobj =
'newobject';
1953 setEventMessages($result,
null,
'errors');
1955 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
1956 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module);
1962if ($dirins && $action ==
'initdic' &&
$module && empty($cancel) ) {
1969 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1973 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1976 $newdicname = $dicname;
1977 if (!preg_match(
'/^c_/', $newdicname)) {
1978 $newdicname =
'c_'.$dicname;
1981 $class =
'mod'.$module;
1984 if (class_exists($class)) {
1987 '@phan-var-force DolibarrModules $moduleobj';
1991 dol_print_error($db, $e->getMessage());
1997 $langs->load(
"errors");
1998 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2003 if ($checkComment < 0) {
2004 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2007 if (function_exists(
'opcache_invalidate')) {
2010 clearstatcache(
true);
2011 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2018if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty(
$module) && !empty($tabobj) ) {
2019 $objectname = $tabobj;
2021 $arrayoftables = array();
2022 if ($action ==
'droptable') {
2025 if ($action ==
'droptableextrafields') {
2026 $arrayoftables[] = MAIN_DB_PREFIX.dol_strtolower(
$module).
'_'.
dol_strtolower($tabobj).
'_extrafields';
2029 foreach ($arrayoftables as $tabletodrop) {
2031 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
2032 $resql = $db->query($sql);
2034 $obj = $db->fetch_object($resql);
2036 $nb = (int) $obj->nb;
2039 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
2040 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
2042 dol_print_error($db);
2046 $resql = $db->DDLDropTable($tabletodrop);
2048 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
2049 } elseif ($nb > 0) {
2050 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
2055if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty(
$module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) ) {
2068 if (!in_array($objectname, array_values($objects))) {
2070 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
2073 $addfieldentry = array();
2076 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
2077 if (!
GETPOST(
'propname',
'aZ09')) {
2079 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
2081 if (!
GETPOST(
'proplabel',
'alpha')) {
2083 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2085 if (!
GETPOST(
'proptype',
'alpha')) {
2087 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2091 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
2095 $proptype =
GETPOST(
'proptype',
'alpha');
2096 if (strpos($proptype,
':') ===
false && strpos($proptype,
'_') ===
false) {
2099 $addfieldentry = array(
2100 'name' =>
GETPOST(
'propname',
'aZ09'),
2101 'label' =>
GETPOST(
'proplabel',
'alpha'),
2102 'type' => $proptype,
2103 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'nohtml'),
2104 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
2105 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
2109 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
2111 'isameasure' =>
GETPOSTINT(
'propisameasure'),
2112 'showoncombobox' =>
GETPOSTINT(
'propshowoncombobox'),
2113 'comment' =>
GETPOST(
'propcomment',
'alpha'),
2114 'help' =>
GETPOST(
'prophelp',
'alpha'),
2115 'css' =>
GETPOST(
'propcss',
'alpha'),
2116 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
2117 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
2118 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
2119 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
2124 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
2125 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
2127 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
2130 $addfieldentry[
'arrayofkeyval'] = $tmparray;
2149 if (is_numeric($object) && $object <= 0) {
2150 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2151 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
2157 if (!$error && $object !==
null) {
2161 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
2167 clearstatcache(
true);
2169 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
2171 setEventMessages($langs->trans(
'WarningDatabaseIsNotUpdated'),
null);
2174 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.
dol_now());
2179if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey ) {
2180 $objectname = $tabobj;
2194 if (is_numeric($object) && $object <= 0) {
2195 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2196 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
2202 if (!$error && $object !==
null) {
2206 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
2212 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
2214 clearstatcache(
true);
2217 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
2222if ($dirins && $action ==
'confirm_deletemodule' ) {
2223 if (preg_match(
'/[^a-z0-9_]/i',
$module)) {
2225 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2232 $dir = $dirins.
'/'.$modulelowercase;
2244 $class =
'mod'.$module;
2248 if (class_exists($class)) {
2251 '@phan-var-force DolibarrModules $moduleobj';
2255 dol_print_error($db, $e->getMessage());
2259 $langs->load(
"errors");
2260 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module),
null,
'warnings');
2270 setEventMessages($langs->trans(
"DirWasRemoved", $modulelowercase),
null);
2272 clearstatcache(
true);
2273 if (function_exists(
'opcache_invalidate')) {
2277 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2280 setEventMessages($langs->trans(
"PurgeNothingToDelete"),
null,
'warnings');
2288if ($dirins && $action ==
'confirm_deleteobject' && $objectname ) {
2289 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2291 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2299 $dir = $dirins.
'/'.$modulelowercase;
2304 }
catch (\InvalidArgumentException $e) {
2306 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2310 if (!$error && $ncObjDel !==
null) {
2312 'myobject_card.php',
2313 'myobject_note.php',
2314 'myobject_contact.php',
2315 'myobject_document.php',
2316 'myobject_agenda.php',
2317 'myobject_list.php',
2318 'admin/myobject_extrafields.php',
2319 'lib/mymodule_myobject.lib.php',
2320 'sql/llx_mymodule_myobject.sql',
2321 'sql/llx_mymodule_myobject_extrafields.sql',
2322 'sql/llx_mymodule_myobject.key.sql',
2323 'sql/llx_mymodule_myobject_extrafields.key.sql',
2324 'scripts/myobject.php',
2325 'class/myobject.class.php',
2326 'class/myobjectstats.class.php',
2327 'core/modules/mymodule/mod_myobject_advanced.php',
2328 'core/modules/mymodule/mod_myobject_standard.php',
2329 'core/modules/mymodule/modules_myobject.php',
2330 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php',
2331 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php',
2332 'stats/myobject_index.php',
2333 ] as $templateFile) {
2334 $filetodelete[$templateFile] = $ncObjDel->applyToFilename($templateFile);
2337 $filetodelete[
'ajax/myobject.lib.php'] =
'ajax/' . $ncObjDel->objectNameLower .
'.php';
2338 $filetodelete[
'test/phpunit/MyObjectTest.php'] =
'test/phpunit/' . $ncObjDel->objectNameLower .
'Test.php';
2339 $filetodelete[
'class/api_myobject.class.php'] =
'class/api_' . $ncObjDel->moduleNameLower .
'.class.php';
2346 $class =
'mod'.$module;
2348 if (class_exists($class)) {
2351 '@phan-var-force DolibarrModules $moduleobj';
2355 dol_print_error($db, $e->getMessage());
2359 $langs->load(
"errors");
2360 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2369 if ($rewriteMenu < 0) {
2370 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2372 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2378 if ($rewritePerms < 0) {
2379 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2385 if ($rewritePerms && $rewriteMenu) {
2390 clearstatcache(
true);
2391 if (function_exists(
'opcache_invalidate')) {
2395 foreach ($filetodelete as $tmpfiletodelete) {
2397 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 1, 0, 1);
2403 if ($resultko == 0) {
2404 setEventMessages($langs->trans(
"FilesDeleted"),
null);
2406 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2413 $tabobj =
'newobject';
2415 $tabobj =
'deleteobject';
2423 setEventMessages($result,
null,
'errors');
2425 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2426 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode(
$module));
2431if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) ) {
2436 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2438 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2441 if (!empty($dicname)) {
2442 $newdicname = $dicname;
2443 if (!preg_match(
'/^c_/', $newdicname)) {
2444 $newdicname =
'c_'.dol_strtolower($dicname);
2451 $class =
'mod'.$module;
2454 if (class_exists($class)) {
2457 '@phan-var-force DolibarrModules $moduleobj';
2461 dol_print_error($db, $e->getMessage());
2467 $langs->load(
"errors");
2468 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2474 if ($checkComment < 0) {
2476 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2479 if (!empty(
GETPOST(
'dictionnarykey'))) {
2480 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2484 $checkTable =
false;
2485 if ($newdicname !==
null) {
2486 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.dol_strtolower($newdicname));
2489 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2494 $keyToDelete =
null;
2495 foreach ($dicts[
'tabname'] as $key => $table) {
2498 $keyToDelete = $key;
2503 if ($keyToDelete !==
null) {
2504 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2505 foreach ($keysToDelete as $key) {
2506 unset($dicts[$key][$keyToDelete]);
2510 setEventMessages($langs->trans(
"ErrorDictionaryNotFound",
dol_ucfirst($dicname)),
null,
'errors');
2512 if (!$error && $newdicname !==
null) {
2514 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.dol_strtolower($newdicname));
2515 if ($_results < 0) {
2516 dol_print_error($db);
2517 $langs->load(
"errors");
2518 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2523 setEventMessages($langs->trans(
"DictionaryDeleted",
dol_ucfirst(
dol_substr($newdicname, 2))),
null);
2525 if (function_exists(
'opcache_invalidate')) {
2528 clearstatcache(
true);
2529 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2533if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') ) {
2534 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2540 $class =
'mod'.$module;
2543 if (class_exists($class)) {
2546 '@phan-var-force DolibarrModules $moduleobj';
2550 dol_print_error($db, $e->getMessage());
2556 $langs->load(
"errors");
2557 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2562 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2565 if ($checkComment < 0) {
2566 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2569 if ($updateDict > 0) {
2570 setEventMessages($langs->trans(
"DictionaryNameUpdated",
dol_ucfirst(
GETPOST(
'tablib'))),
null);
2572 if (function_exists(
'opcache_invalidate')) {
2575 clearstatcache(
true);
2576 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2582if ($dirins && $action ==
'generatedoc' ) {
2590 $util =
new Utils($db);
2591 $result = $util->generateDoc(
$module);
2594 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2596 setEventMessages($util->error, $util->errors,
'errors');
2600if ($dirins && $action ==
'generatepackage' ) {
2613 $class =
'mod'.$module;
2616 if (class_exists($class)) {
2619 '@phan-var-force DolibarrModules $moduleobj';
2623 dol_print_error($db, $e->getMessage());
2629 $langs->load(
"errors");
2630 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2634 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2635 if (count($arrayversion)) {
2636 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2639 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2645 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2648 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2651 $langs->load(
"errors");
2652 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2656 $langs->load(
"errors");
2657 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2662if ($dirins && $action ==
'addright' && !empty(
$module) && empty($cancel) ) {
2668 $class =
'mod'.$module;
2670 if (class_exists($class)) {
2673 '@phan-var-force DolibarrModules $moduleobj';
2677 dol_print_error($db, $e->getMessage());
2682 if (!
GETPOST(
'label',
'alpha')) {
2684 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2686 if (!
GETPOST(
'permissionObj',
'alpha')) {
2688 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2691 $label =
GETPOST(
'label',
'alpha');
2693 $crud =
GETPOST(
'crud',
'alpha');
2697 $permsForObject = array();
2701 $permissions = array();
2703 $allObject = array();
2705 $countPerms = count($permissions);
2707 for ($i = 0; $i < $countPerms; $i++) {
2708 if ($permissions[$i][4] == $objectForPerms) {
2710 if (count($permsForObject) < 3) {
2711 $permsForObject[] = $permissions[$i];
2714 $allObject[] = $permissions[$i][4];
2718 $countPermsObj = count($permsForObject);
2719 for ($j = 0; $j < $countPermsObj; $j++) {
2720 if (in_array($crud, $permsForObject[$j])) {
2722 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2731 setEventMessages($result,
null,
'errors');
2733 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2740 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2743 if (!$reportPerms->hasConflicts()) {
2744 setEventMessages($langs->trans(
'PermissionAddedSuccesfuly'),
null);
2746 clearstatcache(
true);
2747 if (function_exists(
'opcache_invalidate')) {
2750 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
2759if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) ) {
2764 $class =
'mod'.$module;
2766 if (class_exists($class)) {
2769 '@phan-var-force DolibarrModules $moduleobj';
2773 dol_print_error($db, $e->getMessage());
2777 if (!
GETPOST(
'label',
'alpha')) {
2779 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2781 if (!
GETPOST(
'permissionObj',
'alpha')) {
2783 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2786 $label =
GETPOST(
'label',
'alpha');
2788 $crud =
GETPOST(
'crud',
'alpha');
2791 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2795 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2799 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2811 if (array_key_exists($key, $permissions)) {
2812 $x1 = $permissions[$key][1];
2813 $x2 = $permissions[$key][4];
2814 $x3 = $permissions[$key][5];
2822 $permsForObject = array();
2826 $allObject = array();
2828 $countPerms = count($permissions);
2829 for ($i = 0; $i < $countPerms; $i++) {
2830 if ($permissions[$i][4] == $objectForPerms) {
2832 if (count($permsForObject) < 3) {
2833 $permsForObject[] = $permissions[$i];
2836 $allObject[] = $permissions[$i][4];
2839 if ($label != $x1 && $crud != $x3) {
2840 $countPermsObj = count($permsForObject);
2841 for ($j = 0; $j < $countPermsObj; $j++) {
2842 if (in_array($label, $permsForObject[$j])) {
2844 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2854 setEventMessages($result,
null,
'errors');
2856 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2863 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2866 if (!$reportPerms->hasConflicts()) {
2867 setEventMessages($langs->trans(
'PermissionUpdatedSuccesfuly'),
null);
2868 clearstatcache(
true);
2869 if (function_exists(
'opcache_invalidate')) {
2872 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
2879if ($dirins && $action ==
'confirm_deleteright' && !empty(
$module) &&
GETPOSTINT(
'permskey') ) {
2884 $class =
'mod'.$module;
2886 if (class_exists($class)) {
2889 '@phan-var-force DolibarrModules $moduleobj';
2893 dol_print_error($db, $e->getMessage());
2906 setEventMessages($result,
null,
'errors');
2908 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2909 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
2917 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2920 if (!$reportPerms->hasConflicts()) {
2921 setEventMessages($langs->trans(
'PermissionDeletedSuccesfuly'),
null);
2923 clearstatcache(
true);
2924 if (function_exists(
'opcache_invalidate')) {
2928 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
2935if ($action ==
'savefile' && empty($cancel) ) {
2936 $relofcustom = basename($dirins);
2940 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2941 $file = $relofcustom.
'/'.$file;
2949 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2952 $check =
'restricthtml';
2954 if ($srclang ==
'md') {
2955 $check =
'restricthtml';
2957 if ($srclang ==
'lang') {
2958 $check =
'restricthtml';
2960 if ($srclang ==
'php') {
2964 $content =
GETPOST(
'editfilecontent', $check);
2969 $result = file_put_contents($pathoffile, $content);
2973 setEventMessages($langs->trans(
"FileSaved"),
null);
2975 setEventMessages($langs->trans(
"ErrorFailedToSaveFile"),
null,
'errors');
2978 setEventMessages($langs->trans(
"ContentCantBeEmpty"),
null,
'errors');
2986if ($action ==
'set' && $user->admin ) {
2989 $param .=
'&module='.urlencode(
$module);
2992 $param .=
'&tab='.urlencode($tab);
2993 $param .=
'&tabobj='.urlencode($tabobj);
2995 $value =
GETPOST(
'value',
'alpha');
2996 $resarray = activateModule($value, 1, 0);
2997 if (!empty($resarray[
'errors'])) {
2998 setEventMessages(
'', $resarray[
'errors'],
'errors');
3001 if ($resarray[
'nbperms'] > 0) {
3002 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
3003 $resqltmp = $db->query($tmpsql);
3005 $obj = $db->fetch_object($resqltmp);
3007 if ($obj && $obj->nb > 1) {
3008 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
3009 setEventMessages($msg,
null,
'warnings');
3012 dol_print_error($db);
3016 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
3021if ($action ==
'reset' && $user->admin ) {
3024 $param .=
'&module='.urlencode(
$module);
3026 $param .=
'&tab='.urlencode($tab);
3027 $param .=
'&tabobj='.urlencode($tabobj);
3029 $value =
GETPOST(
'value',
'alpha');
3032 setEventMessages($result,
null,
'errors');
3034 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
3039if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') ) {
3045 setEventMessages($result,
null,
'errors');
3047 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3048 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3054 $class =
'mod'.$module;
3056 if (class_exists($class)) {
3059 '@phan-var-force DolibarrModules $moduleobj';
3063 dol_print_error($db, $e->getMessage());
3070 $result = array_map(
'dol_strtolower', $objects);
3077 if ($checkcomment < 0) {
3078 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3081 if (in_array(
dol_strtolower($menus[$key][
'leftmenu']), $result)) {
3082 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
3090 clearstatcache(
true);
3091 if (function_exists(
'opcache_invalidate')) {
3095 setEventMessages($langs->trans(
'MenuDeletedSuccessfuly'),
null);
3096 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3102if ($dirins && $action ==
'addmenu' && empty($cancel) ) {
3108 setEventMessages($result,
null,
'errors');
3110 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3111 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3119 $class =
'mod'.$module;
3121 if (class_exists($class)) {
3124 '@phan-var-force DolibarrModules $moduleobj';
3128 dol_print_error($db, $e->getMessage());
3135 if (!
GETPOST(
'type',
'alpha')) {
3137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
3139 if (!
GETPOST(
'titre',
'alpha')) {
3141 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
3143 if (!
GETPOST(
'user',
'alpha')) {
3145 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
3147 if (!
GETPOST(
'url',
'alpha')) {
3149 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
3151 if (!empty(
GETPOST(
'target'))) {
3152 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
3153 if (!in_array(
GETPOST(
'target'), $targets)) {
3155 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
3162 foreach ($menus as $menu) {
3165 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
3170 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
3175 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
3178 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
3185 if (
GETPOST(
'type',
'alpha') ==
'left') {
3186 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
3188 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
3191 if (
GETPOST(
'type',
'alpha') ==
'top') {
3193 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3200 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3201 'type' =>
GETPOST(
'type',
'alpha'),
3204 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3205 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
3206 'url' =>
GETPOST(
'url',
'alpha'),
3209 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3211 'target' =>
GETPOST(
'target',
'alpha'),
3215 if (
GETPOST(
'type') ==
'left') {
3216 unset($menuToAdd[
'prefix']);
3217 if (empty(
GETPOST(
'fk_menu'))) {
3218 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
3220 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3223 if (
GETPOST(
'enabled') ==
'1') {
3224 $menuToAdd[
'enabled'] =
'isModEnabled("'.dol_strtolower(
$module).
'")';
3226 $menuToAdd[
'enabled'] =
"0";
3228 if (empty(
GETPOST(
'objects'))) {
3229 $menuToAdd[
'perms'] =
'1';
3233 if ($checkcomment < 0) {
3234 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3237 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
3239 clearstatcache(
true);
3240 if (function_exists(
'opcache_invalidate')) {
3249 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3250 setEventMessages($langs->trans(
'MenuAddedSuccesfuly'),
null);
3257if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') ) {
3258 $objectname =
GETPOST(
'tabobj');
3263 if (empty($cancel)) {
3268 setEventMessages($result,
null,
'errors');
3270 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3271 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3278 $class =
'mod'.$module;
3280 if (class_exists($class)) {
3283 '@phan-var-force DolibarrModules $moduleobj';
3287 dol_print_error($db, $e->getMessage());
3295 $menuModify = array(
3296 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3297 'type' =>
GETPOST(
'type',
'alpha'),
3300 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3301 'leftmenu' => $menus[$key][
'leftmenu'],
3302 'url' =>
GETPOST(
'url',
'alpha'),
3305 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3306 'perms' =>
GETPOST(
'perms',
'alpha'),
3307 'target' =>
GETPOST(
'target',
'alpha'),
3310 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3311 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3312 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3313 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3315 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3317 if ($menuModify[
'enabled'] ===
'') {
3318 $menuModify[
'enabled'] =
'1';
3320 if ($menuModify[
'perms'] ===
'') {
3321 $menuModify[
'perms'] =
'1';
3324 if (
GETPOST(
'type',
'alpha') ==
'top') {
3326 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3333 if ($checkComment < 0) {
3334 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3337 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3339 clearstatcache(
true);
3340 if (function_exists(
'opcache_invalidate')) {
3345 setEventMessages($langs->trans(
'ErrorMenuExistValue'),
null,
'errors');
3347 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));
3351 setEventMessages($langs->trans(
'MenuUpdatedSuccessfuly'),
null);
3352 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3357 $_POST[
'type'] =
'';
3358 $_POST[
'titre'] =
'';
3359 $_POST[
'fk_menu'] =
'';
3360 $_POST[
'leftmenu'] =
'';
3366if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) ) {
3371 setEventMessages($result,
null,
'errors');
3373 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3374 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3383 $class =
'mod'.$module;
3385 if (class_exists($class)) {
3388 '@phan-var-force DolibarrModules $moduleobj';
3392 dol_print_error($db, $e->getMessage());
3396 $keydescription =
GETPOST(
'keydescription',
'alpha');
3397 switch ($keydescription) {
3399 $propertyToUpdate =
'description';
3406 $propertyToUpdate = $keydescription;
3409 $error =
GETPOST(
'keydescription');
3413 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3414 $newValue =
GETPOST(
'propsmodule');
3415 $patternToFindLine =
'^\s*\$this->'.$propertyToUpdate.
'\s*=';
3416 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3418 $fileLines = file($moduledescriptorfile);
3421 foreach ($fileLines as &$line) {
3422 if (preg_match(
'/'.$patternToFindLine.
'/', $line)) {
3423 $result =
dolReplaceInFile($moduledescriptorfile, array($line => $newLine));
3426 } elseif ($result <= -1) {
3427 $langs->load(
"errors");
3428 setEventMessages($langs->trans(
'ErrorFailToEditFile', $moduledescriptorfile),
null,
'warnings');
3436 if ($changedone && $propertyToUpdate ===
'version') {
3440 clearstatcache(
true);
3441 if (function_exists(
'opcache_invalidate')) {
3445 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3447 setEventMessages($langs->trans(
'NothingProcessed'),
null,
'warnings');
3450 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.
$module);
3460$form =
new Form($db);
3471 '/includes/ace/src/ace.js',
3472 '/includes/ace/src/ext-statusbar.js',
3473 '/includes/ace/src/ext-language_tools.js',
3478llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3481$text = $langs->trans(
"ModuleBuilder");
3483$morehtmlright =
'<a href="'.DOL_URL_ROOT.
'/admin/tools/ui/index.php" target="_blank" rel="noopener">'.img_picto(
'',
'book',
'class="pictofixedwidth"').$langs->trans(
"UxComponentsDoc").
'</a>';
3487print
'<div class="info hideonsmartphone">';
3488print $langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development').
'</span>';
3494 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3499 $langs->load(
"errors");
3500 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3504 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3513$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3517$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3518$allowonlineinstall =
true;
3519if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3520 $allowonlineinstall =
false;
3522if (empty($allowonlineinstall)) {
3525 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3528 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3545 $loadclasserrormessage =
'';
3555 $class =
'mod'.$module;
3556 }
catch (Throwable $e) {
3557 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3558 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3559 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3563 if (class_exists($class)) {
3566 '@phan-var-force DolibarrModules $moduleobj';
3570 print $e->getMessage();
3573 if (empty($forceddirread)) {
3576 $langs->load(
"errors");
3577 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3578 print img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module).
'<br>';
3579 print $loadclasserrormessage;
3589$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3590$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3591$head[$h][2] =
'initmodule';
3594$linktoenabledisable =
'';
3596if ( count($listofmodules) > 0) {
3602 $param .=
'&module='.urlencode(
$module);
3605 $param .=
'&tab='.urlencode($tab);
3606 $param .=
'&tabobj='.urlencode($tabobj);
3608 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode(
$module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3612 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.
$module.$param.
'">';
3613 $linktoenabledisable .= img_picto($langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"),
'switch_on',
'', 0, 0, 0,
'',
'warning valignmiddle', 1);
3614 $linktoenabledisable .=
'</a>';
3619 $backtourlparam =
'';
3620 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.
$module;
3621 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3622 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3625 if (is_array($objMod->config_page_url)) {
3627 foreach ($objMod->config_page_url as $page) {
3630 $linktoenabledisable .=
' <a class="valignmiddle" href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.img_picto(
dol_ucfirst($page),
"setup").
'</a>';
3633 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3634 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3635 $linktoenabledisable .=
' <a class="valignmiddle" 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"', 0, 0, 0,
'',
'').
'</a>';
3639 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3640 $linktoenabledisable .=
' <a class="valignmiddle" 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"', 0, 0, 0,
'',
'').
'</a>';
3644 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3645 $linktoenabledisable .=
' <a class="valignmiddle" 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"', 0, 0, 0,
'',
'').
'</a>';
3649 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.
$module.$param.
'">';
3650 $linktoenabledisable .= img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip valignmiddle', 1);
3651 $linktoenabledisable .=
"</a>\n";
3656 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3657 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3658 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3659 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3661 if ($tmpmodulearray[
'modulenamewithcase'] ==
$module) {
3662 $head[$h][4] =
'<span class="inline-block valignmiddle">'.$linktoenabledisable.
'</span>';
3669$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3670$head[$h][1] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3671$head[$h][2] =
'deletemodule';
3679 print
'<!-- section init module -->'.
"\n";
3680 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3681 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3682 print
'<input type="hidden" name="action" value="initmodule">';
3683 print
'<input type="hidden" name="module" value="initmodule">';
3688 print
'<div class="tagtable table-border">';
3690 print
'<div class="tagtr"><div class="tagtd paddingright">';
3691 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3692 print
'</div><div class="tagtd">';
3693 print
'<input type="number" min="100000" name="idmodule" class="width100" value="500000">';
3694 print
'<span class="opacitymedium small">';
3695 print
' ';
3696 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info&hidetitle=1',
'',
'');
3698 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3700 print
'</div></div>';
3702 print
'<div class="tagtr"><div class="tagtd paddingright">';
3703 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3704 print
'</div><div class="tagtd">';
3705 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3706 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3707 print
'</div></div>';
3709 print
'<div class="tagtr"><div class="tagtd paddingright">';
3710 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3711 print
'</div><div class="tagtd">';
3712 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3713 print
'</div></div>';
3715 print
'<div class="tagtr"><div class="tagtd paddingright">';
3716 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3717 print
'</div><div class="tagtd">';
3718 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")).
'">';
3719 print
'</div></div>';
3721 print
'<div class="tagtr"><div class="tagtd paddingright">';
3722 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3723 print
'</div><div class="tagtd">';
3724 print
'<select name="family" id="family" class="minwidth400">';
3725 $arrayoffamilies = array(
3726 'hr' =>
"ModuleFamilyHr",
3727 'crm' =>
"ModuleFamilyCrm",
3728 'srm' =>
"ModuleFamilySrm",
3729 'financial' =>
'ModuleFamilyFinancial',
3730 'products' =>
'ModuleFamilyProducts',
3731 'projects' =>
'ModuleFamilyProjects',
3732 'ecm' =>
'ModuleFamilyECM',
3733 'technic' =>
'ModuleFamilyTechnic',
3734 'portal' =>
'ModuleFamilyPortal',
3735 'interface' =>
'ModuleFamilyInterface',
3736 'base' =>
'ModuleFamilyBase',
3737 'other' =>
'ModuleFamilyOther'
3739 foreach ($arrayoffamilies as $key => $value) {
3740 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>';
3744 print
'</div></div>';
3746 print
'<div class="tagtr"><div class="tagtd paddingright">';
3747 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3748 print
'</div><div class="tagtd">';
3749 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3750 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3752 print
' ';
3754 print
'<span class="opacitymedium small">';
3755 print
dolButtonToOpenUrlInDialogPopup(
'popup_picto_id', $langs->transnoentitiesnoconv(
"DocIconsList"), $langs->transnoentitiesnoconv(
"DocIconsList"),
'/admin/tools/ui/components/icons.php?hidenavmenu=1&displayMode=icon-only&mode=no-btn#img-picto-section-list',
'',
'');
3758 print
'</div></div>';
3760 print
'<div class="tagtr"><div class="tagtd paddingright">';
3761 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3762 print
'</div><div class="tagtd">';
3763 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")).
'" spellcheck="false"><br>';
3764 print
'</div></div>';
3766 print
'<div class="tagtr"><div class="tagtd paddingright">';
3767 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3768 print
'</div><div class="tagtd">';
3769 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")).
'" spellcheck="false"><br>';
3770 print
'</div></div>';
3774 print
'<br><center>';
3775 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3778} elseif (
$module ==
'deletemodule') {
3779 print
'<!-- Form to init a module -->'.
"\n";
3780 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3781 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3782 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3783 print
'<input type="hidden" name="module" value="deletemodule">';
3785 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3787 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3788 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3790} elseif (!empty(
$module) && $modulelowercase !==
null) {
3798 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3812 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3813 $head2[$h][1] = $langs->trans(
"Description");
3814 $head2[$h][2] =
'description';
3817 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3818 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3819 $head2[$h][2] =
'objects';
3822 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3823 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3824 $head2[$h][2] =
'languages';
3827 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3828 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3829 $head2[$h][2] =
'permissions';
3832 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3833 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3834 $head2[$h][2] =
'dictionaries';
3837 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3838 $head2[$h][1] = $langs->trans(
"Tabs");
3839 $head2[$h][2] =
'tabs';
3842 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3843 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3844 $head2[$h][2] =
'menus';
3847 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3848 $head2[$h][1] = $langs->trans(
"Hooks");
3849 $head2[$h][2] =
'hooks';
3852 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3853 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3854 $head2[$h][2] =
'triggers';
3857 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3858 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3859 $head2[$h][2] =
'widgets';
3862 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3863 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3864 $head2[$h][2] =
'emailings';
3867 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3868 $head2[$h][1] = $langs->trans(
"ImportExportProfiles");
3869 $head2[$h][2] =
'exportimport';
3872 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3873 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3874 $head2[$h][2] =
'css';
3877 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3878 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3879 $head2[$h][2] =
'js';
3882 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3883 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3884 $head2[$h][2] =
'cli';
3887 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3888 $head2[$h][1] = $langs->trans(
"CronList");
3889 $head2[$h][2] =
'cron';
3892 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3893 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="marginleftonlyshort badge">'.$hasDoc.
"</span>");
3894 $head2[$h][2] =
'specifications';
3897 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3898 $head2[$h][1] = $langs->trans(
"BuildPackage");
3899 $head2[$h][2] =
'buildpackage';
3902 $MAXTABFOROBJECT = 12;
3904 print
'<!-- Section for a given module -->';
3908 if ($tab ==
'description') {
3909 print
'<!-- tab=description -->'.
"\n";
3911 $pathtofilereadme = $modulelowercase.
'/README.md';
3912 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3913 $pathtoindex = $modulelowercase.
'/'.$modulelowercase.
'index.php';
3915 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3917 if ($action !=
'editfile' || empty($file)) {
3918 $morehtmlright =
'';
3919 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3920 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3923 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3925 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3931 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3932 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>';
3935 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"Index").
' : <strong class="wordbreak">'.$pathtoindex.
'</strong>';
3936 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($pathtoindex).
'">'.img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3940 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3941 foreach ($listofsetuppages as $setuppage) {
3944 if (preg_match(
'/^([a-z]+)_extrafields.php/', $setuppage[
'relativename'], $reg)) {
3946 $fileofclass = $realpathofmodule.
'/class/'.$reg[1].
'.class.php';
3947 if (is_readable($fileofclass) && !preg_match(
'/public\s+\$isextrafieldmanaged\s+=\s+1/', file_get_contents($fileofclass))) {
3954 print
'<span class="fa fa-file"></span> ';
3955 if ($setuppage[
'relativename'] ==
'about.php') {
3956 print $langs->trans(
"AboutFile");
3958 print $langs->trans(
"SetupFile");
3961 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3962 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>';
3966 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3967 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>';
3970 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3971 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>';
3977 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3980 print
'<div class="underbanner clearboth"></div>';
3981 print
'<div class="fichecenter">';
3982 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3983 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3984 print
'<input type="hidden" name="action" value="update_props_module">';
3985 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
3986 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3987 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3989 print
'<div class="div-table-responsive-no-min">';
3990 print
'<table class="border centpercent">';
3991 print
'<tr class="liste_titre"><td class="titlefield">';
3992 print $langs->trans(
"Parameter");
3994 print $langs->trans(
"Value");
3998 print $langs->trans(
"IdModule");
4001 print
'<span class="opacitymedium">';
4003 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
4004 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
4009 print $langs->trans(
"ModuleName");
4015 print $langs->trans(
"Description");
4017 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
4018 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'" spellcheck="false">';
4019 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
4020 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4023 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>';
4025 $moduledescritpionautotrans =
$moduleobj->getDesc();
4026 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
4028 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
4029 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
4031 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
4037 print $langs->trans(
"Version");
4039 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
4040 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
4041 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
4042 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4045 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>';
4050 print $langs->trans(
"Family");
4053 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
4054 print
'<select name="propsmodule" id="family" class="minwidth400">';
4055 $arrayoffamilies = array(
4056 'hr' =>
"ModuleFamilyHr",
4057 'crm' =>
"ModuleFamilyCrm",
4058 'srm' =>
"ModuleFamilySrm",
4059 'financial' =>
'ModuleFamilyFinancial',
4060 'products' =>
'ModuleFamilyProducts',
4061 'projects' =>
'ModuleFamilyProjects',
4062 'ecm' =>
'ModuleFamilyECM',
4063 'technic' =>
'ModuleFamilyTechnic',
4064 'portal' =>
'ModuleFamilyPortal',
4065 'interface' =>
'ModuleFamilyInterface',
4066 'base' =>
'ModuleFamilyBase',
4067 'other' =>
'ModuleFamilyOther'
4069 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>';
4070 foreach ($arrayoffamilies as $key => $value) {
4072 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
4076 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
4077 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4080 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>';
4084 print
'<!-- picto of module -->'.
"\n";
4086 print $langs->trans(
"Picto");
4088 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
4089 print
'<input class="minwidth200 maxwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'" spellcheck="false">';
4091 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]] where faprefix can be far,far, facolor can be a text like \'red\' orvalue like \'#FF0000\' and fasize is CSS font size like \'1em\'');
4093 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
4094 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4096 print
' ';
4098 print
'<span class="opacitymedium small">';
4099 print
dolButtonToOpenUrlInDialogPopup(
'popup_picto_id', $langs->transnoentitiesnoconv(
"DocIconsList"), $langs->transnoentitiesnoconv(
"DocIconsList"),
'/admin/tools/ui/components/icons.php?hidenavmenu=1&displayMode=icon-only&mode=no-btn#img-picto-section-list',
'',
'');
4103 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
4104 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>';
4109 print $langs->trans(
"EditorName");
4111 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
4112 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'" spellcheck="false">';
4113 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
4114 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4117 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>';
4122 print $langs->trans(
"EditorUrl");
4124 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
4125 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'" spellcheck="false">';
4126 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
4127 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4130 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.img_picto(
'',
'globe').
'</a>';
4132 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>';
4140 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module).
'<br>';
4147 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
4149 print
'<!-- readme file -->';
4150 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
4151 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
4153 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
4159 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
4161 print
'<!-- changelog file -->';
4163 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
4165 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
4174 if ($fullpathoffile) {
4175 $content = file_get_contents($fullpathoffile);
4179 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4180 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4181 print
'<input type="hidden" name="action" value="savefile">';
4182 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4183 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4184 print
'<input type="hidden" name="module" value="'.$module.
'">';
4188 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
4189 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
4190 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4195 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4197 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4203 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
4206 if ($tab ==
'languages') {
4207 print
'<!-- tab=languages -->'.
"\n";
4208 if ($action !=
'editfile' || empty($file)) {
4209 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
4213 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4215 print
'<input type="hidden" name="action" value="addlanguage">';
4216 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4217 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4218 print
'<input type="hidden" name="module" value="'.$module.
'">';
4219 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
4220 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
4230 $diroflang .=
'/langs';
4231 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
4233 if (!preg_match(
'/custom/', $dirread)) {
4235 $diroflang = $dirread;
4236 $diroflang .=
'/langs';
4237 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
4240 print
'<table class="none">';
4241 foreach ($langfiles as $langfile) {
4242 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
4243 if (!preg_match(
'/custom/', $dirread)) {
4244 $pathtofile =
'langs/'.$langfile[
'relativename'];
4246 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4247 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>';
4248 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>';
4259 $content = file_get_contents($fullpathoffile);
4262 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4263 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4264 print
'<input type="hidden" name="action" value="savefile">';
4265 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4266 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4267 print
'<input type="hidden" name="module" value="'.$module.
'">';
4269 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4270 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
4273 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4275 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4282 if ($tab ==
'objects') {
4283 print
'<!-- tab=objects -->'.
"\n";
4288 $dir = $dirread.
'/'.$modulelowercase.
'/class';
4290 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
4291 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4292 $head3[$h][2] =
'newobject';
4296 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
4298 $firstobjectname =
'';
4299 foreach ($listofobject as $fileobj) {
4300 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
4303 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
4307 $tmpcontent = file_get_contents($fileobj[
'fullname']);
4308 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
4310 $objectname = $reg[1];
4311 if (empty($firstobjectname)) {
4312 $firstobjectname = $objectname;
4314 $pictoname =
'generic';
4315 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
4316 $pictoname = $reg[1];
4319 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
4320 $head3[$h][1] = img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
4321 $head3[$h][2] = $objectname;
4327 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4328 $head3[$h][1] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4329 $head3[$h][2] =
'deleteobject';
4334 if ($tabobj ==
'newobjectifnoobj') {
4335 if ($firstobjectname) {
4336 $tabobj = $firstobjectname;
4338 $tabobj =
'newobject';
4342 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4345 if ($tabobj ==
'newobject') {
4347 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4348 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4349 print
'<input type="hidden" name="action" value="initobject">';
4350 print
'<input type="hidden" name="tab" value="objects">';
4351 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4358 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4360 print
'<div class="tagtable">';
4362 print
'<div class="tagtr"><div class="tagtd">';
4363 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4364 print
'</div><div class="tagtd">';
4365 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(
GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" required autofocus>';
4366 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4367 print
'</div></div>';
4369 print
'<div class="tagtr"><div class="tagtd">';
4370 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4371 print
'</div><div class="tagtd">';
4372 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4374 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]] where faprefix can be far,far, facolor can be a text like \'red\' orvalue like \'#FF0000\' and fasize is CSS font size like \'1em\'');
4376 print
'<span class="opacitymedium small">';
4377 print
' ';
4378 print
dolButtonToOpenUrlInDialogPopup(
'popup_picto_id', $langs->transnoentitiesnoconv(
"DocIconsList"), $langs->transnoentitiesnoconv(
"DocIconsList"),
'/admin/tools/ui/components/icons.php?hidenavmenu=1&displayMode=icon-only&mode=no-btn#img-picto-section-list',
'',
'');
4381 print
'</div></div>';
4383 print
'<div class="tagtr"><div class="tagtd">';
4384 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4385 print
'</div><div class="tagtd">';
4386 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4387 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4388 print
'</div></div>';
4393 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>';
4394 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4395 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4396 print
'<input type="checkbox" name="nogeneratelines" id="nogeneratelines" value="nogeneratelines"> <label for="nogeneratelines">'.$form->textwithpicto($langs->trans(
"NoGenerateLines"), $langs->trans(
"NoGenerateLinesHelp")).
'</label><br>';
4397 print
'<br><span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"EnabledTabsForObject"), $langs->trans(
"EnabledTabsForObjectHelp")).
'</span><br>';
4399 $checked = in_array($tabkey, $enabledtabsdefault,
true) ?
' checked' :
'';
4400 print
'<input type="checkbox" name="enabledtab[]" id="enabledtab_'.$tabkey.
'" value="'.
dol_escape_htmltag($tabkey).
'"'.$checked.
'> ';
4401 print
'<label for="enabledtab_'.$tabkey.
'">'.
dol_escape_htmltag($langs->trans($tabinfo[
'label'])).
'</label> ';
4404 print
'<br><span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"EnabledCardActionsForObject"), $langs->trans(
"EnabledCardActionsForObjectHelp")).
'</span><br>';
4406 $checked = in_array($actionkey, $enabledcardactionsdefault,
true) ?
' checked' :
'';
4407 print
'<input type="checkbox" name="enabledcardaction[]" id="enabledcardaction_'.$actionkey.
'" value="'.
dol_escape_htmltag($actionkey).
'"'.$checked.
'> ';
4408 print
'<label for="enabledcardaction_'.$actionkey.
'">'.
dol_escape_htmltag($langs->trans($actioninfo[
'label'])).
'</label> ';
4412 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4428 } elseif ($tabobj ==
'createproperty') {
4429 $attributesUnique = array(
4430 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4431 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4432 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4433 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4434 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4435 'propdefault' => $langs->trans(
"DefaultValue"),
4436 'propindex' => $langs->trans(
"DatabaseIndex"),
4437 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4438 'propposition' => $langs->trans(
"Position"),
4439 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4440 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4441 'propnoteditable' => $langs->trans(
"NotEditable"),
4443 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4444 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4445 'propcss' => $langs->trans(
"CSSClass"),
4446 'propcssview' => $langs->trans(
"CSSViewClass"),
4447 'propcsslist' => $langs->trans(
"CSSListClass"),
4448 'prophelp' => $langs->trans(
"KeyForTooltip"),
4449 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4451 'propcomment' => $langs->trans(
"Comment"),
4453 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode(
$module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4454 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4455 print
'<input type="hidden" name="action" value="addproperty">';
4456 print
'<input type="hidden" name="tab" value="objects">';
4457 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4458 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4460 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4462 foreach ($attributesUnique as $key => $attribute) {
4463 if ($counter % 2 === 0) {
4466 if ($key ==
'propname' || $key ==
'proplabel') {
4467 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>';
4468 } elseif ($key ==
'proptype') {
4469 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4470 print
'<input class="maxwidth200" name="'.$key.
'" id="'.$key.
'" list="datalist'.$key.
'" type="text" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4472 print
'<datalist id="datalist'.$key.
'">';
4473 print
'<option>varchar(128)</option>';
4474 print
'<option>email</option>';
4475 print
'<option>phone</option>';
4476 print
'<option>ip</option>';
4477 print
'<option>url</option>';
4478 print
'<option>password</option>';
4479 print
'<option>text</option>';
4480 print
'<option>html</option>';
4481 print
'<option>date</option>';
4482 print
'<option>datetime</option>';
4483 print
'<option>integer</option>';
4484 print
'<option>stars(5)</option>';
4485 print
'<option>double(28,4)</option>';
4486 print
'<option>real</option>';
4487 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4496 print
'</datalist>';
4500 } elseif ($key ==
'propvisible') {
4501 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>';
4502 } elseif ($key ==
'propenabled') {
4505 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>';
4506 } elseif ($key ==
'proparrayofkeyval') {
4507 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>';
4509 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>';
4512 if ($counter % 2 === 0) {
4516 if ($counter % 2 !== 0) {
4517 while ($counter % 2 !== 0) {
4523 print
'</table><br>'.
"\n";
4524 print
'<div class="center">';
4525 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4526 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4532 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode(
$module).
'";
4533 window.location.href = url;
4535 $(document).ready(function() {
4536 $("#proplabel").on("keyup", function() {
4537 console.log("key up on label");
4538 s = cleanString($("#proplabel").val());
4539 $("#propname").val(s);
4542 function cleanString( stringtoclean )
4544 // allow "a-z", "A-Z", "0-9" and "_"
4545 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4546 stringtoclean = stringtoclean.toLowerCase();
4547 if (!isNaN(stringtoclean)) {
4550 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4551 stringtoclean = stringtoclean.dol_substr(1)
4553 if (stringtoclean.length > 28) {
4554 stringtoclean = stringtoclean.substring(0, 27);
4556 return stringtoclean;
4561 } elseif ($tabobj ==
'deleteobject') {
4563 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4565 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4566 print
'<input type="hidden" name="tab" value="objects">';
4567 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4568 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4570 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4572 print
'<input type="text" class="valignmiddle" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4573 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4577 if ($action ==
'deleteproperty') {
4578 $formconfirm = $form->formconfirm(
4579 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode(
$module).
'&tabobj='.urlencode($tabobj),
4580 $langs->trans(
'Delete'),
4581 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4582 'confirm_deleteproperty',
4591 if ($action !=
'editfile' || empty($file)) {
4606 clearstatcache(
true);
4607 if (function_exists(
'opcache_invalidate')) {
4608 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4611 if (empty($forceddirread) && empty($dirread)) {
4613 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4615 $result = include_once $dirread.
'/'.$pathtoclass;
4616 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4619 if (class_exists($tabobj)) {
4621 $tmpobject = @
new $tabobj($db);
4623 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4626 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4642 $pathtosql =
'install/mysql/tables/llx_'.dol_strtolower(
$module).
'.sql';
4643 $pathtosqlextra =
'install/mysql/tables/llx_'.dol_strtolower(
$module).
'_extrafields.sql';
4657 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4659 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4660 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4665 $tmpobject = $tmpobject ??
null;
4666 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4667 $pathtopicto = $tmpobject->picto;
4668 $realpathtopicto =
'';
4671 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4676 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4677 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4678 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4679 $realpathtocard = $dirread.
'/'.$pathtocard;
4680 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4681 $realpathtolist = $dirread.
'/'.$pathtolist;
4682 $realpathtonote = $dirread.
'/'.$pathtonote;
4683 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4684 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4685 $realpathtosql = $dirread.
'/'.$pathtosql;
4686 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4687 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4688 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4689 $realpathtolib = $dirread.
'/'.$pathtolib;
4690 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4692 if (empty($realpathtoapi)) {
4694 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4704 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4705 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.(
dol_is_file($realpathtopicto) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtopicto).(
dol_is_file($realpathtopicto) ?
'' :
'</strike>').
'</strong>';
4706 $htmltooltip .=
'<br>';
4707 } elseif (!empty($tmpobject)) {
4708 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4709 $htmltooltip .=
'<br>';
4711 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsExtraFieldManaged").
' : '.yn(empty($tmpobject->isextrafieldmanaged) ? 0 : 1, 1, 2);
4712 $htmltooltip .=
'<br>';
4713 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsMultiEntityManaged").
' : '.yn(empty($tmpobject->ismultientitymanaged) ? 0 : 1, 1, 2);
4714 $htmltooltip .=
'<br>';
4716 print
'<!-- section for object -->';
4717 print
'<div class="fichehalfleft smallxxx">';
4719 print
'<span class="fa fa-file"></span> '.$langs->trans(
"ClassFile").
' : <strong>'.(
dol_is_file($realpathtoclass) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtoclass).(
dol_is_file($realpathtoclass) ?
'' :
'</strike>').
'</strong>';
4720 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>';
4721 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmiddle', 1);
4726 print
'<span class="fa fa-file"></span> '.$langs->trans(
"ApiClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoapi) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtoapi).(
dol_is_file($realpathtoapi) ?
'' :
'</span></strike>').
'</strong>';
4728 $file = file_get_contents($realpathtoapi);
4729 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4730 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>';
4732 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>';
4733 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4737 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled",
$module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4739 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4742 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>';
4745 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>';
4749 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TestClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtophpunit) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtophpunit).(
dol_is_file($realpathtophpunit) ?
'' :
'</span></strike>').
'</strong>';
4751 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>';
4753 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>';
4755 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>';
4761 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtolib) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtolib).(
dol_is_file($realpathtolib) ?
'' :
'</strike>').
'</strong>';
4762 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>';
4764 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForObjLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoobjlib) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtoobjlib).(
dol_is_file($realpathtoobjlib) ?
'' :
'</strike>').
'</strong>';
4765 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>';
4769 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosql) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtosql).(
dol_is_file($realpathtosql) ?
'' :
'</strike>').
'</strong>';
4770 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>';
4771 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>';
4774 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileKey").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlkey) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtosqlkey).(
dol_is_file($realpathtosqlkey) ?
'' :
'</strike>').
'</strong>';
4775 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>';
4778 if (!empty($tmpobject->isextrafieldmanaged)) {
4779 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextra) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtosqlextra).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4781 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>';
4783 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>';
4785 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>';
4787 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>';
4792 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileKeyExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextrakey) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtosqlextrakey).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4794 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>';
4796 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>';
4798 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>';
4804 print
'<div class="fichehalfleft smallxxxx">';
4805 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForList").
' : <strong class="wordbreak"><a href="'.$urloflist.
'" target="_test">'.(
dol_is_file($realpathtolist) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtolist).(
dol_is_file($realpathtolist) ?
'' :
'</span></strike>').
'</a></strong>';
4806 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>';
4808 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForCreateEditView").
' : <strong class="wordbreak"><a href="'.$urlofcard.
'?action=create" target="_test">'.(
dol_is_file($realpathtocard) ?
'' :
'<strike>').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtocard).(
dol_is_file($realpathtocard) ?
'' :
'</strike>').
'?action=create</a></strong>';
4809 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>';
4812 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForContactTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtocontact) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtocontact).(
dol_is_file($realpathtocontact) ?
'' :
'</span></strike>').
'</strong>';
4813 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>';
4816 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>';
4818 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>';
4822 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForDocumentTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtodocument) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtodocument).(
dol_is_file($realpathtodocument) ?
'' :
'</span></strike>').
'</strong>';
4823 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>';
4826 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>';
4828 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>';
4832 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForNoteTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtonote) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtonote).(
dol_is_file($realpathtonote) ?
'' :
'</span></strike>').
'</strong>';
4833 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>';
4836 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>';
4838 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>';
4842 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForAgendaTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoagenda) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.
dol_strtolower(
$module).
'\//',
'', $pathtoagenda).(
dol_is_file($realpathtoagenda) ?
'' :
'</span></strike>').
'</strong>';
4843 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>';
4846 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>';
4848 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>';
4855 print
'<br><br><br>';
4857 if (!empty($tmpobject)) {
4858 $reflector =
new ReflectionClass($tabobj);
4859 $reflectorproperties = $reflector->getProperties();
4860 $reflectorpropdefault = $reflector->getDefaultProperties();
4864 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4865 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4866 print
'<input type="hidden" name="action" value="addproperty">';
4867 print
'<input type="hidden" name="tab" value="objects">';
4868 print
'<input type="hidden" name="page_y" value="">';
4869 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4870 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4872 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4873 print
'<br><br class="clearboth">';
4874 print
'<br class="clearboth">';
4878 $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));
4879 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4881 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
4884 print
'<!-- Table with properties of object -->'.
"\n";
4885 print
'<div class="div-table-responsive">';
4886 print
'<table class="noborder small">';
4887 print
'<tr class="liste_titre">';
4888 if (!empty(
$conf->main_checkbox_left_column)) {
4889 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4891 print
'<th class="tdsticky tdstickygray">';
4892 $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>';
4893 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4896 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4898 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4899 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4900 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4901 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4902 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4903 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4904 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4905 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4906 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4907 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4909 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4910 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4911 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4912 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4913 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4914 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4915 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4917 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4918 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4919 if (empty(
$conf->main_checkbox_left_column)) {
4920 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4927 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4928 if (!empty($properties)) {
4930 foreach ($properties as $propkey => $propval) {
4945 $propname = $propkey;
4946 $proplabel = $propval[
'label'];
4947 $proptype = $propval[
'type'];
4948 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4949 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4950 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4951 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4952 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4953 $propposition = $propval[
'position'];
4954 $propenabled = $propval[
'enabled'];
4955 $propvisible = $propval[
'visible'];
4956 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4958 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4959 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4960 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4961 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4962 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4963 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4964 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4966 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4967 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4969 print
'<!-- line for object property -->'.
"\n";
4970 print
'<tr class="oddeven">';
4972 if (!empty(
$conf->main_checkbox_left_column)) {
4973 if ($action ==
'editproperty' && $propname == $propertykey) {
4974 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4975 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4976 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4979 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4980 if ($propname !=
'rowid') {
4981 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>';
4982 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>';
4987 print
'<td class="tdsticky tdstickygray">';
4990 if ($action ==
'editproperty' && $propname == $propertykey) {
4992 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4993 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4995 print
'<td class="tdoverflowmax150">';
4996 print
'<input name="proptype" id="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'" list="datalistproptype"></input>';
4998 print
'<datalist id="datalistproptype">';
4999 print
'<option>varchar(128)</option>';
5000 print
'<option>email</option>';
5001 print
'<option>phone</option>';
5002 print
'<option>ip</option>';
5003 print
'<option>url</option>';
5004 print
'<option>password</option>';
5005 print
'<option>text</option>';
5006 print
'<option>html</option>';
5007 print
'<option>date</option>';
5008 print
'<option>datetime</option>';
5009 print
'<option>integer</option>';
5010 print
'<option>stars(5)</option>';
5011 print
'<option>double(28,4)</option>';
5012 print
'<option>real</option>';
5013 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
5022 print
'</datalist>';
5025 print
'<td class="tdoverflowmax200">';
5026 print
'<textarea name="proparrayofkeyval">';
5027 if (isset($proparrayofkeyval)) {
5028 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
5032 print
'</textarea>';
5035 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
5038 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
5040 print
'<td class="center">';
5041 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
5044 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
5047 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
5050 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
5053 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
5056 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
5062 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
5065 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
5068 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
5071 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
5074 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
5077 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
5080 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
5083 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
5086 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
5088 if (empty(
$conf->main_checkbox_left_column)) {
5089 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5090 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
5091 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
5095 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
5098 print
'<td class="tdoverflowmax200">';
5101 if (preg_match(
'/^varchar/', $proptype, $matches)) {
5102 $pictoType =
'varchar';
5103 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
5104 $pictoType =
'link';
5105 } elseif (strpos($proptype,
'integer') === 0) {
5107 } elseif (strpos($proptype,
'timestamp') === 0) {
5108 $pictoType =
'datetime';
5109 } elseif (strpos($proptype,
'real') === 0) {
5110 $pictoType =
'double';
5111 } elseif (strpos($proptype,
'stars') === 0) {
5112 $pictoType =
'stars';
5116 print
'<td class="tdoverflowmax200">';
5117 if ($proparrayofkeyval) {
5118 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
5123 print
'<td class="center">';
5129 print
'<td class="center">';
5130 print $propindex ?
'1' :
'';
5132 print
'<td class="center">';
5135 print
'<td class="right">';
5138 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
5142 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
5146 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
5152 print
'<td class="center">';
5153 print $propsearchall ?
'1' :
'';
5155 print
'<td class="center">';
5158 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
5161 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
5164 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
5168 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
5171 print
'<td class="center">';
5177 print
'<td class="center">';
5180 print
'<td class="tdoverflowmax200">';
5181 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
5185 if (empty(
$conf->main_checkbox_left_column)) {
5186 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5187 if ($propname !=
'rowid') {
5188 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>';
5189 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>';
5197 if ($tab ==
'specifications') {
5198 if ($action !=
'editfile' || empty($file)) {
5199 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
5204 foreach ($specs as $spec) {
5205 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
5206 $format =
'asciidoc';
5207 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
5208 $format =
'markdown';
5210 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5211 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>';
5221 $content = file_get_contents($fullpathoffile);
5224 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5225 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5226 print
'<input type="hidden" name="action" value="savefile">';
5227 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5228 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5229 print
'<input type="hidden" name="module" value="'.$module.
'">';
5231 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5232 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5235 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5237 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5243 $langs->load(
"errors");
5244 print
'<tr><td><span class="warning">'.$langs->trans(
'ErrorModuleBuilderNoFieldProperty').
'</warning></td></tr>';
5251 $langs->load(
"errors");
5252 print
'<span class="warning">'.$langs->trans(
'ErrorModuleBuilderFailedToInit', $tabobj, (
string) $db).
'</warning>';
5256 print $e->getMessage();
5260 if (empty($forceddirread)) {
5263 $fullpathoffile = $dirread.
'/'.$file;
5266 $content = file_get_contents($fullpathoffile);
5269 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5270 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5271 print
'<input type="hidden" name="action" value="savefile">';
5272 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5273 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5274 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5275 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
5277 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5278 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5281 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5283 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5293 if ($tab ==
'dictionaries') {
5294 print
'<!-- tab=dictionaries -->'.
"\n";
5299 if ($action ==
'deletedict') {
5300 $formconfirm = $form->formconfirm(
5301 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)),
5302 $langs->trans(
'Delete'),
5303 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
5304 'confirm_deletedictionary',
5312 if ($action !=
'editfile' || empty($file)) {
5313 print
'<span class="opacitymedium">';
5314 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
5315 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
5316 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5320 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5321 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>';
5323 if (is_array($dicts) && !empty($dicts)) {
5324 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
5325 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
5336 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
5337 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
5338 $head3[$h][2] =
'newdictionary';
5379 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode(
$module).
'&tabdic=newdictionary');
5380 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
5382 if ($tabdic !=
'newdictionary') {
5383 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5384 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5385 print
'<input type="hidden" name="action" value="addDictionary">';
5386 print
'<input type="hidden" name="tab" value="dictionaries">';
5387 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5388 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
5390 print
'<div class="div-table-responsive">';
5391 print
'<table class="noborder">';
5393 print
'<tr class="liste_titre">';
5394 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
5407 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
5409 $maxi = count($dicts[
'tabname']);
5410 while ($i < $maxi) {
5411 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5412 print
'<tr class="oddeven">';
5413 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5414 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5415 print
'<input type="hidden" name="tab" value="dictionaries">';
5416 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5417 print
'<input type="hidden" name="action" value="updatedictionary">';
5418 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5420 print
'<td class="tdsticky tdstickygray">';
5425 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5429 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5433 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5437 print
'<select name="tabsqlsort">';
5438 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5442 print
'<td><select name="tabfield" >';
5443 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5444 print
'</select></td>';
5446 print
'<td><select name="tabfieldvalue" >';
5447 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5448 print
'</select></td>';
5450 print
'<td><select name="tabfieldinsert" >';
5451 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5452 print
'</select></td>';
5455 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5459 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5462 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5463 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5465 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5471 print
'<tr class="oddeven">';
5473 print
'<td class="tdsticky tdstickygray">';
5478 print $dicts[
'tabname'][$i];
5482 print $dicts[
'tablib'][$i];
5486 print $dicts[
'tabsql'][$i];
5490 print $dicts[
'tabsqlsort'][$i];
5494 print $dicts[
'tabfield'][$i];
5498 print $dicts[
'tabfieldvalue'][$i];
5502 print $dicts[
'tabfieldinsert'][$i];
5506 print $dicts[
'tabrowid'][$i];
5510 print $dicts[
'tabcond'][$i];
5513 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5514 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>';
5515 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>';
5523 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5532 if ($tabdic ==
'newdictionary') {
5534 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5535 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5536 print
'<input type="hidden" name="action" value="initdic">';
5537 print
'<input type="hidden" name="tab" value="dictionaries">';
5538 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5540 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5542 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5545 print
'<table class="border centpercent">';
5547 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>';
5548 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>';
5549 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>';
5550 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>';
5551 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5552 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5553 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5554 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5556 print
'</tbody></table>';
5557 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5558 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5562 $(document).ready(function() {
5563 $("input[name=\'dicname\']").on("blur", function() {
5564 if ($(this).val().length > 0) {
5565 $("input[name=\'label\']").val($(this).val());
5566 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5567 $("input[name=\'sqlsort\']").val("label ASC");
5568 $("input[name=\'field\']").val("code,label");
5569 $("input[name=\'fieldvalue\']").val("code,label");
5570 $("input[name=\'fieldinsert\']").val("code,label");
5571 $("input[name=\'rowid\']").val("rowid");
5573 $("input[name=\'label\']").val("");
5574 $("input[name=\'sql\']").val("");
5575 $("input[name=\'sqlsort\']").val("");
5576 $("input[name=\'field\']").val("");
5577 $("input[name=\'fieldvalue\']").val("");
5578 $("input[name=\'fieldinsert\']").val("");
5579 $("input[name=\'rowid\']").val("");
5582 $("input[id=\'cancel\']").click(function() {
5583 window.history.back();
5600 } elseif ($tabdic ==
'deletedictionary') {
5602 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5603 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5604 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5605 print
'<input type="hidden" name="tab" value="dictionaries">';
5606 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5608 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5610 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5611 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5619 $content = file_get_contents($fullpathoffile);
5622 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5623 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5624 print
'<input type="hidden" name="action" value="savefile">';
5625 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5626 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5627 print
'<input type="hidden" name="module" value="'.$module.
'">';
5629 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5630 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5631 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5634 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5636 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5643 if ($tab ==
'menus') {
5644 print
'<!-- tab=menus -->'.
"\n";
5648 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5651 $leftmenus = array();
5656 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5659 $groupedRights = array();
5660 foreach ($permissions as $right) {
5662 if (!isset($groupedRights[$key])) {
5663 $groupedRights[$key] = array();
5665 $groupedRights[$key][] = $right;
5667 $groupedRights_json = json_encode($groupedRights);
5669 if ($action ==
'deletemenu') {
5670 $formconfirms = $form->formconfirm(
5671 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)),
5672 $langs->trans(
'Delete'),
5673 ($menus[
GETPOST(
'menukey')][
'fk_menu'] ===
'fk_mainmenu='.
dol_strtolower(
$module) ? $langs->trans(
'Warning: you will delete all menus linked to this one.',
GETPOSTINT(
'menukey')) : $langs->trans(
'Confirm Delete Menu',
GETPOSTINT(
'menukey'))),
5674 'confirm_deletemenu',
5679 print $formconfirms;
5681 if ($action !=
'editfile' || empty($file)) {
5682 print
'<span class="opacitymedium">';
5683 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5684 $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);
5685 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5690 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5691 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>';
5695 $listODifferentUrlsInMenu = array();
5696 foreach ($menus as $obj) {
5697 if (preg_match(
'/^\/'.preg_quote(
dol_strtolower(
$module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5698 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5701 $pathtofile = $obj[
'url'];
5702 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5703 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5704 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>';
5713 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5714 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5715 print
'<input type="hidden" name="action" value="addmenu">';
5716 print
'<input type="hidden" name="tab" value="menus">';
5717 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5718 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5720 print
'<div class="div-table-responsive">';
5721 print
'<table class="noborder small">';
5723 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5724 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5725 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5726 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(
dol_strtolower(
$module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5727 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5728 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5729 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(
dol_strtolower(
$module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5731 print
'<tr class="liste_titre">';
5732 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5735 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5738 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5740 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5741 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5742 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5743 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5744 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5745 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5748 $r = count($menus) + 1;
5751 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5752 print
'<td class="center">';
5753 print
'<select class="maxwidth50" name="type">';
5754 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5755 print
'</select></td>';
5756 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5757 print
'<td class="left">';
5758 print
'<select name="fk_menu">';
5759 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5760 foreach ($menus as $obj) {
5761 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5762 print
"<option value=".dol_strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5768 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5770 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5771 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.dol_strtolower(
$module).
'@'.
dol_strtolower(
$module).
'" readonly></td>';
5773 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5775 print
'<td class="center">';
5776 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(
GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.
$module.
'\')').
'">';
5785 print
'<td class="left">';
5786 print
'<select class="maxwidth" name="objects" id="objects">';
5787 print
'<option value=""></option>';
5788 if (is_array($objects)) {
5789 foreach ($objects as $value) {
5794 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5797 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5798 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>';
5800 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5801 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5809 if (count($menus)) {
5811 foreach ($menus as $menu) {
5817 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5818 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5819 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5820 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5821 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5822 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5823 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5824 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5825 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5827 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5828 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5832 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5834 print
'<tr class="oddeven">';
5835 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5836 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5837 print
'<input type="hidden" name="action" value="update_menu">';
5838 print
'<input type="hidden" name="tab" value="menus">';
5839 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5840 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5842 print
'<td class="tdsticky tdstickygray">';
5846 print
'<td class="center">
5847 <select class="center maxwidth50" name="type">
5848 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5851 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5852 if ($menu[
'type'] ==
'left') {
5857 print
'</option></select></td>';
5859 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5870 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5872 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5873 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5875 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5876 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.dol_strtolower(
$module).
'@'.
dol_strtolower(
$module).
'" readonly></td>';
5878 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5880 print
'<td class="nowraponall">';
5881 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag(
$module).
"')").
'">';
5882 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5883 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5884 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5885 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag(
$module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5886 print $form->textwithpicto('', $htmltext);
5888 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5889 print '<option value=
"1">1 (always enabled)</option>
';
5890 print '<option value=
"0">0 (always
disabled)</option>
';
5896 print '<td
class=
"nowraponall">
';
5897 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5899 if (!empty($objPerms)) {
5900 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5901 print '<select
class=
"center maxwidth50" name=
"perms">
';
5902 if (!empty($valPerms)) {
5903 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5904 foreach ($crud as $key => $val) {
5905 if ($valPerms != $key) {
5906 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5912 print '<select
class=
"center maxwidth50" name=
"objects">
';
5913 print '<option></option>
';
5914 foreach ($objects as $obj) {
5915 print '<option value=
"'.dol_escape_htmltag(dol_strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5918 print '<select
class=
"center maxwidth50" name=
"perms">
';
5919 foreach ($crud as $key => $val) {
5920 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5926 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5927 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>
';
5928 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5929 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5930 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5935 print '<tr
class=
"oddeven">
';
5937 print '<td
class=
"tdsticky tdstickygray">
';
5941 print '<td
class=
"center">
';
5942 print dol_escape_htmltag($menu['type']);
5947 print dol_escape_htmltag($menu['titre
']);
5951 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5952 print dol_escape_htmltag($menu['fk_menu
']);
5956 print dol_escape_htmltag($menu['mainmenu
']);
5960 print dol_escape_htmltag($menu['leftmenu
']);
5963 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5964 print dol_escape_htmltag($menu['url
']);
5968 print dol_escape_htmltag($menu['langs
']);
5972 print '<td
class=
"center">
';
5973 print dol_escape_htmltag((string) $menu['position']);
5977 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5978 print dol_escape_htmltag($menu['enabled
']);
5982 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5983 print dol_escape_htmltag($langs->trans($menu['perms
']));
5987 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5988 print dol_escape_htmltag($menu['target
']);
5991 print '<td
class=
"center">
';
5992 if ($menu['user'] == 2) {
5993 print $langs->trans("AllMenus");
5994 } elseif ($menu['user'] == 0) {
5995 print $langs->trans('Internal
');
5996 } elseif ($menu['user'] == 1) {
5997 print $langs->trans('External
');
5999 print $menu['user']; // should not happen
6002 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
6003 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
6004 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>
';
6005 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>
';
6012 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
6021 $(document).ready(
function() {
6023 $(
"#leftmenu").on(
"input",
function() {
6024 var inputLeftMenu = $(
"#leftmenu").val();
6025 if (inputLeftMenu !== \
'\') {
6033 var groupedRights = ' . $groupedRights_json .
';
6034 var objectsSelect = $("select[id=\'objects\']");
6035 var permsSelect = $("select[id=\'perms\']");
6037 objectsSelect.change(function() {
6038 var selectedObject = $(this).val();
6040 permsSelect.empty();
6042 var rights = groupedRights[selectedObject];
6045 for (var i = 0; i < rights.length; i++) {
6046 var right = rights[i];
6047 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
6048 permsSelect.append(option);
6051 var option = $("<option></option>").attr("value", "read").text("read");
6052 permsSelect.append(option);
6055 if (selectedObject !== "" && selectedObject !== null && rights) {
6060 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
6071 $content = file_get_contents($fullpathoffile);
6074 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6075 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6076 print
'<input type="hidden" name="action" value="savefile">';
6077 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6078 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6079 print
'<input type="hidden" name="module" value="'.$module.
'">';
6081 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6082 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6083 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6086 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6088 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6095 if ($tab ==
'permissions') {
6096 print
'<!-- tab=permissions -->'.
"\n";
6102 $dir = $dirread.
'/'.$modulelowercase.
'/class';
6103 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
6104 $objects = array(
'myobject');
6106 foreach ($listofobject as $fileobj) {
6107 $tmpcontent = file_get_contents($fileobj[
'fullname']);
6108 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
6109 $objects[$fileobj[
'fullname']] = $reg[1];
6114 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
6115 $labels = array(
"Read objects of ".
$module,
"Create/Update objects of ".
$module,
"Delete objects of ".
$module);
6117 $action =
GETPOST(
'action',
'alpha');
6119 if ($action ==
'deleteright') {
6120 $formconfirm = $form->formconfirm(
6121 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)).
'&tabobj='.urlencode((
string) ($tabobj)),
6122 $langs->trans(
'Delete'),
6123 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
6124 'confirm_deleteright',
6132 if ($action !=
'editfile' || empty($file)) {
6133 print
'<!-- Tab to manage permissions -->'.
"\n";
6134 print
'<span class="opacitymedium">';
6135 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip");
6138 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6142 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6143 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>';
6149 print
'<!-- form to add permissions -->'.
"\n";
6150 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6151 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6152 print
'<input type="hidden" name="action" value="addright">';
6153 print
'<input type="hidden" name="tab" value="permissions">';
6154 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6155 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6157 print
'<div class="div-table-responsive">';
6158 print
'<table class="noborder">';
6160 print
'<tr class="liste_titre">';
6162 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
6169 print
'<tr class="small">';
6170 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
6172 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
6173 print
'<option value=""></option>';
6174 foreach ($objects as $obj) {
6175 if ($obj !=
'myobject') {
6176 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
6179 print
'</select></td>';
6181 print
'<td><select class="maxwidth75" name="crud" id="crud">';
6182 print
'<option value=""></option>';
6183 foreach ($crud as $key => $val) {
6184 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
6189 print
'<input type="text" name="label" id="label" class="minwidth200">';
6192 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6193 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
6197 if (count($perms)) {
6199 foreach ($perms as $perm) {
6203 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
6204 print
'<tr class="oddeven">';
6205 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
6206 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6207 print
'<input type="hidden" name="tab" value="permissions">';
6208 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6209 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6210 print
'<input type="hidden" name="action" value="update_right">';
6211 print
'<input type="hidden" name="counter" value="'.$i.
'">';
6213 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
6215 print
'<td class="tdsticky tdstickygray">';
6216 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
6220 print
'<select name="crud">';
6221 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
6222 foreach ($crud as $i => $x) {
6223 if ($perm[5] != $i) {
6224 print
'<option value="'.$i.
'">'.$langs->trans(
dol_ucfirst($x)).
'</option>';
6230 print
'<td><select name="permissionObj" >';
6231 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.
dol_ucfirst($perm[4]).
'</option>';
6232 print
'</select></td>';
6235 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
6238 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6239 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
6241 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
6248 print
'<tr class="oddeven">';
6255 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
6263 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
6271 print $langs->trans($perm[1]);
6274 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6275 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>';
6276 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>';
6284 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6292 function updateInputField() {
6293 value1 = $("#crud").val();
6294 value2 = $("#permissionObj").val();
6296 // Check if both selections are made
6297 if (value1 && value2) {
6298 switch(value1.toLowerCase()){
6300 $("#label").val("Read "+value2+" object of '.dol_ucfirst(
$module).
'")
6314 $("#crud, #permissionObj").change(function(){
6315 console.log("We change selection");
6323 $content = file_get_contents($fullpathoffile);
6326 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6328 print
'<input type="hidden" name="action" value="savefile">';
6329 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6330 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6331 print
'<input type="hidden" name="module" value="'.$module.
'">';
6333 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6334 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6335 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6338 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6340 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6347 if ($tab ==
'hooks') {
6348 print
'<!-- tab=hooks -->'.
"\n";
6349 if ($action !=
'editfile' || empty($file)) {
6350 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
6357 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6359 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>';
6364 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
6366 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6368 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> ';
6369 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>';
6371 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6372 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inithook&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</td>';
6379 $content = file_get_contents($fullpathoffile);
6382 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6383 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6384 print
'<input type="hidden" name="action" value="savefile">';
6385 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6386 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6387 print
'<input type="hidden" name="module" value="'.$module.
'">';
6389 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6390 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6391 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6394 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6396 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6403 if ($tab ==
'triggers') {
6404 print
'<!-- tab=triggers -->'.
"\n";
6405 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
6410 if ($action !=
'editfile' || empty($file)) {
6411 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6418 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6420 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>';
6423 if (!empty($triggers)) {
6424 foreach ($triggers as $trigger) {
6425 $pathtofile = $trigger[
'relpath'];
6428 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6429 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>';
6430 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>';
6435 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6436 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6437 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inittrigger&token='.
newToken().
'&format=php">'.img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
6446 $content = file_get_contents($fullpathoffile);
6449 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6450 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6451 print
'<input type="hidden" name="action" value="savefile">';
6452 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6453 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6454 print
'<input type="hidden" name="module" value="'.$module.
'">';
6456 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6457 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6458 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6461 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6463 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6470 if ($tab ==
'css') {
6471 print
'<!-- tab=css -->'.
"\n";
6472 if ($action !=
'editfile' || empty($file)) {
6473 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6480 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6482 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6483 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>';
6484 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>';
6486 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6487 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcss&token='.
newToken().
'&format=php&file='.urlencode($pathtohook).
'">'.img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a></td>';
6493 $content = file_get_contents($fullpathoffile);
6496 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6497 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6498 print
'<input type="hidden" name="action" value="savefile">';
6499 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6500 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6501 print
'<input type="hidden" name="module" value="'.$module.
'">';
6503 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6504 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6507 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6509 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6517 print
'<!-- tab=js -->'.
"\n";
6518 if ($action !=
'editfile' || empty($file)) {
6519 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6526 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6528 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6529 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>';
6530 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>';
6532 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6533 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>';
6539 $content = file_get_contents($fullpathoffile);
6542 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6543 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6544 print
'<input type="hidden" name="action" value="savefile">';
6545 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6546 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6547 print
'<input type="hidden" name="module" value="'.$module.
'">';
6549 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6550 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6553 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6555 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6562 if ($tab ==
'widgets') {
6563 print
'<!-- tab=widgets -->'.
"\n";
6564 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6568 if ($action !=
'editfile' || empty($file)) {
6569 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6573 if (!empty($widgets)) {
6574 foreach ($widgets as $widget) {
6575 $pathtofile = $widget[
'relpath'];
6577 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6578 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>';
6579 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>';
6583 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6584 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>';
6591 $content = file_get_contents($fullpathoffile);
6594 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6595 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6596 print
'<input type="hidden" name="action" value="savefile">';
6597 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6598 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6599 print
'<input type="hidden" name="module" value="'.$module.
'">';
6601 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6602 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6605 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6607 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6614 if ($tab ==
'emailings') {
6615 print
'<!-- tab=emailings -->'.
"\n";
6616 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6620 if ($action !=
'editfile' || empty($file)) {
6621 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6625 if (!empty($emailingselectors)) {
6626 foreach ($emailingselectors as $emailingselector) {
6627 $pathtofile = $emailingselector[
'relpath'];
6629 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6630 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>';
6631 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>';
6635 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6636 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>';
6643 $content = file_get_contents($fullpathoffile);
6646 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6647 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6648 print
'<input type="hidden" name="action" value="savefile">';
6649 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6650 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6651 print
'<input type="hidden" name="module" value="'.$module.
'">';
6653 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6654 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6657 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6659 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6666 if ($tab ==
'exportimport') {
6667 print
'<!-- tab=exportimport -->'.
"\n";
6673 if ($action !=
'editfile' || empty($file)) {
6674 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6677 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6678 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>';
6680 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6681 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>';
6686 $content = file_get_contents($fullpathoffile);
6689 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6690 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6691 print
'<input type="hidden" name="action" value="savefile">';
6692 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6693 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6694 print
'<input type="hidden" name="module" value="'.$module.
'">';
6696 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6697 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6698 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6701 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6703 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6710 if ($tab ==
'cli') {
6711 print
'<!-- tab=cli -->'.
"\n";
6712 $clifiles = array();
6717 foreach ($dircli as $reldir) {
6726 $handle = opendir($newdir);
6728 if (is_resource($handle)) {
6729 while (($tmpfile = readdir($handle)) !==
false) {
6730 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6731 if (preg_match(
'/\.back$/', $tmpfile)) {
6735 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6744 if ($action !=
'editfile' || empty($file)) {
6745 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6749 if (!empty($clifiles)) {
6750 foreach ($clifiles as $clifile) {
6751 $pathtofile = $clifile[
'relpath'];
6753 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6754 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>';
6755 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>';
6759 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6760 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>';
6767 $content = file_get_contents($fullpathoffile);
6770 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6771 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6772 print
'<input type="hidden" name="action" value="savefile">';
6773 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6774 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6775 print
'<input type="hidden" name="module" value="'.$module.
'">';
6777 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6778 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6781 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6783 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6790 if ($tab ==
'cron') {
6791 print
'<!-- tab=cron -->'.
"\n";
6796 if ($action !=
'editfile' || empty($file)) {
6797 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>';
6800 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6801 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>';
6807 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6808 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6809 print
'<input type="hidden" name="action" value="addproperty">';
6810 print
'<input type="hidden" name="tab" value="objects">';
6811 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6812 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6814 print
'<div class="div-table-responsive">';
6815 print
'<table class="noborder">';
6817 print
'<tr class="liste_titre">';
6825 if (count($cronjobs)) {
6826 foreach ($cronjobs as $cron) {
6827 print
'<tr class="oddeven">';
6830 print $cron[
'label'];
6835 if ($cron[
'jobtype'] ==
'method') {
6836 $text = $langs->trans(
"CronClass");
6837 $texttoshow = $langs->trans(
'CronModule').
': '.
$module.
'<br>';
6838 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6839 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6840 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6841 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6842 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6843 } elseif ($cron[
'jobtype'] ==
'command') {
6844 $text = $langs->trans(
'CronCommand');
6845 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6846 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6847 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6849 print $form->textwithpicto($text, $texttoshow, 1);
6853 if ($cron[
'unitfrequency'] ==
"60") {
6854 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6856 if ($cron[
'unitfrequency'] ==
"3600") {
6857 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6859 if ($cron[
'unitfrequency'] ==
"86400") {
6860 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6862 if ($cron[
'unitfrequency'] ==
"604800") {
6863 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6868 print $cron[
'status'];
6872 if (!empty($cron[
'comment'])) {
6873 print $cron[
'comment'];
6880 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6890 $content = file_get_contents($fullpathoffile);
6893 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6894 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6895 print
'<input type="hidden" name="action" value="savefile">';
6896 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6897 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6898 print
'<input type="hidden" name="module" value="'.$module.
'">';
6900 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6901 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6902 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6905 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6907 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6914 if ($tab ==
'specifications') {
6915 print
'<!-- tab=specifications -->'.
"\n";
6918 if ($action !=
'editfile' || empty($file)) {
6919 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6923 if (is_array($specs) && !empty($specs)) {
6924 foreach ($specs as $spec) {
6925 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6926 $format =
'asciidoc';
6927 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6928 $format =
'markdown';
6931 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6932 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>';
6933 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>';
6938 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6939 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>';
6950 $content = file_get_contents($fullpathoffile);
6953 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6954 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6955 print
'<input type="hidden" name="action" value="savefile">';
6956 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6957 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6958 print
'<input type="hidden" name="module" value="'.$module.
'">';
6960 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6961 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6964 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6966 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6972 print
'<br><br><br>';
6974 $FILENAMEDOC = $modulelowercase.
'.html';
6975 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6976 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6977 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6978 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6979 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6980 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6981 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6984 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6986 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6989 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6990 print $outputfiledoc;
6993 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6994 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>';
6996 print
'</strong><br>';
6999 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
7001 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7004 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
7005 print $outputfiledocpdf;
7008 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
7009 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>';
7011 print
'</strong><br>';
7015 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
7016 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7017 print
'<input type="hidden" name="action" value="generatedoc">';
7018 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
7019 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7020 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
7021 if (!is_array($specs) || empty($specs)) {
7022 print
' disabled="disabled"';
7028 if ($tab ==
'buildpackage') {
7029 print
'<!-- tab=buildpackage -->'.
"\n";
7030 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
7033 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
7034 print img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
7046 $class =
'mod'.$module;
7048 if (class_exists($class)) {
7051 '@phan-var-force DolibarrModules $moduleobj';
7055 dol_print_error($db, $e->getMessage());
7060 $langs->load(
"errors");
7061 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
7065 $outputfilezip =
null;
7066 $arrayversion = explode(
'.',
$moduleobj->version, 3);
7067 if (count($arrayversion)) {
7068 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
7069 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
7074 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
7075 if ($outputfilezip ===
null || !
dol_is_file($outputfilezip)) {
7076 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7078 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
7079 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
7080 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
7081 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>';
7089 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
7090 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7091 print
'<input type="hidden" name="action" value="generatepackage">';
7092 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
7093 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7094 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
7098 if ($tab ==
'tabs') {
7103 if ($action !=
'editfile' || empty($file)) {
7104 print
'<span class="opacitymedium">';
7105 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
7106 $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);
7107 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
7111 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
7112 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>';
7118 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7119 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7120 print
'<input type="hidden" name="action" value="addproperty">';
7121 print
'<input type="hidden" name="tab" value="objects">';
7122 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7123 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
7125 print
'<div class="div-table-responsive">';
7126 print
'<table class="noborder small">';
7128 print
'<tr class="liste_titre">';
7138 foreach ($tabs as $tab) {
7139 $parts = explode(
':', $tab[
'data']);
7141 $objectType = $parts[0];
7142 $tabName = $parts[1];
7143 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
7144 $langFile = isset($parts[3]) ? $parts[3] :
'';
7145 $condition = isset($parts[4]) ? $parts[4] :
'';
7146 $path = isset($parts[5]) ? $parts[5] :
'';
7150 if ($tabName[0] ===
'-') {
7152 $condition = isset($parts[2]) ? $parts[2] :
'';
7155 print
'<tr class="oddeven">';
7162 if ($tabName[0] ===
"+") {
7163 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
7165 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
7188 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
7198 $content = file_get_contents($fullpathoffile);
7201 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7202 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7203 print
'<input type="hidden" name="action" value="savefile">';
7204 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
7205 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
7206 print
'<input type="hidden" name="module" value="'.$module.
'">';
7208 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
7209 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
7210 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
7213 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
7215 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
7222 if ($tab !=
'description') {
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Syncs rights straight into the mod<Module>.class.php descriptor file.
Class to manage a WYSIWYG editor.
Class to manage triggers.
static getEmailingSelectorsList($forcedir=null)
Return list of widget.
static getWidgetsList($forcedirwidget=null)
Return list of widget.
Immutable value object holding all case variants of a module/object pair.
Immutable request describing one permissions sync to perform on a module descriptor.
static forObjectDeletion(string $module, string $descriptorFile, array $permissions, string $objectName)
Drop every right attached to an object being deleted.
static forRightDeletion(string $module, string $descriptorFile, array $permissions, int $rightKey)
Remove one right, addressed by its index in the rights array.
static forRightUpdate(string $module, string $descriptorFile, array $permissions, int $rightKey, string $objectName, string $label, string $crud)
Replace one right, addressed by its index in the rights array.
static forRightAddition(string $module, string $descriptorFile, array $permissions, string $objectName, string $label, string $crud)
Append one right to the descriptor.
static forObjectCreation(string $module, string $descriptorFile, array $permissions, string $objectName)
Declare the three CRUD rights of a newly generated object.
Strict implementation — reports any residual myobject/mymodule token as a warning.
Immutable outcome of a permissions sync run.
Class to manage utility methods.
if(! $sortfield) if(! $sortorder) $module
removePatternFromFile(string $filePath, string $pattern)
Removes content from a file that matches a given pattern.
dol_filemtime($pathoffile)
Return time of a file.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_writable($folderorfile)
Test if directory or filename is writable.
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null, $excludearchivefiles=0)
Copy a dir to another dir.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask='0', $indexdatabase=0, $arrayreplacementisregex=0)
Make replacement of strings into a file.
dol_is_dir_empty($dir)
Return if path is empty.
dol_now($mode='gmt')
Return date for now.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
treeview li table
No Email.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getPictoForType($key, $morecss='')
Return the picto for a data type.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
getLicenceHeader($user, $langs, $now)
Produce copyright replacement string for user.
modulebuilderValidateGeneratedFile(string $destfile, NamingContract $nc)
Post-generation validation – logs and displays a warning if residual myobject/mymodule tokens remain.
foreach( $dirsrootforscan as $tmpdirread) moduleBuilderShutdownFunction()
Add management to catch fatal errors - shutdown handler.
getModuleBuilderDefaultEnabledKeys($map)
Return the keys enabled by default in a ModuleBuilder generation map.
updateDictionaryInFile($module, $file, $dicts)
Updates a dictionary in a module descriptor file.
deletePropsAndPermsFromDoc($file, $objectname)
Delete property and permissions from documentation ascii file if we delete an object.
getModuleBuilderCardActionUncommentPatterns($marker)
Build the regular expressions removing the comment fence of a card action generated in 'activate' mod...
createNewDictionnary($modulename, $file, $namedic, $dictionnaires=null)
Create a new dictionary table.
filterEnabledKeys($requested, $map)
Filter a list of requested keys against a known map of generable elements.
countItemsInDirectory($path, $type=1)
count directories or files in modulebuilder folder
getModuleBuilderCardActionBlockPattern($marker)
Build the regular expression matching every block of a card action in the object card template.
writePermsInAsciiDoc($file, $destfile)
Write all permissions of each object in AsciiDoc format.
reWriteAllMenus($file, $menus, $menuWantTo, $key, $action)
rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null, $moduletype='external')
Save data into a memory area shared by all users, all sessions on server.
writeApiUrlsInDoc($file_api, $file_doc)
Generate Urls and add them to documentation module.
dolGetListOfObjectClasses($destdir)
Get list of existing objects from a directory.
getModuleBuilderLinesBlockPattern()
Return the regular expression matching a block of object lines code in the templates,...
writePropsInAsciiDoc($file, $objectname, $destfile)
Write all properties of the object in AsciiDoc format.
removeObjectFromApiFile($file, $objects, $objectname)
Remove Object variables and methods from API_Module File.
getModuleBuilderObjectCardActions()
Return the map of optional action buttons that can be generated on the card page of a ModuleBuilder o...
dolReplaceInFilePreservingModuleBuilderMarkers($file, $arrayreplacement)
Apply substitutions to a module descriptor file while preserving the MODULEBUILDER comment markers.
rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array(), $delfieldentry='')
Regenerate files .class.php.
checkExistComment($file, $number)
Function to check if comment BEGIN and END exists in modMyModule class.
getModuleBuilderObjectTabs()
Return the map of optional tabs that can be generated for a ModuleBuilder object.
addObjectsToApiFile($srcfile, $file, $objects, $modulename)
Add Object in ModuleApi File.
$conf db user
Active Directory does not allow anonymous connections.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.