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",
"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');
336$hookmanager->initHooks(array(
'modulebuilder'));
339$parameters = array(
'module' =>
$module,
'tab' => $tab,
'tabobj' => $tabobj,
'dirins' => $dirins,
'dirread' => $dirread,
'listofmodules' => $listofmodules);
340$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $hookobject, $action);
342 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
349if ($dirins && $action ==
'initmodule' && $modulename) {
351 $destdir =
'/not_set/';
354 if (preg_match(
'/[^a-z0-9]/i', $modulename)) {
356 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
360 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
363 $arrayreplacement = [
364 'mymodule' => $ncModule->moduleNameLower,
365 'MyModule' => $ncModule->moduleNameCase,
367 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayreplacement);
372 $langs->load(
"errors");
373 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
376 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
382 $tryToCopyFromSetupClass =
true;
383 $backportDest = $destdir .
'/backport/v16/core/class';
384 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
385 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
390 $langs->load(
"errors");
391 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
392 $tryToCopyFromSetupClass =
false;
395 if ($tryToCopyFromSetupClass) {
396 $result =
dol_copy($backportFileSrc, $backportFileDest);
400 $langs->load(
"errors");
401 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
403 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
446 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
467 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
470 foreach ($listofphpfilestoedit as $phpfileval) {
472 $arrayreplacement = array_merge(
473 $ncModule->getSubstitutionMap(),
475 'htdocs/modulebuilder/template' => $ncModule->moduleNameLower,
476 '---Put here your own copyright and developer email---' => $licInfo,
477 '---Replace with your own copyright and developer email---' => $licInfo,
478 'Editor name' => $editorname,
479 'https://www.example.com' => $editorurl,
480 '$this->version = \'1.0\'' =>
'$this->version = \'' . $version .
'\'',
481 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\';' :
'$this->picto = \'' . $picto .
'\';',
482 'modulefamily' => $family,
486 '$this->numero = 500000' =>
'$this->numero = '.$idmodule,
491 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
"\t\t" .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
498 $langs->load(
"errors");
499 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
504 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
506 file_put_contents($destdir.
'/README.md',
getDolGlobalString(
"MODULEBUILDER_SPECIFIC_README"));
517 setEventMessages($langs->trans(
'ModuleInitialized', $destdir),
null);
520 clearstatcache(
true);
521 if (function_exists(
'opcache_invalidate')) {
525 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
530$destdir =
'/not_set/';
531$destfile =
'/not_set/';
532$srcfile =
'/not_set/';
535if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty(
$module) ) {
537 $objectname = $tabobj;
538 $varnametoupdate =
'';
539 $accesspolicyfailed =
false;
547 if ($action ==
'initapi') {
552 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
553 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
555 } elseif ($action ==
'initphpunit') {
557 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
558 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
560 } elseif ($action ==
'initpagecontact') {
562 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
563 $srcfile = $srcdir.
'/myobject_contact.php';
565 $varnametoupdate =
'showtabofpagecontact';
566 } elseif ($action ==
'initpagedocument') {
568 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
569 $srcfile = $srcdir.
'/myobject_document.php';
571 $varnametoupdate =
'showtabofpagedocument';
572 } elseif ($action ==
'initpagenote') {
574 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
575 $srcfile = $srcdir.
'/myobject_note.php';
577 $varnametoupdate =
'showtabofpagenote';
578 } elseif ($action ==
'initpageagenda') {
580 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
581 $srcfile = $srcdir.
'/myobject_agenda.php';
583 $varnametoupdate =
'showtabofpageagenda';
586 if (!file_exists($destfile)) {
587 $result =
dol_copy($srcfile, $destfile,
'0', 0);
594 }
catch (\InvalidArgumentException $e) {
596 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
600 if (!$error && $ncApiObj !==
null) {
601 $arrayreplacement = array_merge(
602 $ncApiObj->getSubstitutionMap(),
604 'htdocs/modulebuilder/template' => $ncApiObj->moduleNameLower,
605 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now),
609 if ($action ==
'initapi') {
610 if (count($objects) >= 1) {
616 $headerFix = $arrayreplacement;
617 unset($headerFix[
'MYOBJECT']);
623 if ($varnametoupdate) {
624 $classfile = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
628 $accesspolicyfailed =
true;
629 $langs->load(
"errors");
630 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $destfile),
null,
'errors');
632 }
catch (\InvalidArgumentException $e) {
633 $accesspolicyfailed =
true;
634 dol_syslog(
"modulebuilder: invalid access policy stored in ".$classfile.
": ".$e->getMessage(), LOG_ERR);
635 setEventMessages($langs->trans(
"ErrorModuleBuilderInvalidStoredAccessPolicy", basename($classfile)),
null,
'errors');
638 if ($accesspolicyfailed) {
649 if ($varnametoupdate && !$accesspolicyfailed) {
652 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
657 $langs->load(
"errors");
658 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
664if ($dirins && $action ==
'initsqlextrafields' && !empty(
$module) ) {
666 $objectname = $tabobj;
669 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
670 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
672 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
673 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
675 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
677 if ($result1 > 0 && $result2 > 0) {
683 }
catch (\InvalidArgumentException $e) {
685 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
689 if (!$error && $ncSqlObj !==
null) {
690 $arrayreplacement = array_merge(
691 $ncSqlObj->getSubstitutionMap(),
693 'htdocs/modulebuilder/template' => $ncSqlObj->moduleNameLower,
694 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now),
704 $langs->load(
"errors");
706 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
709 $langs->load(
"errors");
710 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
716 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
717 $arrayreplacement = array(
'/\$isextrafieldmanaged = 0;/' =>
'$isextrafieldmanaged = 1;');
723if ($dirins && $action ==
'inithook' && !empty(
$module) ) {
725 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
726 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
728 $result =
dol_copy($srcfile, $destfile,
'0', 0);
734 $arrayreplacement = array(
736 'MyModule' => $modulename,
738 'My module' => $modulename,
739 'my module' => $modulename,
740 'Mon module' => $modulename,
741 'mon module' => $modulename,
743 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
749 $langs->load(
"errors");
750 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
756if ($dirins && $action ==
'inittrigger' && !empty(
$module) ) {
758 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
759 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
761 $result =
dol_copy($srcfile, $destfile,
'0', 0);
767 $arrayreplacement = array(
769 'MyModule' => $modulename,
771 'My module' => $modulename,
772 'my module' => $modulename,
773 'Mon module' => $modulename,
774 'mon module' => $modulename,
776 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
782 $langs->load(
"errors");
783 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
789if ($dirins && $action ==
'initwidget' && !empty(
$module) ) {
791 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
792 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
794 $result =
dol_copy($srcfile, $destfile,
'0', 0);
800 $arrayreplacement = array(
802 'MyModule' => $modulename,
804 'My module' => $modulename,
805 'my module' => $modulename,
806 'Mon module' => $modulename,
807 'mon module' => $modulename,
809 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
815 $langs->load(
"errors");
816 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
822if ($dirins && $action ==
'initemailing' && !empty(
$module) ) {
824 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
825 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
827 $result =
dol_copy($srcfile, $destfile,
'0', 0);
833 $arrayreplacement = array(
835 'MyModule' => $modulename,
837 'My module' => $modulename,
838 'my module' => $modulename,
839 'Mon module' => $modulename,
840 'mon module' => $modulename,
842 '---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 ==
'initcss' && !empty(
$module) ) {
857 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
858 $srcfile = $srcdir.
'/css/mymodule.css.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 ==
'initjs' && !empty(
$module) ) {
895 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
896 $srcfile = $srcdir.
'/js/mymodule.js.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 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
924 $langs->load(
"errors");
925 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
931if ($dirins && $action ==
'initcli' && !empty(
$module) ) {
933 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
934 $srcfile = $srcdir.
'/scripts/mymodule.php';
936 $result =
dol_copy($srcfile, $destfile,
'0', 0);
942 $arrayreplacement = array(
944 'MyModule' => $modulename,
946 'My module' => $modulename,
947 'my module' => $modulename,
948 'Mon module' => $modulename,
949 'mon module' => $modulename,
951 '__MYCOMPANY_NAME__' =>
$mysoc->name,
952 '__KEYWORDS__' => $modulename,
953 '__USER_FULLNAME__' => $user->getFullName($langs),
954 '__USER_EMAIL__' => $user->email,
956 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
962 $langs->load(
"errors");
963 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
968$moduledescriptorfile =
'/not_set/';
969$modulelowercase =
null;
972if ($dirins && $action ==
'initdoc' && !empty(
$module) ) {
974 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
975 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
977 $result =
dol_copy($srcfile, $destfile,
'0', 0);
984 $arrayreplacement = array(
986 'MyModule' => $modulename,
988 'My module' => $modulename,
989 'my module' => $modulename,
990 'Mon module' => $modulename,
991 'mon module' => $modulename,
993 '__MYCOMPANY_NAME__' =>
$mysoc->name,
994 '__KEYWORDS__' => $modulename,
995 '__USER_FULLNAME__' => $user->getFullName($langs),
996 '__USER_EMAIL__' => $user->email,
998 '---Replace with your own copyright and developer email---' =>
getLicenceHeader($user, $langs, $now)
1008 foreach ($objects as $path => $obj) {
1025 $string = file_get_contents($changeLog);
1027 $replace = explode(
"\n", $string);
1028 $strreplace = array();
1029 foreach ($replace as $line) {
1033 if (strpos($line,
'##') !==
false) {
1034 $strreplace[$line] = str_replace(
'##',
'', $line);
1036 $strreplace[$line] = $line;
1039 $stringLog = implode(
"\n", $strreplace);
1041 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
1045 $FILENAMEDOC = $modulelowercase.
'.html';
1046 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
1047 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
1048 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
1049 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
1050 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
1055 $langs->load(
"errors");
1056 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
1062if ($dirins && $action ==
'addlanguage' && !empty(
$module) ) {
1063 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
1071 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
1073 $diroflang = $dolibarr_main_document_root;
1075 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
1076 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
1078 $result =
dol_copy($srcfile, $destfile,
'0', 0);
1080 $langs->load(
"errors");
1081 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
1084 $srcdir = $diroflang.
'/langs/en_US';
1085 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
1086 $destdir = $diroflang.
'/langs/'.$newlangcode;
1088 $arrayofreplacement = array();
1090 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
1091 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
1093 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
1096 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
1102if ($dirins && $action ==
'confirm_removefile' && !empty(
$module) ) {
1103 $objectname = $tabobj;
1110 if ($relativefilename) {
1111 $dirnametodelete = dirname($relativefilename);
1112 $filetodelete = $dirins.
'/'.$relativefilename;
1113 $dirtodelete = $dirins.
'/'.$dirnametodelete;
1118 $keyofobjecttodelete = array_search($objectname, $objects);
1119 if ($keyofobjecttodelete !==
false) {
1120 unset($objects[$keyofobjecttodelete]);
1124 if (strpos($relativefilename,
'api') !==
false) {
1129 if (count($objects) == 0) {
1134 setEventMessages($langs->trans(
"ApiObjectDeleted"),
null);
1141 $langs->load(
"errors");
1142 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1145 if (preg_match(
'/\.sql$/', $relativefilename)) {
1146 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1147 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1148 $filetodelete = $dirins.
'/'.$relativefilename;
1150 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1151 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1152 $filetodelete = $dirins.
'/'.$relativefilename;
1162 if (in_array($tab, array(
'css',
'js'))) {
1164 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1168 if (preg_match(
'/_extrafields/', $relativefilename)) {
1171 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1176 $varnametoupdate =
'';
1178 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1179 $varnametoupdate =
'showtabofpage'.$reg[1];
1181 if ($varnametoupdate) {
1183 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1191if ($dirins && $action ==
'initobject' &&
$module && $objectname) {
1199 if (preg_match(
'/[^a-z0-9]/i', $objectname)) {
1201 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1202 $tabobj =
'newobject';
1204 if (class_exists($objectname)) {
1207 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1208 $tabobj =
'newobject';
1213 }
catch (\InvalidArgumentException $e) {
1215 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1219 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1228 $accesspolicy =
null;
1229 $copiedfiles = array();
1230 $accesspolicyalternatives = array();
1231 for ($i = 0; $i < AccessPolicyConfig::MAX_ALTERNATIVES; $i++) {
1232 $accesspolicyalternatives[] =
GETPOST(
'accesspolicy_'.$i,
'array:aZ09');
1236 }
catch (\InvalidArgumentException $e) {
1238 dol_syslog(
"modulebuilder: invalid access policy for object ".$objectname.
": ".$e->getMessage(), LOG_WARNING);
1239 setEventMessages($langs->trans(
"ErrorModuleBuilderInvalidAccessPolicy"),
null,
'errors');
1240 $tabobj =
'newobject';
1243 if (!$error && $objectalreadyexists) {
1244 $classfile = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
1247 if ($accesspolicy !==
null && ($storedaccesspolicy ===
null || $storedaccesspolicy->toJson() !== $accesspolicy->toJson())) {
1248 setEventMessages($langs->trans(
"WarningAccessPolicyOnRegeneration"),
null,
'warnings');
1250 $accesspolicy = $storedaccesspolicy;
1251 }
catch (\InvalidArgumentException $e) {
1253 dol_syslog(
"modulebuilder: invalid access policy stored in ".$classfile.
": ".$e->getMessage(), LOG_ERR);
1254 setEventMessages($langs->trans(
"ErrorModuleBuilderInvalidStoredAccessPolicy", basename($classfile)),
null,
'errors');
1255 $tabobj =
'newobject';
1270 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1271 $alreadyfound =
false;
1272 foreach ($dirlist as $key => $val) {
1273 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1275 $alreadyfound =
true;
1277 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1285 $stringforproperties =
'';
1286 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1288 $_results = $db->DDLDescTable($tablename);
1289 if (empty($_results)) {
1291 $langs->load(
"errors");
1292 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1341 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1342 $stringforproperties .=
'public $fields = array('.
"\n";
1344 while ($obj = $db->fetch_object($_results)) {
1346 $fieldname = $obj->Field;
1349 if ($type ==
'int(11)') {
1351 } elseif ($type ==
'float') {
1353 } elseif (strstr($type,
'tinyint')) {
1355 } elseif (strstr($type,
'url')) {
1356 $type =
'varchar(255)';
1357 } elseif ($obj->Field ==
'fk_soc') {
1358 $type =
'integer:Societe:societe/class/societe.class.php';
1359 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1360 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1361 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1362 $type =
'integer:Product:product/class/product.class.php:1';
1363 } elseif ($obj->Field ==
'fk_warehouse') {
1364 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1365 } elseif (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1366 $type =
'integer:User:user/class/user.class.php';
1370 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1371 if ($fieldname ==
'fk_user_modif') {
1375 $label = preg_replace(
'/_/',
'',
dol_ucfirst($fieldname));
1376 if ($fieldname ==
'rowid') {
1377 $label =
'TechnicalID';
1379 if ($fieldname ==
'import_key') {
1380 $label =
'ImportId';
1382 if ($fieldname ==
'fk_soc') {
1383 $label =
'ThirdParty';
1385 if (in_array($fieldname, array(
'tms',
'date_modification'))) {
1386 $label =
'DateModification';
1388 if (in_array($fieldname, array(
'datec',
'date_creation'))) {
1389 $label =
'DateCreation';
1391 if ($fieldname ==
'date_valid') {
1392 $label =
'DateValidation';
1394 if ($fieldname ==
'datev') {
1395 $label =
'DateValidation';
1397 if ($fieldname ==
'note_private') {
1398 $label =
'NotePublic';
1400 if ($fieldname ==
'note_public') {
1401 $label =
'NotePrivate';
1403 if ($fieldname ==
'fk_user_creat') {
1404 $label =
'UserAuthor';
1406 if ($fieldname ==
'fk_user_modif') {
1407 $label =
'UserModif';
1409 if ($fieldname ==
'fk_user_valid') {
1410 $label =
'UserValidation';
1414 if (in_array($fieldname, array(
'ref',
'label'))) {
1417 if ($fieldname ==
'entity') {
1420 if ($fieldname ==
'entity') {
1423 if ($fieldname ==
'import_key') {
1426 if ($fieldname ==
'fk_user_creat') {
1429 if ($fieldname ==
'fk_user_modif') {
1432 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1439 if ($fieldname ==
'entity') {
1444 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1447 if ($fieldname ==
'import_key') {
1451 $alwayseditable = 0;
1452 if ($fieldname ==
'label') {
1453 $alwayseditable = 1;
1455 $alwayseditable = 0;
1459 if ($fieldname ==
'entity') {
1466 if (preg_match(
'/^fk_/', $fieldname)) {
1467 $css =
'maxwidth500 widthcentpercentminusxx';
1469 if ($fieldname ==
'label') {
1470 $css =
'minwidth300';
1471 $cssview =
'wordbreak';
1473 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1474 $cssview =
'wordbreak';
1476 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1477 $csslist =
'tdoverflowmax150';
1482 if (isset($obj->Picto)) {
1483 $picto = $obj->Picto;
1485 if (preg_match(
'/^fk_soc/', $obj->Field)) {
1487 } elseif (preg_match(
'/^fk_contact/', $obj->Field)) {
1489 } elseif (preg_match(
'/^fk_bank/', $obj->Field)) {
1491 } elseif (preg_match(
'/^fk_user/', $obj->Field)) {
1493 } elseif (preg_match(
'/^fk_warehouse/', $obj->Field)) {
1494 $picto =
'warehouse';
1495 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1497 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1499 } elseif (preg_match(
'/^fk_task/', $obj->Field)) {
1507 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1508 if ($default !=
'') {
1509 $stringforproperties .=
" 'default' => ".$default.
",";
1511 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1512 $stringforproperties .=
" 'visible' => ".$visible;
1514 $stringforproperties .=
", 'notnull' => ".$notnull;
1516 if ($alwayseditable) {
1517 $stringforproperties .=
", 'alwayseditable' => 1";
1519 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1520 $stringforproperties .=
", 'showoncombobox' => 1";
1522 $stringforproperties .=
", 'position' => ".$position;
1524 $stringforproperties .=
", 'index' => ".$index;
1527 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1530 $stringforproperties .=
", 'css' => '".$css.
"'";
1533 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1536 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1539 $stringforproperties .=
", 'lang' => '".$lang.
"'";
1541 $stringforproperties .=
"),\n";
1544 $stringforproperties .=
');'.
"\n";
1545 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1552 $parameters = array(
'module' =>
$module,
'objectname' => $objectname,
'dirins' => $dirins,
'initfromtablename' => $tablename);
1553 $reshook = $hookmanager->executeHooks(
'getFieldsForNewObject', $parameters, $hookobject, $action);
1556 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1557 $tabobj =
'newobject';
1558 } elseif ($reshook > 0 && !empty($hookmanager->resArray[
'fields']) && is_array($hookmanager->resArray[
'fields'])) {
1560 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1561 $stringforproperties .=
'public $fields = '.var_export($hookmanager->resArray[
'fields'],
true).
';'.
"\n";
1562 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1566 $filetogenerate = array();
1569 $filetogenerate = [];
1571 'myobject_card.php',
1572 'myobject_note.php',
1573 'myobject_contact.php',
1574 'myobject_document.php',
1575 'myobject_agenda.php',
1576 'myobject_list.php',
1577 'admin/myobject_extrafields.php',
1578 'ajax/myobject.php',
1579 'lib/mymodule_myobject.lib.php',
1581 'sql/llx_mymodule_myobject.sql',
1582 'sql/llx_mymodule_myobject.key.sql',
1583 'sql/llx_mymodule_myobject_extrafields.sql',
1584 'sql/llx_mymodule_myobject_extrafields.key.sql',
1586 'class/myobject.class.php',
1587 'class/myobjectstats.class.php',
1589 'stats/myobject_index.php',
1590 ] as $templateFile) {
1591 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1596 if (!in_array($tabkey, $enabledtabs,
true)) {
1597 unset($filetogenerate[$tabinfo[
'file']]);
1601 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1605 'core/modules/mymodule/mod_myobject_advanced.php',
1606 'core/modules/mymodule/mod_myobject_standard.php',
1607 'core/modules/mymodule/modules_myobject.php',
1608 ] as $templateFile) {
1609 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1612 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1617 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php',
1618 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php',
1619 ] as $templateFile) {
1620 $filetogenerate[$templateFile] = $ncObj->applyToFilename($templateFile);
1624 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1625 $firstobjectname =
'myobject';
1628 $class =
'mod'.$module;
1630 if (class_exists($class)) {
1633 '@phan-var-force DolibarrModules $moduleobj';
1637 dol_print_error($db, $e->getMessage());
1645 $moduledescriptorfile = $destdir.
'/core/modules/mod'.
$module.
'.class.php';
1647 if ($checkComment < 0) {
1648 $langs->load(
"errors");
1649 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1652 if ($reportPerms->skipped > 0) {
1653 $langs->load(
"errors");
1654 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1660 foreach ($filetogenerate as $srcfile => $destfile) {
1661 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1663 $copiedfiles[$srcfile] = $destfile;
1668 $langs->load(
"errors");
1669 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1672 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1675 $arrayreplacement = array(
1676 '/myobject\.class\.php/' =>
dol_strtolower($objectname).
'.class.php',
1677 '/myobject\.lib\.php/' =>
dol_strtolower($objectname).
'.lib.php',
1680 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1685 if (!$error && $stringforproperties) {
1687 $arrayreplacement = array(
1688 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1695 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1697 $arrayreplacement = array(
1698 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1704 $arrayreplacement = array(
1705 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1711 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1713 $arrayreplacement = array(
1714 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1719 $arrayreplacement = array(
1720 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1730 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1732 $firstobjectname =
'';
1734 foreach ($listofobject as $fileobj) {
1735 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1738 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1742 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1744 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1745 $objectnameloop = $reg[1];
1746 if (empty($firstobjectname)) {
1747 $firstobjectname = $objectnameloop;
1753 \$this->menu[\$r++] = array(
1754 'fk_menu' => 'fk_mainmenu=mymodule',
1756 'titre' => 'MyObject',
1757 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1758 'mainmenu' => 'mymodule',
1759 'leftmenu' => 'myobject',
1760 'url' => '/mymodule/myobject_list.php',
1761 'langs' => 'mymodule@mymodule',
1762 'position' => 1000 + \$r,
1763 'enabled' => 'isModEnabled(\"mymodule\")',
1764 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1767 'object' => 'MyObject'
1769 \$this->menu[\$r++] = array(
1770 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1772 'titre' => 'List MyObject',
1773 'mainmenu' => 'mymodule',
1774 'leftmenu' => 'mymodule_myobject_list',
1775 'url' => '/mymodule/myobject_list.php',
1776 'langs' => 'mymodule@mymodule',
1777 'position' => 1000 + \$r,
1778 'enabled' => 'isModEnabled(\"mymodule\")',
1779 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1782 'object' => 'MyObject'
1784 \$this->menu[\$r++] = array(
1785 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1787 'titre' => 'New MyObject',
1788 'mainmenu' => 'mymodule',
1789 'leftmenu' => 'mymodule_myobject_new',
1790 'url' => '/mymodule/myobject_card.php?action=create',
1791 'langs' => 'mymodule@mymodule',
1792 'position' => 1000 + \$r,
1793 'enabled' => 'isModEnabled(\"mymodule\")',
1794 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1797 'object' => 'MyObject'
1799 $stringtoadd = $ncObj->applyTo($stringtoadd);
1801 $moduledescriptorfile = $destdir.
'/core/modules/mod'.
$module.
'.class.php';
1809 $class =
'mod'.$module;
1811 if (class_exists($class)) {
1814 '@phan-var-force DolibarrModules $moduleobj';
1818 dol_print_error($db, $e->getMessage());
1827 foreach ($menus as $menu) {
1834 if ($checkComment < 0) {
1836 $langs->load(
"errors");
1837 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1839 $arrayofreplacement = array(
1840 '/* 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 */'
1846 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1849 if (! $error &&
GETPOST(
'nogeneratelines',
'aZ09')) {
1851 if ($checkComment < 0) {
1853 $langs->load(
"errors");
1854 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1858 $destdir .
'/class/' .
dol_strtolower($objectname) .
'.class.php',
1865 foreach ($TFilePaths as $filePath) {
1878 $libdestfile = $destdir.
'/'.$ncObj->applyToFilename(
'lib/mymodule_myobject.lib.php');
1880 $marker = $tabinfo[
'marker'];
1881 if (in_array($tabkey, $enabledtabs,
true)) {
1882 $arrayreplacement = array(
1883 '/\$'.$tabinfo[
'var'].
' = getDolGlobalInt\([^;]*\);/' =>
'$'.$tabinfo[
'var'].
' = 1;'
1885 if (
dolReplaceInFile($libdestfile, $arrayreplacement,
'',
'0', 0, 1) < 0) {
1887 dol_syslog(
"modulebuilder: failed to activate tab flag '".$tabkey.
"' in ".$libdestfile, LOG_ERR);
1890 if (!
removePatternFromFile($libdestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TABFLAG '.$marker.
'.*?\/\/ END MODULEBUILDER TABFLAG '.$marker.
'\s*/s')
1891 || !
removePatternFromFile($libdestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TAB '.$marker.
'.*?\/\/ END MODULEBUILDER TAB '.$marker.
'\s*/s')) {
1893 dol_syslog(
"modulebuilder: failed to purge tab '".$tabkey.
"' in ".$libdestfile, LOG_ERR);
1897 $carddestfile = $destdir.
'/'.$ncObj->applyToFilename(
'myobject_card.php');
1900 if (!$error && !in_array(
'agenda', $enabledtabs,
true)) {
1901 if (!
removePatternFromFile($carddestfile,
'/\h*\/\/ BEGIN MODULEBUILDER TAB AGENDA.*?\/\/ END MODULEBUILDER TAB AGENDA\s*/s')) {
1903 dol_syslog(
"modulebuilder: failed to purge agenda widget in ".$carddestfile, LOG_ERR);
1911 if (!in_array($actionkey, $enabledcardactions,
true)) {
1914 dol_syslog(
"modulebuilder: failed to purge card action '".$actionkey.
"' in ".$carddestfile, LOG_ERR);
1916 } elseif ($actioninfo[
'mode'] ==
'activate') {
1920 dol_syslog(
"modulebuilder: failed to activate card action '".$actionkey.
"' in ".$carddestfile, LOG_ERR);
1931 $accesspolicytargets[
'class/myobject.class.php'] =
'class';
1932 foreach ($accesspolicytargets as $templatefile => $targettype) {
1933 if (!isset($copiedfiles[$templatefile])) {
1936 $targetfile = $destdir.
'/'.$copiedfiles[$templatefile];
1940 $langs->load(
"errors");
1941 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $targetfile),
null,
'errors');
1946 if ($objectalreadyexists) {
1947 setEventMessages($langs->trans(
"WarningTabSelectionOnRegeneration"),
null,
'warnings');
1948 setEventMessages($langs->trans(
"WarningCardActionSelectionOnRegeneration"),
null,
'warnings');
1954 foreach ($filetogenerate as $destfile) {
1955 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1962 $arrayreplacement = array_merge(
1963 $ncObj->getSubstitutionMap(),
1965 'htdocs/modulebuilder/template/' => $ncObj->moduleNameLower,
1966 '---Replace with your own copyright and developer email---' => $licenceValue,
1970 if (basename($phpfileval[
'fullname']) ===
'mod'.
$module.
'.class.php') {
1978 $langs->load(
"errors");
1979 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1986 if (!$error && $ncObj !==
null) {
1994 $moduleReplacementAll = array_merge(
1995 $ncObj->getSubstitutionMap(),
1997 'htdocs/modulebuilder/template/' => $ncObj->moduleNameLower,
1998 '---Replace with your own copyright and developer email---' => $licenceValueAll,
2001 $allModulePhpFiles =
dol_dir_list($destdir,
'files', 1,
'\.php$');
2005 $moduledescriptorbasename =
'mod'.$module.
'.class.php';
2006 if (is_array($allModulePhpFiles) && !empty($allModulePhpFiles)) {
2007 foreach ($allModulePhpFiles as $phpFileval) {
2008 if (basename($phpFileval[
'fullname']) === $moduledescriptorbasename) {
2011 $result =
dolReplaceInFile($phpFileval[
'fullname'], $moduleReplacementAll);
2013 $langs->load(
"errors");
2014 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpFileval[
'fullname']),
null,
'warnings');
2021 $destdir .
'/stats/myobject_index.php',
2022 $destdir .
'/lib/' . $moduleLowerForPlaceholder .
'_myobject.lib.php',
2023 ] as $placeholder) {
2024 if (file_exists($placeholder)) {
2035 if (is_numeric($object) && $object <= 0) {
2036 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2037 $langs->load(
"errors");
2038 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
2042 $file = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2043 $destfile = $destdir.
'/doc/Documentation.asciidoc';
2045 if (file_exists($destfile)) {
2049 if (!$error && $object !==
null) {
2054 $langs->load(
"errors");
2055 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null);
2061 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
2062 $tabobj = $objectname;
2064 $tabobj =
'newobject';
2072 setEventMessages($result,
null,
'errors');
2074 $langs->load(
"errors");
2075 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2076 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module);
2082if ($dirins && $action ==
'initdic' &&
$module && empty($cancel) ) {
2089 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
2093 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2096 $newdicname = $dicname;
2097 if (!preg_match(
'/^c_/', $newdicname)) {
2098 $newdicname =
'c_'.$dicname;
2101 $class =
'mod'.$module;
2104 if (class_exists($class)) {
2107 '@phan-var-force DolibarrModules $moduleobj';
2111 dol_print_error($db, $e->getMessage());
2117 $langs->load(
"errors");
2118 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2123 if ($checkComment < 0) {
2124 $langs->load(
"errors");
2125 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2128 if (function_exists(
'opcache_invalidate')) {
2131 clearstatcache(
true);
2132 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2139if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty(
$module) && !empty($tabobj) ) {
2140 $objectname = $tabobj;
2142 $arrayoftables = array();
2143 if ($action ==
'droptable') {
2146 if ($action ==
'droptableextrafields') {
2147 $arrayoftables[] = MAIN_DB_PREFIX.dol_strtolower(
$module).
'_'.
dol_strtolower($tabobj).
'_extrafields';
2150 foreach ($arrayoftables as $tabletodrop) {
2152 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
2153 $resql = $db->query($sql);
2155 $obj = $db->fetch_object($resql);
2157 $nb = (int) $obj->nb;
2160 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
2161 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
2163 dol_print_error($db);
2167 $resql = $db->DDLDropTable($tabletodrop);
2169 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
2170 } elseif ($nb > 0) {
2171 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
2176if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty(
$module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) ) {
2189 if (!in_array($objectname, array_values($objects))) {
2191 $langs->load(
"errors");
2192 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
2195 $addfieldentry = array();
2198 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
2199 if (!
GETPOST(
'propname',
'aZ09')) {
2201 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
2203 if (!
GETPOST(
'proplabel',
'alpha')) {
2205 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2207 if (!
GETPOST(
'proptype',
'alpha')) {
2209 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2213 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
2217 $proptype =
GETPOST(
'proptype',
'alpha');
2218 if (strpos($proptype,
':') ===
false && strpos($proptype,
'_') ===
false) {
2221 $addfieldentry = array(
2222 'name' =>
GETPOST(
'propname',
'aZ09'),
2223 'label' =>
GETPOST(
'proplabel',
'alpha'),
2224 'type' => $proptype,
2225 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'nohtml'),
2226 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
2227 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
2231 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
2233 'isameasure' =>
GETPOSTINT(
'propisameasure'),
2234 'showoncombobox' =>
GETPOSTINT(
'propshowoncombobox'),
2235 'comment' =>
GETPOST(
'propcomment',
'alpha'),
2236 'help' =>
GETPOST(
'prophelp',
'alpha'),
2237 'css' =>
GETPOST(
'propcss',
'alpha'),
2238 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
2239 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
2240 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
2241 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
2246 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
2247 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
2249 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
2252 $addfieldentry[
'arrayofkeyval'] = $tmparray;
2271 if (is_numeric($object) && $object <= 0) {
2272 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2273 $langs->load(
"errors");
2274 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
2280 if (!$error && $object !==
null) {
2284 $langs->load(
"errors");
2285 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
2291 clearstatcache(
true);
2293 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
2295 setEventMessages($langs->trans(
'WarningDatabaseIsNotUpdated'),
null);
2298 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.
dol_now());
2303if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey ) {
2304 $objectname = $tabobj;
2318 if (is_numeric($object) && $object <= 0) {
2319 $pathoffiletoeditsrc = $destdir.
'/class/'.
dol_strtolower($objectname).
'.class.php';
2320 $langs->load(
"errors");
2321 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
2327 if (!$error && $object !==
null) {
2331 $langs->load(
"errors");
2332 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
2338 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
2340 clearstatcache(
true);
2343 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
2348if ($dirins && $action ==
'confirm_deletemodule' ) {
2349 if (preg_match(
'/[^a-z0-9_]/i',
$module)) {
2351 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2358 $dir = $dirins.
'/'.$modulelowercase;
2370 $class =
'mod'.$module;
2374 if (class_exists($class)) {
2377 '@phan-var-force DolibarrModules $moduleobj';
2381 dol_print_error($db, $e->getMessage());
2385 $langs->load(
"errors");
2386 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module),
null,
'warnings');
2396 setEventMessages($langs->trans(
"DirWasRemoved", $modulelowercase),
null);
2398 clearstatcache(
true);
2399 if (function_exists(
'opcache_invalidate')) {
2403 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2406 setEventMessages($langs->trans(
"PurgeNothingToDelete"),
null,
'warnings');
2414if ($dirins && $action ==
'confirm_deleteobject' && $objectname ) {
2415 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2417 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2425 $dir = $dirins.
'/'.$modulelowercase;
2430 }
catch (\InvalidArgumentException $e) {
2432 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2436 if (!$error && $ncObjDel !==
null) {
2438 'myobject_card.php',
2439 'myobject_note.php',
2440 'myobject_contact.php',
2441 'myobject_document.php',
2442 'myobject_agenda.php',
2443 'myobject_list.php',
2444 'admin/myobject_extrafields.php',
2445 'lib/mymodule_myobject.lib.php',
2446 'sql/llx_mymodule_myobject.sql',
2447 'sql/llx_mymodule_myobject_extrafields.sql',
2448 'sql/llx_mymodule_myobject.key.sql',
2449 'sql/llx_mymodule_myobject_extrafields.key.sql',
2450 'scripts/myobject.php',
2451 'class/myobject.class.php',
2452 'class/myobjectstats.class.php',
2453 'core/modules/mymodule/mod_myobject_advanced.php',
2454 'core/modules/mymodule/mod_myobject_standard.php',
2455 'core/modules/mymodule/modules_myobject.php',
2456 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php',
2457 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php',
2458 'stats/myobject_index.php',
2459 ] as $templateFile) {
2460 $filetodelete[$templateFile] = $ncObjDel->applyToFilename($templateFile);
2463 $filetodelete[
'ajax/myobject.lib.php'] =
'ajax/' . $ncObjDel->objectNameLower .
'.php';
2464 $filetodelete[
'test/phpunit/MyObjectTest.php'] =
'test/phpunit/' . $ncObjDel->objectNameLower .
'Test.php';
2465 $filetodelete[
'class/api_myobject.class.php'] =
'class/api_' . $ncObjDel->moduleNameLower .
'.class.php';
2472 $class =
'mod'.$module;
2474 if (class_exists($class)) {
2477 '@phan-var-force DolibarrModules $moduleobj';
2481 dol_print_error($db, $e->getMessage());
2485 $langs->load(
"errors");
2486 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2495 if ($rewriteMenu < 0) {
2496 $langs->load(
"errors");
2497 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2499 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2505 if ($rewritePerms < 0) {
2506 $langs->load(
"errors");
2507 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2513 if ($rewritePerms && $rewriteMenu) {
2518 clearstatcache(
true);
2519 if (function_exists(
'opcache_invalidate')) {
2523 foreach ($filetodelete as $tmpfiletodelete) {
2525 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 1, 0, 1);
2531 if ($resultko == 0) {
2532 setEventMessages($langs->trans(
"FilesDeleted"),
null);
2534 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2541 $tabobj =
'newobject';
2543 $tabobj =
'deleteobject';
2551 setEventMessages($result,
null,
'errors');
2553 $langs->load(
"errors");
2554 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2555 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode(
$module));
2560if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) ) {
2565 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2567 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2570 if (!empty($dicname)) {
2571 $newdicname = $dicname;
2572 if (!preg_match(
'/^c_/', $newdicname)) {
2573 $newdicname =
'c_'.dol_strtolower($dicname);
2580 $class =
'mod'.$module;
2583 if (class_exists($class)) {
2586 '@phan-var-force DolibarrModules $moduleobj';
2590 dol_print_error($db, $e->getMessage());
2596 $langs->load(
"errors");
2597 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2603 if ($checkComment < 0) {
2605 $langs->load(
"errors");
2606 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2609 if (!empty(
GETPOST(
'dictionnarykey'))) {
2610 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2614 $checkTable =
false;
2615 if ($newdicname !==
null) {
2616 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.dol_strtolower($newdicname));
2619 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2624 $keyToDelete =
null;
2625 foreach ($dicts[
'tabname'] as $key => $table) {
2628 $keyToDelete = $key;
2633 if ($keyToDelete !==
null) {
2634 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2635 foreach ($keysToDelete as $key) {
2636 unset($dicts[$key][$keyToDelete]);
2640 $langs->load(
"errors");
2641 setEventMessages($langs->trans(
"ErrorDictionaryNotFound",
dol_ucfirst($dicname)),
null,
'errors');
2643 if (!$error && $newdicname !==
null) {
2645 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.dol_strtolower($newdicname));
2646 if ($_results < 0) {
2647 dol_print_error($db);
2648 $langs->load(
"errors");
2649 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2654 setEventMessages($langs->trans(
"DictionaryDeleted",
dol_ucfirst(
dol_substr($newdicname, 2))),
null);
2656 if (function_exists(
'opcache_invalidate')) {
2659 clearstatcache(
true);
2660 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2664if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') ) {
2665 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2671 $class =
'mod'.$module;
2674 if (class_exists($class)) {
2677 '@phan-var-force DolibarrModules $moduleobj';
2681 dol_print_error($db, $e->getMessage());
2687 $langs->load(
"errors");
2688 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2693 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2696 if ($checkComment < 0) {
2697 $langs->load(
"errors");
2698 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2701 if ($updateDict > 0) {
2702 setEventMessages($langs->trans(
"DictionaryNameUpdated",
dol_ucfirst(
GETPOST(
'tablib'))),
null);
2704 if (function_exists(
'opcache_invalidate')) {
2707 clearstatcache(
true);
2708 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
''));
2714if ($dirins && $action ==
'generatedoc' ) {
2722 $util =
new Utils($db);
2723 $result = $util->generateDoc(
$module);
2726 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2728 setEventMessages($util->error, $util->errors,
'errors');
2732if ($dirins && $action ==
'generatepackage' ) {
2745 $class =
'mod'.$module;
2748 if (class_exists($class)) {
2751 '@phan-var-force DolibarrModules $moduleobj';
2755 dol_print_error($db, $e->getMessage());
2761 $langs->load(
"errors");
2762 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
2766 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2767 if (count($arrayversion)) {
2768 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2771 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2777 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2780 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2783 $langs->load(
"errors");
2784 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2788 $langs->load(
"errors");
2789 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2794if ($dirins && $action ==
'addright' && !empty(
$module) && empty($cancel) ) {
2800 $class =
'mod'.$module;
2802 if (class_exists($class)) {
2805 '@phan-var-force DolibarrModules $moduleobj';
2809 dol_print_error($db, $e->getMessage());
2814 if (!
GETPOST(
'label',
'alpha')) {
2816 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2818 if (!
GETPOST(
'permissionObj',
'alpha')) {
2820 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2823 $label =
GETPOST(
'label',
'alpha');
2825 $crud =
GETPOST(
'crud',
'alpha');
2829 $permsForObject = array();
2833 $permissions = array();
2835 $allObject = array();
2837 $countPerms = count($permissions);
2839 for ($i = 0; $i < $countPerms; $i++) {
2840 if ($permissions[$i][4] == $objectForPerms) {
2842 if (count($permsForObject) < 3) {
2843 $permsForObject[] = $permissions[$i];
2846 $allObject[] = $permissions[$i][4];
2850 $countPermsObj = count($permsForObject);
2851 for ($j = 0; $j < $countPermsObj; $j++) {
2852 if (in_array($crud, $permsForObject[$j])) {
2854 $langs->load(
"errors");
2855 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2864 setEventMessages($result,
null,
'errors');
2866 $langs->load(
"errors");
2867 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
2874 $langs->load(
"errors");
2875 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2878 if (!$reportPerms->hasConflicts()) {
2879 setEventMessages($langs->trans(
'PermissionAddedSuccesfuly'),
null);
2881 clearstatcache(
true);
2882 if (function_exists(
'opcache_invalidate')) {
2885 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
2894if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) ) {
2899 $class =
'mod'.$module;
2901 if (class_exists($class)) {
2904 '@phan-var-force DolibarrModules $moduleobj';
2908 dol_print_error($db, $e->getMessage());
2912 if (!
GETPOST(
'label',
'alpha')) {
2914 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2916 if (!
GETPOST(
'permissionObj',
'alpha')) {
2918 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2921 $label =
GETPOST(
'label',
'alpha');
2923 $crud =
GETPOST(
'crud',
'alpha');
2926 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2930 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2934 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2946 if (array_key_exists($key, $permissions)) {
2947 $x1 = $permissions[$key][1];
2948 $x2 = $permissions[$key][4];
2949 $x3 = $permissions[$key][5];
2957 $permsForObject = array();
2961 $allObject = array();
2963 $countPerms = count($permissions);
2964 for ($i = 0; $i < $countPerms; $i++) {
2965 if ($permissions[$i][4] == $objectForPerms) {
2967 if (count($permsForObject) < 3) {
2968 $permsForObject[] = $permissions[$i];
2971 $allObject[] = $permissions[$i][4];
2974 if ($label != $x1 && $crud != $x3) {
2975 $countPermsObj = count($permsForObject);
2976 for ($j = 0; $j < $countPermsObj; $j++) {
2977 if (in_array($label, $permsForObject[$j])) {
2979 $langs->load(
"errors");
2980 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2990 setEventMessages($result,
null,
'errors');
2992 $langs->load(
"errors");
2993 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3000 $langs->load(
"errors");
3001 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
3004 if (!$reportPerms->hasConflicts()) {
3005 setEventMessages($langs->trans(
'PermissionUpdatedSuccesfuly'),
null);
3006 clearstatcache(
true);
3007 if (function_exists(
'opcache_invalidate')) {
3010 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
3017if ($dirins && $action ==
'confirm_deleteright' && !empty(
$module) &&
GETPOSTINT(
'permskey') ) {
3022 $class =
'mod'.$module;
3024 if (class_exists($class)) {
3027 '@phan-var-force DolibarrModules $moduleobj';
3031 dol_print_error($db, $e->getMessage());
3044 setEventMessages($result,
null,
'errors');
3046 $langs->load(
"errors");
3047 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3048 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
3056 $langs->load(
"errors");
3057 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
3060 if (!$reportPerms->hasConflicts()) {
3061 setEventMessages($langs->trans(
'PermissionDeletedSuccesfuly'),
null);
3063 clearstatcache(
true);
3064 if (function_exists(
'opcache_invalidate')) {
3068 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.
$module);
3075if ($action ==
'savefile' && empty($cancel) ) {
3076 $relofcustom = basename($dirins);
3080 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
3081 $file = $relofcustom.
'/'.$file;
3089 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
3092 $check =
'restricthtml';
3094 if ($srclang ==
'md') {
3095 $check =
'restricthtml';
3097 if ($srclang ==
'lang') {
3098 $check =
'restricthtml';
3100 if ($srclang ==
'php') {
3104 $content =
GETPOST(
'editfilecontent', $check);
3109 $result = file_put_contents($pathoffile, $content);
3113 setEventMessages($langs->trans(
"FileSaved"),
null);
3115 setEventMessages($langs->trans(
"ErrorFailedToSaveFile"),
null,
'errors');
3118 setEventMessages($langs->trans(
"ContentCantBeEmpty"),
null,
'errors');
3126if ($action ==
'set' && $user->admin ) {
3129 $param .=
'&module='.urlencode(
$module);
3132 $param .=
'&tab='.urlencode($tab);
3133 $param .=
'&tabobj='.urlencode($tabobj);
3135 $value =
GETPOST(
'value',
'alpha');
3136 $resarray = activateModule($value, 1, 0);
3137 if (!empty($resarray[
'errors'])) {
3138 setEventMessages(
'', $resarray[
'errors'],
'errors');
3141 if ($resarray[
'nbperms'] > 0) {
3142 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
3143 $resqltmp = $db->query($tmpsql);
3145 $obj = $db->fetch_object($resqltmp);
3147 if ($obj && $obj->nb > 1) {
3148 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
3149 setEventMessages($msg,
null,
'warnings');
3152 dol_print_error($db);
3156 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
3161if ($action ==
'reset' && $user->admin ) {
3164 $param .=
'&module='.urlencode(
$module);
3166 $param .=
'&tab='.urlencode($tab);
3167 $param .=
'&tabobj='.urlencode($tabobj);
3169 $value =
GETPOST(
'value',
'alpha');
3172 setEventMessages($result,
null,
'errors');
3174 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
3179if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') ) {
3185 setEventMessages($result,
null,
'errors');
3187 $langs->load(
"errors");
3188 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3189 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3195 $class =
'mod'.$module;
3197 if (class_exists($class)) {
3200 '@phan-var-force DolibarrModules $moduleobj';
3204 dol_print_error($db, $e->getMessage());
3211 $result = array_map(
'dol_strtolower', $objects);
3218 if ($checkcomment < 0) {
3219 $langs->load(
"errors");
3220 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3223 if (in_array(
dol_strtolower($menus[$key][
'leftmenu']), $result)) {
3224 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
3232 clearstatcache(
true);
3233 if (function_exists(
'opcache_invalidate')) {
3237 setEventMessages($langs->trans(
'MenuDeletedSuccessfuly'),
null);
3238 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3244if ($dirins && $action ==
'addmenu' && empty($cancel) ) {
3250 setEventMessages($result,
null,
'errors');
3252 $langs->load(
"errors");
3253 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3254 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3262 $class =
'mod'.$module;
3264 if (class_exists($class)) {
3267 '@phan-var-force DolibarrModules $moduleobj';
3271 dol_print_error($db, $e->getMessage());
3278 if (!
GETPOST(
'type',
'alpha')) {
3280 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
3282 if (!
GETPOST(
'titre',
'alpha')) {
3284 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
3286 if (!
GETPOST(
'user',
'alpha')) {
3288 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
3290 if (!
GETPOST(
'url',
'alpha')) {
3292 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
3294 if (!empty(
GETPOST(
'target'))) {
3295 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
3296 if (!in_array(
GETPOST(
'target'), $targets)) {
3298 $langs->load(
"errors");
3299 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
3306 foreach ($menus as $menu) {
3309 $langs->load(
"errors");
3310 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
3315 $langs->load(
"errors");
3316 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
3321 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
3324 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
3331 if (
GETPOST(
'type',
'alpha') ==
'left') {
3332 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
3334 $langs->load(
"errors");
3335 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
3338 if (
GETPOST(
'type',
'alpha') ==
'top') {
3340 $langs->load(
"errors");
3341 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3348 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3349 'type' =>
GETPOST(
'type',
'alpha'),
3352 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3353 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
3354 'url' =>
GETPOST(
'url',
'alpha'),
3357 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3359 'target' =>
GETPOST(
'target',
'alpha'),
3363 if (
GETPOST(
'type') ==
'left') {
3364 unset($menuToAdd[
'prefix']);
3365 if (empty(
GETPOST(
'fk_menu'))) {
3366 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
3368 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3371 if (
GETPOST(
'enabled') ==
'1') {
3372 $menuToAdd[
'enabled'] =
'isModEnabled("'.dol_strtolower(
$module).
'")';
3374 $menuToAdd[
'enabled'] =
"0";
3376 if (empty(
GETPOST(
'objects'))) {
3377 $menuToAdd[
'perms'] =
'1';
3381 if ($checkcomment < 0) {
3382 $langs->load(
"errors");
3383 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3386 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
3388 clearstatcache(
true);
3389 if (function_exists(
'opcache_invalidate')) {
3398 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3399 setEventMessages($langs->trans(
'MenuAddedSuccesfuly'),
null);
3406if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') ) {
3407 $objectname =
GETPOST(
'tabobj');
3412 if (empty($cancel)) {
3417 setEventMessages($result,
null,
'errors');
3419 $langs->load(
"errors");
3420 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3421 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3428 $class =
'mod'.$module;
3430 if (class_exists($class)) {
3433 '@phan-var-force DolibarrModules $moduleobj';
3437 dol_print_error($db, $e->getMessage());
3445 $menuModify = array(
3446 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3447 'type' =>
GETPOST(
'type',
'alpha'),
3450 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3451 'leftmenu' => $menus[$key][
'leftmenu'],
3452 'url' =>
GETPOST(
'url',
'alpha'),
3455 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3456 'perms' =>
GETPOST(
'perms',
'alpha'),
3457 'target' =>
GETPOST(
'target',
'alpha'),
3460 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3461 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3462 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3463 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3465 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3467 if ($menuModify[
'enabled'] ===
'') {
3468 $menuModify[
'enabled'] =
'1';
3470 if ($menuModify[
'perms'] ===
'') {
3471 $menuModify[
'perms'] =
'1';
3474 if (
GETPOST(
'type',
'alpha') ==
'top') {
3476 $langs->load(
"errors");
3477 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3484 if ($checkComment < 0) {
3485 $langs->load(
"errors");
3486 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3489 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3491 clearstatcache(
true);
3492 if (function_exists(
'opcache_invalidate')) {
3497 $langs->load(
"errors");
3498 setEventMessages($langs->trans(
'ErrorMenuExistValue'),
null,
'errors');
3500 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));
3504 setEventMessages($langs->trans(
'MenuUpdatedSuccessfuly'),
null);
3505 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3510 $_POST[
'type'] =
'';
3511 $_POST[
'titre'] =
'';
3512 $_POST[
'fk_menu'] =
'';
3513 $_POST[
'leftmenu'] =
'';
3519if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) ) {
3524 setEventMessages($result,
null,
'errors');
3526 $langs->load(
"errors");
3527 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities(
$module)),
null,
'warnings');
3528 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.
$module);
3537 $class =
'mod'.$module;
3539 if (class_exists($class)) {
3542 '@phan-var-force DolibarrModules $moduleobj';
3546 dol_print_error($db, $e->getMessage());
3550 $keydescription =
GETPOST(
'keydescription',
'alpha');
3551 switch ($keydescription) {
3553 $propertyToUpdate =
'description';
3560 $propertyToUpdate = $keydescription;
3563 $error =
GETPOST(
'keydescription');
3567 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3568 $newValue =
GETPOST(
'propsmodule');
3569 $patternToFindLine =
'^\s*\$this->'.$propertyToUpdate.
'\s*=';
3570 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3572 $fileLines = file($moduledescriptorfile);
3575 foreach ($fileLines as &$line) {
3576 if (preg_match(
'/'.$patternToFindLine.
'/', $line)) {
3577 $result =
dolReplaceInFile($moduledescriptorfile, array($line => $newLine));
3580 } elseif ($result <= -1) {
3581 $langs->load(
"errors");
3582 setEventMessages($langs->trans(
'ErrorFailToEditFile', $moduledescriptorfile),
null,
'warnings');
3590 if ($changedone && $propertyToUpdate ===
'version') {
3594 clearstatcache(
true);
3595 if (function_exists(
'opcache_invalidate')) {
3599 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3601 setEventMessages($langs->trans(
'NothingProcessed'),
null,
'warnings');
3604 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.
$module);
3614$form =
new Form($db);
3625 '/includes/ace/src/ace.js',
3626 '/includes/ace/src/ext-statusbar.js',
3627 '/includes/ace/src/ext-language_tools.js',
3632llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3635$text = $langs->trans(
"ModuleBuilder");
3637$morehtmlright =
'<a href="'.DOL_URL_ROOT.
'/admin/tools/ui/index.php" target="_blank" rel="noopener">'.img_picto(
'',
'book',
'class="pictofixedwidth"').$langs->trans(
"UxComponentsDoc").
'</a>';
3641print
'<div class="info hideonsmartphone">';
3642print $langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development').
'</span>';
3648 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3653 $langs->load(
"errors");
3654 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3658 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3667$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3671$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3672$allowonlineinstall =
true;
3673if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3674 $allowonlineinstall =
false;
3676if (empty($allowonlineinstall)) {
3679 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3682 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3699 $loadclasserrormessage =
'';
3709 $class =
'mod'.$module;
3710 }
catch (Throwable $e) {
3711 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3712 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3713 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3717 if (class_exists($class)) {
3720 '@phan-var-force DolibarrModules $moduleobj';
3724 print $e->getMessage();
3727 if (empty($forceddirread)) {
3730 $langs->load(
"errors");
3731 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3732 $langs->load(
"errors");
3733 print img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module).
'<br>';
3734 print $loadclasserrormessage;
3744$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3745$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3746$head[$h][2] =
'initmodule';
3749$linktoenabledisable =
'';
3751if ( count($listofmodules) > 0) {
3757 $param .=
'&module='.urlencode(
$module);
3760 $param .=
'&tab='.urlencode($tab);
3761 $param .=
'&tabobj='.urlencode($tabobj);
3763 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode(
$module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3767 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.
$module.$param.
'">';
3768 $linktoenabledisable .= img_picto($langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"),
'switch_on',
'', 0, 0, 0,
'',
'warning valignmiddle', 1);
3769 $linktoenabledisable .=
'</a>';
3774 $backtourlparam =
'';
3775 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.
$module;
3776 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3777 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3780 if (is_array($objMod->config_page_url)) {
3782 foreach ($objMod->config_page_url as $page) {
3785 $linktoenabledisable .=
' <a class="valignmiddle" href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.img_picto(
dol_ucfirst($page),
"setup").
'</a>';
3788 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3789 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3790 $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>';
3794 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3795 $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>';
3799 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3800 $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>';
3804 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.
$module.$param.
'">';
3805 $linktoenabledisable .= img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip valignmiddle', 1);
3806 $linktoenabledisable .=
"</a>\n";
3811 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3812 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3813 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3814 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3816 if ($tmpmodulearray[
'modulenamewithcase'] ==
$module) {
3817 $head[$h][4] =
'<span class="inline-block valignmiddle">'.$linktoenabledisable.
'</span>';
3824$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3825$head[$h][1] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3826$head[$h][2] =
'deletemodule';
3834 print
'<!-- section init module -->'.
"\n";
3835 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3836 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3837 print
'<input type="hidden" name="action" value="initmodule">';
3838 print
'<input type="hidden" name="module" value="initmodule">';
3843 print
'<div class="tagtable table-border">';
3845 print
'<div class="tagtr"><div class="tagtd paddingright">';
3846 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3847 print
'</div><div class="tagtd">';
3848 print
'<input type="number" min="100000" name="idmodule" class="width100" value="500000">';
3849 print
'<span class="opacitymedium small">';
3850 print
' ';
3851 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info&hidetitle=1',
'',
'');
3853 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3855 print
'</div></div>';
3857 print
'<div class="tagtr"><div class="tagtd paddingright">';
3858 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3859 print
'</div><div class="tagtd">';
3860 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3861 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3862 print
'</div></div>';
3864 print
'<div class="tagtr"><div class="tagtd paddingright">';
3865 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3866 print
'</div><div class="tagtd">';
3867 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3868 print
'</div></div>';
3870 print
'<div class="tagtr"><div class="tagtd paddingright">';
3871 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3872 print
'</div><div class="tagtd">';
3873 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")).
'">';
3874 print
'</div></div>';
3876 print
'<div class="tagtr"><div class="tagtd paddingright">';
3877 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3878 print
'</div><div class="tagtd">';
3879 print
'<select name="family" id="family" class="minwidth400">';
3880 $arrayoffamilies = array(
3881 'hr' =>
"ModuleFamilyHr",
3882 'crm' =>
"ModuleFamilyCrm",
3883 'srm' =>
"ModuleFamilySrm",
3884 'financial' =>
'ModuleFamilyFinancial',
3885 'products' =>
'ModuleFamilyProducts',
3886 'projects' =>
'ModuleFamilyProjects',
3887 'ecm' =>
'ModuleFamilyECM',
3888 'technic' =>
'ModuleFamilyTechnic',
3889 'portal' =>
'ModuleFamilyPortal',
3890 'interface' =>
'ModuleFamilyInterface',
3891 'base' =>
'ModuleFamilyBase',
3892 'other' =>
'ModuleFamilyOther'
3894 foreach ($arrayoffamilies as $key => $value) {
3895 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>';
3899 print
'</div></div>';
3901 print
'<div class="tagtr"><div class="tagtd paddingright">';
3902 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3903 print
'</div><div class="tagtd">';
3904 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3905 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3907 print
' ';
3909 print
'<span class="opacitymedium small">';
3910 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',
'',
'');
3913 print
'</div></div>';
3915 print
'<div class="tagtr"><div class="tagtd paddingright">';
3916 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3917 print
'</div><div class="tagtd">';
3918 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>';
3919 print
'</div></div>';
3921 print
'<div class="tagtr"><div class="tagtd paddingright">';
3922 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3923 print
'</div><div class="tagtd">';
3924 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>';
3925 print
'</div></div>';
3929 print
'<br><center>';
3930 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3933} elseif (
$module ==
'deletemodule') {
3934 print
'<!-- Form to init a module -->'.
"\n";
3935 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3936 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3937 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3938 print
'<input type="hidden" name="module" value="deletemodule">';
3940 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3942 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3943 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3945} elseif (!empty(
$module) && $modulelowercase !==
null) {
3953 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3967 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3968 $head2[$h][1] = $langs->trans(
"Description");
3969 $head2[$h][2] =
'description';
3972 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3973 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3974 $head2[$h][2] =
'objects';
3977 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3978 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3979 $head2[$h][2] =
'languages';
3982 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3983 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3984 $head2[$h][2] =
'permissions';
3987 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3988 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3989 $head2[$h][2] =
'dictionaries';
3992 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3993 $head2[$h][1] = $langs->trans(
"Tabs");
3994 $head2[$h][2] =
'tabs';
3997 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
3998 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3999 $head2[$h][2] =
'menus';
4002 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4003 $head2[$h][1] = $langs->trans(
"Hooks");
4004 $head2[$h][2] =
'hooks';
4007 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4008 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
4009 $head2[$h][2] =
'triggers';
4012 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4013 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
4014 $head2[$h][2] =
'widgets';
4017 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4018 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
4019 $head2[$h][2] =
'emailings';
4022 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4023 $head2[$h][1] = $langs->trans(
"ImportExportProfiles");
4024 $head2[$h][2] =
'exportimport';
4027 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4028 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
4029 $head2[$h][2] =
'css';
4032 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4033 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
4034 $head2[$h][2] =
'js';
4037 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4038 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
4039 $head2[$h][2] =
'cli';
4042 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4043 $head2[$h][1] = $langs->trans(
"CronList");
4044 $head2[$h][2] =
'cron';
4047 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4048 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="marginleftonlyshort badge">'.$hasDoc.
"</span>");
4049 $head2[$h][2] =
'specifications';
4052 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.
$module.($forceddirread ?
'@'.$dirread :
'');
4053 $head2[$h][1] = $langs->trans(
"BuildPackage");
4054 $head2[$h][2] =
'buildpackage';
4057 $MAXTABFOROBJECT = 12;
4059 print
'<!-- Section for a given module -->';
4063 if ($tab ==
'description') {
4064 print
'<!-- tab=description -->'.
"\n";
4066 $pathtofilereadme = $modulelowercase.
'/README.md';
4067 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
4068 $pathtoindex = $modulelowercase.
'/'.$modulelowercase.
'index.php';
4070 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
4072 if ($action !=
'editfile' || empty($file)) {
4073 $morehtmlright =
'';
4074 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
4075 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
4078 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
4080 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
4086 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4087 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>';
4090 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"Index").
' : <strong class="wordbreak">'.$pathtoindex.
'</strong>';
4091 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>';
4095 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
4096 foreach ($listofsetuppages as $setuppage) {
4099 if (preg_match(
'/^([a-z]+)_extrafields.php/', $setuppage[
'relativename'], $reg)) {
4101 $fileofclass = $realpathofmodule.
'/class/'.$reg[1].
'.class.php';
4102 if (is_readable($fileofclass) && !preg_match(
'/public\s+\$isextrafieldmanaged\s+=\s+1/', file_get_contents($fileofclass))) {
4109 print
'<span class="fa fa-file"></span> ';
4110 if ($setuppage[
'relativename'] ==
'about.php') {
4111 print $langs->trans(
"AboutFile");
4113 print $langs->trans(
"SetupFile");
4116 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
4117 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>';
4121 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
4122 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>';
4125 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
4126 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>';
4132 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
4135 print
'<div class="underbanner clearboth"></div>';
4136 print
'<div class="fichecenter">';
4137 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4138 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4139 print
'<input type="hidden" name="action" value="update_props_module">';
4140 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4141 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
4142 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
4144 print
'<div class="div-table-responsive-no-min">';
4145 print
'<table class="border centpercent">';
4146 print
'<tr class="liste_titre"><td class="titlefield">';
4147 print $langs->trans(
"Parameter");
4149 print $langs->trans(
"Value");
4153 print $langs->trans(
"IdModule");
4156 print
'<span class="opacitymedium">';
4158 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
4159 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
4164 print $langs->trans(
"ModuleName");
4170 print $langs->trans(
"Description");
4172 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
4173 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'" spellcheck="false">';
4174 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
4175 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4178 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>';
4180 $moduledescritpionautotrans =
$moduleobj->getDesc();
4181 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
4183 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
4184 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
4186 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
4192 print $langs->trans(
"Version");
4194 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
4195 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
4196 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
4197 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4200 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>';
4205 print $langs->trans(
"Family");
4208 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
4209 print
'<select name="propsmodule" id="family" class="minwidth400">';
4210 $arrayoffamilies = array(
4211 'hr' =>
"ModuleFamilyHr",
4212 'crm' =>
"ModuleFamilyCrm",
4213 'srm' =>
"ModuleFamilySrm",
4214 'financial' =>
'ModuleFamilyFinancial',
4215 'products' =>
'ModuleFamilyProducts',
4216 'projects' =>
'ModuleFamilyProjects',
4217 'ecm' =>
'ModuleFamilyECM',
4218 'technic' =>
'ModuleFamilyTechnic',
4219 'portal' =>
'ModuleFamilyPortal',
4220 'interface' =>
'ModuleFamilyInterface',
4221 'base' =>
'ModuleFamilyBase',
4222 'other' =>
'ModuleFamilyOther'
4224 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>';
4225 foreach ($arrayoffamilies as $key => $value) {
4227 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
4231 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
4232 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4235 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>';
4239 print
'<!-- picto of module -->'.
"\n";
4241 print $langs->trans(
"Picto");
4243 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
4244 print
'<input class="minwidth200 maxwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'" spellcheck="false">';
4246 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\'');
4248 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
4249 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4251 print
' ';
4253 print
'<span class="opacitymedium small">';
4254 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',
'',
'');
4258 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
4259 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>';
4264 print $langs->trans(
"EditorName");
4266 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
4267 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'" spellcheck="false">';
4268 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
4269 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4272 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>';
4277 print $langs->trans(
"EditorUrl");
4279 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
4280 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'" spellcheck="false">';
4281 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
4282 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
4285 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.img_picto(
'',
'globe').
'</a>';
4287 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>';
4295 $langs->load(
"errors");
4296 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module).
'<br>';
4303 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
4305 print
'<!-- readme file -->';
4306 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
4307 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
4309 $langs->load(
"errors");
4310 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
4316 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
4318 print
'<!-- changelog file -->';
4320 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
4322 $langs->load(
"errors");
4323 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
4332 if ($fullpathoffile) {
4333 $content = file_get_contents($fullpathoffile);
4337 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4339 print
'<input type="hidden" name="action" value="savefile">';
4340 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4341 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4342 print
'<input type="hidden" name="module" value="'.$module.
'">';
4346 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
4347 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
4348 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4353 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4355 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4361 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
4364 if ($tab ==
'languages') {
4365 print
'<!-- tab=languages -->'.
"\n";
4366 if ($action !=
'editfile' || empty($file)) {
4367 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
4371 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4372 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4373 print
'<input type="hidden" name="action" value="addlanguage">';
4374 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4375 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4376 print
'<input type="hidden" name="module" value="'.$module.
'">';
4377 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
4378 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
4388 $diroflang .=
'/langs';
4389 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
4391 if (!preg_match(
'/custom/', $dirread)) {
4393 $diroflang = $dirread;
4394 $diroflang .=
'/langs';
4395 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
4398 print
'<table class="none">';
4399 foreach ($langfiles as $langfile) {
4400 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
4401 if (!preg_match(
'/custom/', $dirread)) {
4402 $pathtofile =
'langs/'.$langfile[
'relativename'];
4404 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4405 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>';
4406 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>';
4417 $content = file_get_contents($fullpathoffile);
4420 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4421 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4422 print
'<input type="hidden" name="action" value="savefile">';
4423 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4424 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4425 print
'<input type="hidden" name="module" value="'.$module.
'">';
4427 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4428 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
4431 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4433 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4440 if ($tab ==
'objects') {
4441 print
'<!-- tab=objects -->'.
"\n";
4446 $dir = $dirread.
'/'.$modulelowercase.
'/class';
4448 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
4449 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4450 $head3[$h][2] =
'newobject';
4454 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
4456 $firstobjectname =
'';
4457 foreach ($listofobject as $fileobj) {
4458 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
4461 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
4465 $tmpcontent = file_get_contents($fileobj[
'fullname']);
4466 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
4468 $objectname = $reg[1];
4469 if (empty($firstobjectname)) {
4470 $firstobjectname = $objectname;
4472 $pictoname =
'generic';
4473 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
4474 $pictoname = $reg[1];
4477 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
4478 $head3[$h][1] = img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
4479 $head3[$h][2] = $objectname;
4485 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4486 $head3[$h][1] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4487 $head3[$h][2] =
'deleteobject';
4492 if ($tabobj ==
'newobjectifnoobj') {
4493 if ($firstobjectname) {
4494 $tabobj = $firstobjectname;
4496 $tabobj =
'newobject';
4500 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4503 if ($tabobj ==
'newobject') {
4505 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4506 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4507 print
'<input type="hidden" name="action" value="initobject">';
4508 print
'<input type="hidden" name="tab" value="objects">';
4509 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4516 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4518 print
'<div class="tagtable">';
4520 print
'<div class="tagtr"><div class="tagtd">';
4521 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4522 print
'</div><div class="tagtd">';
4523 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(
GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" required autofocus>';
4524 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4525 print
'</div></div>';
4527 print
'<div class="tagtr"><div class="tagtd">';
4528 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4529 print
'</div><div class="tagtd">';
4530 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4532 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\'');
4534 print
'<span class="opacitymedium small">';
4535 print
' ';
4536 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',
'',
'');
4539 print
'</div></div>';
4541 print
'<div class="tagtr"><div class="tagtd">';
4542 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4543 print
'</div><div class="tagtd">';
4544 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4545 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4546 print
'</div></div>';
4549 $parameters = array(
'module' =>
$module,
'tabobj' => $tabobj);
4550 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $hookobject, $action);
4552 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
4554 print $hookmanager->resPrint;
4559 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>';
4560 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4561 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4562 print
'<input type="checkbox" name="nogeneratelines" id="nogeneratelines" value="nogeneratelines"> <label for="nogeneratelines">'.$form->textwithpicto($langs->trans(
"NoGenerateLines"), $langs->trans(
"NoGenerateLinesHelp")).
'</label><br>';
4563 print
'<br><span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"EnabledTabsForObject"), $langs->trans(
"EnabledTabsForObjectHelp")).
'</span><br>';
4565 $checked = in_array($tabkey, $enabledtabsdefault,
true) ?
' checked' :
'';
4566 print
'<input type="checkbox" name="enabledtab[]" id="enabledtab_'.$tabkey.
'" value="'.
dol_escape_htmltag($tabkey).
'"'.$checked.
'> ';
4567 print
'<label for="enabledtab_'.$tabkey.
'">'.
dol_escape_htmltag($langs->trans($tabinfo[
'label'])).
'</label> ';
4570 print
'<br><span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"EnabledCardActionsForObject"), $langs->trans(
"EnabledCardActionsForObjectHelp")).
'</span><br>';
4572 $checked = in_array($actionkey, $enabledcardactionsdefault,
true) ?
' checked' :
'';
4573 print
'<input type="checkbox" name="enabledcardaction[]" id="enabledcardaction_'.$actionkey.
'" value="'.
dol_escape_htmltag($actionkey).
'"'.$checked.
'> ';
4574 print
'<label for="enabledcardaction_'.$actionkey.
'">'.
dol_escape_htmltag($langs->trans($actioninfo[
'label'])).
'</label> ';
4577 print
'<br><span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"AccessPolicyForObject"), $langs->trans(
"AccessPolicyForObjectHelp")).
'</span><br>';
4578 for ($i = 0; $i < AccessPolicyConfig::MAX_ALTERNATIVES; $i++) {
4579 $accesspolicyselected =
GETPOST(
'accesspolicy_'.$i,
'array:aZ09');
4580 print
'<span class="opacitymedium">'.dol_escape_htmltag($langs->trans($i == 0 ?
"AccessPolicyFirstAlternative" :
"AccessPolicyOtherAlternative", $i + 1)).
'</span> ';
4582 $checked = in_array($predicatename, $accesspolicyselected,
true) ?
' checked' :
'';
4583 print
'<span class="nowraponall"><input type="checkbox" name="accesspolicy_'.$i.
'[]" id="accesspolicy_'.$i.
'_'.$predicatename.
'" value="'.
dol_escape_htmltag($predicatename).
'"'.$checked.
'> ';
4584 print
'<label for="accesspolicy_'.$i.
'_'.$predicatename.
'">'.
dol_escape_htmltag($langs->trans(
"AccessPolicyPredicate".ucfirst($predicatename))).
'</label></span> ';
4588 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"AccessPolicyMessage"), $langs->trans(
"AccessPolicyMessageHelp")).
'</span> ';
4589 print
'<input type="text" name="accesspolicymessage" maxlength="'.AccessPolicyConfig::MAX_MESSAGE_LENGTH.
'" value="'.
dol_escape_htmltag(
GETPOST(
'accesspolicymessage',
'alphanohtml')).
'" placeholder="ErrorForbidden">';
4592 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4608 } elseif ($tabobj ==
'createproperty') {
4609 $attributesUnique = array(
4610 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4611 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4612 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4613 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4614 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4615 'propdefault' => $langs->trans(
"DefaultValue"),
4616 'propindex' => $langs->trans(
"DatabaseIndex"),
4617 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4618 'propposition' => $langs->trans(
"Position"),
4619 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4620 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4621 'propnoteditable' => $langs->trans(
"NotEditable"),
4623 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4624 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4625 'propcss' => $langs->trans(
"CSSClass"),
4626 'propcssview' => $langs->trans(
"CSSViewClass"),
4627 'propcsslist' => $langs->trans(
"CSSListClass"),
4628 'prophelp' => $langs->trans(
"KeyForTooltip"),
4629 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4631 'propcomment' => $langs->trans(
"Comment"),
4633 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode(
$module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4634 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4635 print
'<input type="hidden" name="action" value="addproperty">';
4636 print
'<input type="hidden" name="tab" value="objects">';
4637 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4638 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4640 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4642 foreach ($attributesUnique as $key => $attribute) {
4643 if ($counter % 2 === 0) {
4646 if ($key ==
'propname' || $key ==
'proplabel') {
4647 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>';
4648 } elseif ($key ==
'proptype') {
4649 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4650 print
'<input class="maxwidth200" name="'.$key.
'" id="'.$key.
'" list="datalist'.$key.
'" type="text" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4652 print
'<datalist id="datalist'.$key.
'">';
4653 print
'<option>varchar(128)</option>';
4654 print
'<option>email</option>';
4655 print
'<option>phone</option>';
4656 print
'<option>ip</option>';
4657 print
'<option>url</option>';
4658 print
'<option>password</option>';
4659 print
'<option>text</option>';
4660 print
'<option>html</option>';
4661 print
'<option>date</option>';
4662 print
'<option>datetime</option>';
4663 print
'<option>integer</option>';
4664 print
'<option>stars(5)</option>';
4665 print
'<option>double(28,4)</option>';
4666 print
'<option>real</option>';
4667 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4676 print
'</datalist>';
4680 } elseif ($key ==
'propvisible') {
4681 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>';
4682 } elseif ($key ==
'propenabled') {
4685 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>';
4686 } elseif ($key ==
'proparrayofkeyval') {
4687 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>';
4689 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>';
4692 if ($counter % 2 === 0) {
4696 if ($counter % 2 !== 0) {
4697 while ($counter % 2 !== 0) {
4703 print
'</table><br>'.
"\n";
4704 print
'<div class="center">';
4705 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4706 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4712 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode(
$module).
'";
4713 window.location.href = url;
4715 $(document).ready(function() {
4716 $("#proplabel").on("keyup", function() {
4717 console.log("key up on label");
4718 s = cleanString($("#proplabel").val());
4719 $("#propname").val(s);
4722 function cleanString( stringtoclean )
4724 // allow "a-z", "A-Z", "0-9" and "_"
4725 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4726 stringtoclean = stringtoclean.toLowerCase();
4727 if (!isNaN(stringtoclean)) {
4730 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4731 stringtoclean = stringtoclean.dol_substr(1)
4733 if (stringtoclean.length > 28) {
4734 stringtoclean = stringtoclean.substring(0, 27);
4736 return stringtoclean;
4741 } elseif ($tabobj ==
'deleteobject') {
4743 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4744 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4745 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4746 print
'<input type="hidden" name="tab" value="objects">';
4747 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4748 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
4750 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4752 print
'<input type="text" class="valignmiddle" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4753 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4757 if ($action ==
'deleteproperty') {
4758 $formconfirm = $form->formconfirm(
4759 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode(
$module).
'&tabobj='.urlencode($tabobj),
4760 $langs->trans(
'Delete'),
4761 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4762 'confirm_deleteproperty',
4771 if ($action !=
'editfile' || empty($file)) {
4786 clearstatcache(
true);
4787 if (function_exists(
'opcache_invalidate')) {
4788 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4791 if (empty($forceddirread) && empty($dirread)) {
4793 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4795 $result = include_once $dirread.
'/'.$pathtoclass;
4796 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4799 if (class_exists($tabobj)) {
4801 $tmpobject = @
new $tabobj($db);
4803 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4806 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4822 $pathtosql =
'install/mysql/tables/llx_'.dol_strtolower(
$module).
'.sql';
4823 $pathtosqlextra =
'install/mysql/tables/llx_'.dol_strtolower(
$module).
'_extrafields.sql';
4837 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4839 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4840 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4845 $tmpobject = $tmpobject ??
null;
4846 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4847 $pathtopicto = $tmpobject->picto;
4848 $realpathtopicto =
'';
4851 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4856 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4857 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4858 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4859 $realpathtocard = $dirread.
'/'.$pathtocard;
4860 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4861 $realpathtolist = $dirread.
'/'.$pathtolist;
4862 $realpathtonote = $dirread.
'/'.$pathtonote;
4863 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4864 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4865 $realpathtosql = $dirread.
'/'.$pathtosql;
4866 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4867 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4868 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4869 $realpathtolib = $dirread.
'/'.$pathtolib;
4870 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4872 if (empty($realpathtoapi)) {
4874 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4884 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4885 $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>';
4886 $htmltooltip .=
'<br>';
4887 } elseif (!empty($tmpobject)) {
4888 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4889 $htmltooltip .=
'<br>';
4891 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsExtraFieldManaged").
' : '.yn(empty($tmpobject->isextrafieldmanaged) ? 0 : 1, 1, 2);
4892 $htmltooltip .=
'<br>';
4893 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsMultiEntityManaged").
' : '.yn(empty($tmpobject->ismultientitymanaged) ? 0 : 1, 1, 2);
4894 $htmltooltip .=
'<br>';
4896 print
'<!-- section for object -->';
4897 print
'<div class="fichehalfleft smallxxx">';
4899 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>';
4900 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>';
4901 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmiddle', 1);
4906 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>';
4908 $file = file_get_contents($realpathtoapi);
4909 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4910 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>';
4912 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>';
4913 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4917 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled",
$module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4919 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4922 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>';
4925 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>';
4929 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>';
4931 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>';
4933 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>';
4935 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>';
4941 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>';
4942 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>';
4944 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>';
4945 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>';
4949 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>';
4950 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>';
4951 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>';
4954 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>';
4955 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>';
4958 if (!empty($tmpobject->isextrafieldmanaged)) {
4959 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>';
4961 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>';
4963 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>';
4965 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>';
4967 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>';
4972 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>';
4974 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>';
4976 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>';
4978 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>';
4984 print
'<div class="fichehalfleft smallxxxx">';
4985 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>';
4986 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>';
4988 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>';
4989 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>';
4992 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>';
4993 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>';
4996 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>';
4998 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>';
5002 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>';
5003 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>';
5006 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>';
5008 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>';
5012 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>';
5013 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>';
5016 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>';
5018 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>';
5022 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>';
5023 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>';
5026 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>';
5028 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>';
5035 print
'<br><br><br>';
5037 if (!empty($tmpobject)) {
5038 $reflector =
new ReflectionClass($tabobj);
5039 $reflectorproperties = $reflector->getProperties();
5040 $reflectorpropdefault = $reflector->getDefaultProperties();
5044 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5045 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5046 print
'<input type="hidden" name="action" value="addproperty">';
5047 print
'<input type="hidden" name="tab" value="objects">';
5048 print
'<input type="hidden" name="page_y" value="">';
5049 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module.($forceddirread ?
'@'.$dirread :
'')).
'">';
5050 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5052 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
5054 $parameters = array(
'module' =>
$module,
'tabobj' => $tabobj,
'dirread' => $dirread);
5055 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $tmpobject, $action);
5057 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
5059 print $hookmanager->resPrint;
5061 print
'<br><br class="clearboth">';
5062 print
'<br class="clearboth">';
5066 $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));
5067 $nbOfProperties = count($reflectorpropdefault[
'fields']);
5069 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
5072 print
'<!-- Table with properties of object -->'.
"\n";
5073 print
'<div class="div-table-responsive">';
5074 print
'<table class="noborder small">';
5075 print
'<tr class="liste_titre">';
5076 if (!empty(
$conf->main_checkbox_left_column)) {
5077 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
5079 print
'<th class="tdsticky tdstickygray">';
5080 $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>';
5081 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
5084 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
5086 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
5087 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
5088 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
5089 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
5090 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
5091 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
5092 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
5093 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
5094 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
5095 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
5097 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
5098 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
5099 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
5100 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
5101 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
5102 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
5103 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
5105 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
5106 print
'<th>'.$langs->trans(
"Comment").
'</th>';
5107 if (empty(
$conf->main_checkbox_left_column)) {
5108 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
5115 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
5116 if (!empty($properties)) {
5118 foreach ($properties as $propkey => $propval) {
5133 $propname = $propkey;
5134 $proplabel = $propval[
'label'];
5135 $proptype = $propval[
'type'];
5136 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
5137 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
5138 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
5139 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
5140 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
5141 $propposition = $propval[
'position'];
5142 $propenabled = $propval[
'enabled'];
5143 $propvisible = $propval[
'visible'];
5144 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
5146 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
5147 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
5148 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
5149 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
5150 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
5151 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
5152 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
5154 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
5155 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
5157 print
'<!-- line for object property -->'.
"\n";
5158 print
'<tr class="oddeven">';
5160 if (!empty(
$conf->main_checkbox_left_column)) {
5161 if ($action ==
'editproperty' && $propname == $propertykey) {
5162 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5163 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
5164 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
5167 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5168 if ($propname !=
'rowid') {
5169 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>';
5170 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>';
5175 print
'<td class="tdsticky tdstickygray">';
5178 if ($action ==
'editproperty' && $propname == $propertykey) {
5180 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
5181 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
5183 print
'<td class="tdoverflowmax150">';
5184 print
'<input name="proptype" id="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'" list="datalistproptype"></input>';
5186 print
'<datalist id="datalistproptype">';
5187 print
'<option>varchar(128)</option>';
5188 print
'<option>email</option>';
5189 print
'<option>phone</option>';
5190 print
'<option>ip</option>';
5191 print
'<option>url</option>';
5192 print
'<option>password</option>';
5193 print
'<option>text</option>';
5194 print
'<option>html</option>';
5195 print
'<option>date</option>';
5196 print
'<option>datetime</option>';
5197 print
'<option>integer</option>';
5198 print
'<option>stars(5)</option>';
5199 print
'<option>double(28,4)</option>';
5200 print
'<option>real</option>';
5201 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
5210 print
'</datalist>';
5213 print
'<td class="tdoverflowmax200">';
5214 print
'<textarea name="proparrayofkeyval">';
5215 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
5218 print
'</textarea>';
5221 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
5224 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
5226 print
'<td class="center">';
5227 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
5230 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
5233 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
5236 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
5239 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
5242 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
5248 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
5251 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
5254 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
5257 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
5260 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
5263 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
5266 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
5269 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
5272 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
5274 if (empty(
$conf->main_checkbox_left_column)) {
5275 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5276 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
5277 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
5281 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
5284 print
'<td class="tdoverflowmax200">';
5287 if (preg_match(
'/^varchar/', $proptype, $matches)) {
5288 $pictoType =
'varchar';
5289 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
5290 $pictoType =
'link';
5291 } elseif (strpos($proptype,
'integer') === 0) {
5293 } elseif (strpos($proptype,
'timestamp') === 0) {
5294 $pictoType =
'datetime';
5295 } elseif (strpos($proptype,
'real') === 0) {
5296 $pictoType =
'double';
5297 } elseif (strpos($proptype,
'stars') === 0) {
5298 $pictoType =
'stars';
5302 print
'<td class="tdoverflowmax200">';
5303 if ($proparrayofkeyval) {
5304 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
5309 print
'<td class="center">';
5315 print
'<td class="center">';
5316 print $propindex ?
'1' :
'';
5318 print
'<td class="center">';
5321 print
'<td class="right">';
5324 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
5328 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
5332 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
5338 print
'<td class="center">';
5339 print $propsearchall ?
'1' :
'';
5341 print
'<td class="center">';
5344 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
5347 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
5350 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
5354 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
5357 print
'<td class="center">';
5363 print
'<td class="center">';
5366 print
'<td class="tdoverflowmax200">';
5367 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
5371 if (empty(
$conf->main_checkbox_left_column)) {
5372 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5373 if ($propname !=
'rowid') {
5374 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>';
5375 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>';
5383 if ($tab ==
'specifications') {
5384 if ($action !=
'editfile' || empty($file)) {
5385 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
5390 foreach ($specs as $spec) {
5391 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
5392 $format =
'asciidoc';
5393 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
5394 $format =
'markdown';
5396 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5397 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>';
5407 $content = file_get_contents($fullpathoffile);
5410 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5411 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5412 print
'<input type="hidden" name="action" value="savefile">';
5413 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5414 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5415 print
'<input type="hidden" name="module" value="'.$module.
'">';
5417 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5418 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5421 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5423 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5429 $langs->load(
"errors");
5430 print
'<tr><td><span class="warning">'.$langs->trans(
'ErrorModuleBuilderNoFieldProperty').
'</warning></td></tr>';
5437 $langs->load(
"errors");
5438 print
'<span class="warning">'.$langs->trans(
'ErrorModuleBuilderFailedToInit', $tabobj, (
string) $db).
'</warning>';
5442 print $e->getMessage();
5446 if (empty($forceddirread)) {
5449 $fullpathoffile = $dirread.
'/'.$file;
5452 $content = file_get_contents($fullpathoffile);
5455 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5456 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5457 print
'<input type="hidden" name="action" value="savefile">';
5458 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5459 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5460 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5461 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
5463 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
5464 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5467 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5469 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5479 if ($tab ==
'dictionaries') {
5480 print
'<!-- tab=dictionaries -->'.
"\n";
5485 if ($action ==
'deletedict') {
5486 $formconfirm = $form->formconfirm(
5487 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)),
5488 $langs->trans(
'Delete'),
5489 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
5490 'confirm_deletedictionary',
5498 if ($action !=
'editfile' || empty($file)) {
5499 print
'<span class="opacitymedium">';
5500 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
5501 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
5502 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5506 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5507 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>';
5509 if (is_array($dicts) && !empty($dicts)) {
5510 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
5511 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
5522 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.
$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
5523 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
5524 $head3[$h][2] =
'newdictionary';
5565 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode(
$module).
'&tabdic=newdictionary');
5566 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
5568 if ($tabdic !=
'newdictionary') {
5569 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5570 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5571 print
'<input type="hidden" name="action" value="addDictionary">';
5572 print
'<input type="hidden" name="tab" value="dictionaries">';
5573 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5574 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
5576 print
'<div class="div-table-responsive">';
5577 print
'<table class="noborder">';
5579 print
'<tr class="liste_titre">';
5580 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
5593 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
5595 $maxi = count($dicts[
'tabname']);
5596 while ($i < $maxi) {
5597 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5598 print
'<tr class="oddeven">';
5599 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5600 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5601 print
'<input type="hidden" name="tab" value="dictionaries">';
5602 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5603 print
'<input type="hidden" name="action" value="updatedictionary">';
5604 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5606 print
'<td class="tdsticky tdstickygray">';
5611 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5615 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5619 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5623 print
'<select name="tabsqlsort">';
5624 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5628 print
'<td><select name="tabfield" >';
5629 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5630 print
'</select></td>';
5632 print
'<td><select name="tabfieldvalue" >';
5633 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5634 print
'</select></td>';
5636 print
'<td><select name="tabfieldinsert" >';
5637 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5638 print
'</select></td>';
5641 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5645 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5648 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5649 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5651 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5657 print
'<tr class="oddeven">';
5659 print
'<td class="tdsticky tdstickygray">';
5664 print $dicts[
'tabname'][$i];
5668 print $dicts[
'tablib'][$i];
5672 print $dicts[
'tabsql'][$i];
5676 print $dicts[
'tabsqlsort'][$i];
5680 print $dicts[
'tabfield'][$i];
5684 print $dicts[
'tabfieldvalue'][$i];
5688 print $dicts[
'tabfieldinsert'][$i];
5692 print $dicts[
'tabrowid'][$i];
5696 print $dicts[
'tabcond'][$i];
5699 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5700 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>';
5701 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>';
5709 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5718 if ($tabdic ==
'newdictionary') {
5720 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5721 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5722 print
'<input type="hidden" name="action" value="initdic">';
5723 print
'<input type="hidden" name="tab" value="dictionaries">';
5724 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5726 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5728 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5731 print
'<table class="border centpercent">';
5733 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>';
5734 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>';
5735 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>';
5736 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>';
5737 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5738 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5739 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5740 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5742 print
'</tbody></table>';
5743 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5744 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5748 $(document).ready(function() {
5749 $("input[name=\'dicname\']").on("blur", function() {
5750 if ($(this).val().length > 0) {
5751 $("input[name=\'label\']").val($(this).val());
5752 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5753 $("input[name=\'sqlsort\']").val("label ASC");
5754 $("input[name=\'field\']").val("code,label");
5755 $("input[name=\'fieldvalue\']").val("code,label");
5756 $("input[name=\'fieldinsert\']").val("code,label");
5757 $("input[name=\'rowid\']").val("rowid");
5759 $("input[name=\'label\']").val("");
5760 $("input[name=\'sql\']").val("");
5761 $("input[name=\'sqlsort\']").val("");
5762 $("input[name=\'field\']").val("");
5763 $("input[name=\'fieldvalue\']").val("");
5764 $("input[name=\'fieldinsert\']").val("");
5765 $("input[name=\'rowid\']").val("");
5768 $("input[id=\'cancel\']").click(function() {
5769 window.history.back();
5786 } elseif ($tabdic ==
'deletedictionary') {
5788 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5789 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5790 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5791 print
'<input type="hidden" name="tab" value="dictionaries">';
5792 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5794 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5796 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5797 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5805 $content = file_get_contents($fullpathoffile);
5808 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5809 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5810 print
'<input type="hidden" name="action" value="savefile">';
5811 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5812 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5813 print
'<input type="hidden" name="module" value="'.$module.
'">';
5815 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5816 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5817 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5820 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5822 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5829 if ($tab ==
'menus') {
5830 print
'<!-- tab=menus -->'.
"\n";
5834 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5837 $leftmenus = array();
5842 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5845 $groupedRights = array();
5846 foreach ($permissions as $right) {
5848 if (!isset($groupedRights[$key])) {
5849 $groupedRights[$key] = array();
5851 $groupedRights[$key][] = $right;
5853 $groupedRights_json = json_encode($groupedRights);
5855 if ($action ==
'deletemenu') {
5856 $formconfirms = $form->formconfirm(
5857 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)),
5858 $langs->trans(
'Delete'),
5859 ($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'))),
5860 'confirm_deletemenu',
5865 print $formconfirms;
5867 if ($action !=
'editfile' || empty($file)) {
5868 print
'<span class="opacitymedium">';
5869 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5870 $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);
5871 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5876 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5877 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>';
5881 $listODifferentUrlsInMenu = array();
5882 foreach ($menus as $obj) {
5883 if (preg_match(
'/^\/'.preg_quote(
dol_strtolower(
$module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5884 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5887 $pathtofile = $obj[
'url'];
5888 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5889 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5890 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>';
5899 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5900 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5901 print
'<input type="hidden" name="action" value="addmenu">';
5902 print
'<input type="hidden" name="tab" value="menus">';
5903 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
5904 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5906 print
'<div class="div-table-responsive">';
5907 print
'<table class="noborder small">';
5909 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5910 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5911 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5912 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(
dol_strtolower(
$module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5913 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5914 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5915 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(
dol_strtolower(
$module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5917 print
'<tr class="liste_titre">';
5918 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5921 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5924 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5926 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5927 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5928 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5929 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5930 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5931 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5934 $r = count($menus) + 1;
5937 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5938 print
'<td class="center">';
5939 print
'<select class="maxwidth50" name="type">';
5940 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5941 print
'</select></td>';
5942 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5943 print
'<td class="left">';
5944 print
'<select name="fk_menu">';
5945 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5946 foreach ($menus as $obj) {
5947 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5948 print
"<option value=".dol_strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5954 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5956 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5957 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.dol_strtolower(
$module).
'@'.
dol_strtolower(
$module).
'" readonly></td>';
5959 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5961 print
'<td class="center">';
5962 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(
GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.
$module.
'\')').
'">';
5971 print
'<td class="left">';
5972 print
'<select class="maxwidth" name="objects" id="objects">';
5973 print
'<option value=""></option>';
5974 if (is_array($objects)) {
5975 foreach ($objects as $value) {
5980 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5983 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5984 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>';
5986 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5987 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5995 if (count($menus)) {
5997 foreach ($menus as $menu) {
6003 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
6004 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
6005 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
6006 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
6007 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
6008 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
6009 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
6010 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
6011 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
6013 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
6014 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
6018 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
6020 print
'<tr class="oddeven">';
6021 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6022 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6023 print
'<input type="hidden" name="action" value="update_menu">';
6024 print
'<input type="hidden" name="tab" value="menus">';
6025 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6026 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
6028 print
'<td class="tdsticky tdstickygray">';
6032 print
'<td class="center">
6033 <select class="center maxwidth50" name="type">
6034 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
6037 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
6038 if ($menu[
'type'] ==
'left') {
6043 print
'</option></select></td>';
6045 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
6056 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
6058 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
6059 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
6061 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
6062 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.dol_strtolower(
$module).
'@'.
dol_strtolower(
$module).
'" readonly></td>';
6064 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
6066 print
'<td class="nowraponall">';
6067 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag(
$module).
"')").
'">';
6068 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
6069 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
6070 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
6071 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag(
$module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
6072 print $form->textwithpicto('', $htmltext);
6074 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
6075 print '<option value=
"1">1 (always enabled)</option>
';
6076 print '<option value=
"0">0 (always
disabled)</option>
';
6082 print '<td
class=
"nowraponall">
';
6083 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
6085 if (!empty($objPerms)) {
6086 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
6087 print '<select
class=
"center maxwidth50" name=
"perms">
';
6088 if (!empty($valPerms)) {
6089 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
6090 foreach ($crud as $key => $val) {
6091 if ($valPerms != $key) {
6092 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
6098 print '<select
class=
"center maxwidth50" name=
"objects">
';
6099 print '<option></option>
';
6100 foreach ($objects as $obj) {
6101 print '<option value=
"'.dol_escape_htmltag(dol_strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
6104 print '<select
class=
"center maxwidth50" name=
"perms">
';
6105 foreach ($crud as $key => $val) {
6106 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
6112 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
6113 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>
';
6114 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
6115 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
6116 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
6121 print '<tr
class=
"oddeven">
';
6123 print '<td
class=
"tdsticky tdstickygray">
';
6127 print '<td
class=
"center">
';
6128 print dol_escape_htmltag($menu['type']);
6133 print dol_escape_htmltag($menu['titre
']);
6137 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
6138 print dol_escape_htmltag($menu['fk_menu
']);
6142 print dol_escape_htmltag($menu['mainmenu
']);
6146 print dol_escape_htmltag($menu['leftmenu
']);
6149 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
6150 print dol_escape_htmltag($menu['url
']);
6154 print dol_escape_htmltag($menu['langs
']);
6158 print '<td
class=
"center">
';
6159 print dol_escape_htmltag((string) $menu['position']);
6163 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
6164 print dol_escape_htmltag($menu['enabled
']);
6168 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
6169 print dol_escape_htmltag($langs->trans($menu['perms
']));
6173 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
6174 print dol_escape_htmltag($menu['target
']);
6177 print '<td
class=
"center">
';
6178 if ($menu['user'] == 2) {
6179 print $langs->trans("AllMenus");
6180 } elseif ($menu['user'] == 0) {
6181 print $langs->trans('Internal
');
6182 } elseif ($menu['user'] == 1) {
6183 print $langs->trans('External
');
6185 print $menu['user']; // should not happen
6188 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
6189 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
6190 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>
';
6191 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>
';
6198 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
6207 $(document).ready(
function() {
6209 $(
"#leftmenu").on(
"input",
function() {
6210 var inputLeftMenu = $(
"#leftmenu").val();
6211 if (inputLeftMenu !== \
'\') {
6219 var groupedRights = ' . $groupedRights_json .
';
6220 var objectsSelect = $("select[id=\'objects\']");
6221 var permsSelect = $("select[id=\'perms\']");
6223 objectsSelect.change(function() {
6224 var selectedObject = $(this).val();
6226 permsSelect.empty();
6228 var rights = groupedRights[selectedObject];
6231 for (var i = 0; i < rights.length; i++) {
6232 var right = rights[i];
6233 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
6234 permsSelect.append(option);
6237 var option = $("<option></option>").attr("value", "read").text("read");
6238 permsSelect.append(option);
6241 if (selectedObject !== "" && selectedObject !== null && rights) {
6246 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
6257 $content = file_get_contents($fullpathoffile);
6260 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6261 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6262 print
'<input type="hidden" name="action" value="savefile">';
6263 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6264 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6265 print
'<input type="hidden" name="module" value="'.$module.
'">';
6267 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6268 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6269 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6272 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6274 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6281 if ($tab ==
'permissions') {
6282 print
'<!-- tab=permissions -->'.
"\n";
6288 $dir = $dirread.
'/'.$modulelowercase.
'/class';
6289 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
6290 $objects = array(
'myobject');
6292 foreach ($listofobject as $fileobj) {
6293 $tmpcontent = file_get_contents($fileobj[
'fullname']);
6294 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
6295 $objects[$fileobj[
'fullname']] = $reg[1];
6300 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
6301 $labels = array(
"Read objects of ".
$module,
"Create/Update objects of ".
$module,
"Delete objects of ".
$module);
6303 $action =
GETPOST(
'action',
'alpha');
6305 if ($action ==
'deleteright') {
6306 $formconfirm = $form->formconfirm(
6307 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) (
$module)).
'&tabobj='.urlencode((
string) ($tabobj)),
6308 $langs->trans(
'Delete'),
6309 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
6310 'confirm_deleteright',
6318 if ($action !=
'editfile' || empty($file)) {
6319 print
'<!-- Tab to manage permissions -->'.
"\n";
6320 print
'<span class="opacitymedium">';
6321 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip");
6324 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6328 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6329 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>';
6335 print
'<!-- form to add permissions -->'.
"\n";
6336 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6337 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6338 print
'<input type="hidden" name="action" value="addright">';
6339 print
'<input type="hidden" name="tab" value="permissions">';
6340 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6341 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6343 print
'<div class="div-table-responsive">';
6344 print
'<table class="noborder">';
6346 print
'<tr class="liste_titre">';
6348 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
6355 print
'<tr class="small">';
6356 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
6358 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
6359 print
'<option value=""></option>';
6360 foreach ($objects as $obj) {
6361 if ($obj !=
'myobject') {
6362 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
6365 print
'</select></td>';
6367 print
'<td><select class="maxwidth75" name="crud" id="crud">';
6368 print
'<option value=""></option>';
6369 foreach ($crud as $key => $val) {
6370 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
6375 print
'<input type="text" name="label" id="label" class="minwidth200">';
6378 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6379 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
6383 if (count($perms)) {
6385 foreach ($perms as $perm) {
6389 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
6390 print
'<tr class="oddeven">';
6391 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
6392 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6393 print
'<input type="hidden" name="tab" value="permissions">';
6394 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6395 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6396 print
'<input type="hidden" name="action" value="update_right">';
6397 print
'<input type="hidden" name="counter" value="'.$i.
'">';
6399 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
6401 print
'<td class="tdsticky tdstickygray">';
6402 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
6406 print
'<select name="crud">';
6407 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
6408 foreach ($crud as $i => $x) {
6409 if ($perm[5] != $i) {
6410 print
'<option value="'.$i.
'">'.$langs->trans(
dol_ucfirst($x)).
'</option>';
6416 print
'<td><select name="permissionObj" >';
6417 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.
dol_ucfirst($perm[4]).
'</option>';
6418 print
'</select></td>';
6421 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
6424 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6425 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
6427 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
6434 print
'<tr class="oddeven">';
6441 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
6449 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
6457 print $langs->trans($perm[1]);
6460 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
6461 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>';
6462 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>';
6470 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6478 function updateInputField() {
6479 value1 = $("#crud").val();
6480 value2 = $("#permissionObj").val();
6482 // Check if both selections are made
6483 if (value1 && value2) {
6484 switch(value1.toLowerCase()){
6486 $("#label").val("Read "+value2+" object of '.dol_ucfirst(
$module).
'")
6500 $("#crud, #permissionObj").change(function(){
6501 console.log("We change selection");
6509 $content = file_get_contents($fullpathoffile);
6512 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6513 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6514 print
'<input type="hidden" name="action" value="savefile">';
6515 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6516 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6517 print
'<input type="hidden" name="module" value="'.$module.
'">';
6519 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6520 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6521 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6524 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6526 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6533 if ($tab ==
'hooks') {
6534 print
'<!-- tab=hooks -->'.
"\n";
6535 if ($action !=
'editfile' || empty($file)) {
6536 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
6543 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6545 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>';
6550 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
6552 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6554 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> ';
6555 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>';
6557 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6558 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>';
6565 $content = file_get_contents($fullpathoffile);
6568 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6569 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6570 print
'<input type="hidden" name="action" value="savefile">';
6571 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6572 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6573 print
'<input type="hidden" name="module" value="'.$module.
'">';
6575 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6576 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6577 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6580 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6582 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6589 if ($tab ==
'triggers') {
6590 print
'<!-- tab=triggers -->'.
"\n";
6591 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
6596 if ($action !=
'editfile' || empty($file)) {
6597 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6604 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6606 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>';
6609 if (!empty($triggers)) {
6610 foreach ($triggers as $trigger) {
6611 $pathtofile = $trigger[
'relpath'];
6614 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6615 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>';
6616 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>';
6621 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6622 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6623 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>';
6632 $content = file_get_contents($fullpathoffile);
6635 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6636 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6637 print
'<input type="hidden" name="action" value="savefile">';
6638 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6639 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6640 print
'<input type="hidden" name="module" value="'.$module.
'">';
6642 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6643 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6644 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6647 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6649 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6656 if ($tab ==
'css') {
6657 print
'<!-- tab=css -->'.
"\n";
6658 if ($action !=
'editfile' || empty($file)) {
6659 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6666 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6668 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6669 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>';
6670 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>';
6672 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6673 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>';
6679 $content = file_get_contents($fullpathoffile);
6682 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6683 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6684 print
'<input type="hidden" name="action" value="savefile">';
6685 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6686 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6687 print
'<input type="hidden" name="module" value="'.$module.
'">';
6689 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6690 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6693 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6695 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6703 print
'<!-- tab=js -->'.
"\n";
6704 if ($action !=
'editfile' || empty($file)) {
6705 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6712 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6714 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6715 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>';
6716 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>';
6718 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6719 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>';
6725 $content = file_get_contents($fullpathoffile);
6728 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6729 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6730 print
'<input type="hidden" name="action" value="savefile">';
6731 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6732 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6733 print
'<input type="hidden" name="module" value="'.$module.
'">';
6735 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6736 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6739 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6741 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6748 if ($tab ==
'widgets') {
6749 print
'<!-- tab=widgets -->'.
"\n";
6750 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6754 if ($action !=
'editfile' || empty($file)) {
6755 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6759 if (!empty($widgets)) {
6760 foreach ($widgets as $widget) {
6761 $pathtofile = $widget[
'relpath'];
6763 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6764 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>';
6765 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>';
6769 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6770 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>';
6777 $content = file_get_contents($fullpathoffile);
6780 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6781 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6782 print
'<input type="hidden" name="action" value="savefile">';
6783 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6784 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6785 print
'<input type="hidden" name="module" value="'.$module.
'">';
6787 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6788 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6791 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6793 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6800 if ($tab ==
'emailings') {
6801 print
'<!-- tab=emailings -->'.
"\n";
6802 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6806 if ($action !=
'editfile' || empty($file)) {
6807 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6811 if (!empty($emailingselectors)) {
6812 foreach ($emailingselectors as $emailingselector) {
6813 $pathtofile = $emailingselector[
'relpath'];
6815 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6816 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>';
6817 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>';
6821 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6822 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>';
6829 $content = file_get_contents($fullpathoffile);
6832 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6833 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6834 print
'<input type="hidden" name="action" value="savefile">';
6835 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6836 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6837 print
'<input type="hidden" name="module" value="'.$module.
'">';
6839 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6840 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6843 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6845 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6852 if ($tab ==
'exportimport') {
6853 print
'<!-- tab=exportimport -->'.
"\n";
6859 if ($action !=
'editfile' || empty($file)) {
6860 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6863 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6864 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>';
6866 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6867 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>';
6872 $content = file_get_contents($fullpathoffile);
6875 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6876 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6877 print
'<input type="hidden" name="action" value="savefile">';
6878 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6879 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6880 print
'<input type="hidden" name="module" value="'.$module.
'">';
6882 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6883 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6884 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6887 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6889 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6896 if ($tab ==
'cli') {
6897 print
'<!-- tab=cli -->'.
"\n";
6898 $clifiles = array();
6903 foreach ($dircli as $reldir) {
6912 $handle = opendir($newdir);
6914 if (is_resource($handle)) {
6915 while (($tmpfile = readdir($handle)) !==
false) {
6916 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6917 if (preg_match(
'/\.back$/', $tmpfile)) {
6921 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6930 if ($action !=
'editfile' || empty($file)) {
6931 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6935 if (!empty($clifiles)) {
6936 foreach ($clifiles as $clifile) {
6937 $pathtofile = $clifile[
'relpath'];
6939 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6940 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>';
6941 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>';
6945 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6946 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>';
6953 $content = file_get_contents($fullpathoffile);
6956 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6957 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6958 print
'<input type="hidden" name="action" value="savefile">';
6959 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6960 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6961 print
'<input type="hidden" name="module" value="'.$module.
'">';
6963 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6964 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6967 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6969 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6976 if ($tab ==
'cron') {
6977 print
'<!-- tab=cron -->'.
"\n";
6982 if ($action !=
'editfile' || empty($file)) {
6983 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>';
6986 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6987 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>';
6993 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6994 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6995 print
'<input type="hidden" name="action" value="addproperty">';
6996 print
'<input type="hidden" name="tab" value="objects">';
6997 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
6998 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
7000 print
'<div class="div-table-responsive">';
7001 print
'<table class="noborder">';
7003 print
'<tr class="liste_titre">';
7011 if (count($cronjobs)) {
7012 foreach ($cronjobs as $cron) {
7013 print
'<tr class="oddeven">';
7016 print $cron[
'label'];
7021 if ($cron[
'jobtype'] ==
'method') {
7022 $text = $langs->trans(
"CronClass");
7023 $texttoshow = $langs->trans(
'CronModule').
': '.
$module.
'<br>';
7024 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
7025 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
7026 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
7027 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
7028 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
7029 } elseif ($cron[
'jobtype'] ==
'command') {
7030 $text = $langs->trans(
'CronCommand');
7031 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
7032 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
7033 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
7035 print $form->textwithpicto($text, $texttoshow, 1);
7039 if ($cron[
'unitfrequency'] ==
"60") {
7040 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
7042 if ($cron[
'unitfrequency'] ==
"3600") {
7043 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
7045 if ($cron[
'unitfrequency'] ==
"86400") {
7046 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
7048 if ($cron[
'unitfrequency'] ==
"604800") {
7049 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
7054 print $cron[
'status'];
7058 if (!empty($cron[
'comment'])) {
7059 print $cron[
'comment'];
7066 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
7076 $content = file_get_contents($fullpathoffile);
7079 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7080 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7081 print
'<input type="hidden" name="action" value="savefile">';
7082 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
7083 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
7084 print
'<input type="hidden" name="module" value="'.$module.
'">';
7086 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
7087 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
7088 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
7091 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
7093 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
7100 if ($tab ==
'specifications') {
7101 print
'<!-- tab=specifications -->'.
"\n";
7104 if ($action !=
'editfile' || empty($file)) {
7105 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
7109 if (is_array($specs) && !empty($specs)) {
7110 foreach ($specs as $spec) {
7111 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
7112 $format =
'asciidoc';
7113 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
7114 $format =
'markdown';
7117 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
7118 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>';
7119 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>';
7124 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7125 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>';
7136 $content = file_get_contents($fullpathoffile);
7139 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7140 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7141 print
'<input type="hidden" name="action" value="savefile">';
7142 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
7143 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
7144 print
'<input type="hidden" name="module" value="'.$module.
'">';
7146 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
7147 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
7150 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
7152 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
7158 print
'<br><br><br>';
7160 $FILENAMEDOC = $modulelowercase.
'.html';
7161 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
7162 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
7163 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
7164 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
7165 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
7166 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
7167 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
7170 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
7172 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7175 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
7176 print $outputfiledoc;
7179 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
7180 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>';
7182 print
'</strong><br>';
7185 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
7187 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7190 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
7191 print $outputfiledocpdf;
7194 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
7195 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>';
7197 print
'</strong><br>';
7201 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
7202 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7203 print
'<input type="hidden" name="action" value="generatedoc">';
7204 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
7205 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7206 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
7207 if (!is_array($specs) || empty($specs)) {
7208 print
' disabled="disabled"';
7214 if ($tab ==
'buildpackage') {
7215 print
'<!-- tab=buildpackage -->'.
"\n";
7216 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
7219 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
7220 $langs->load(
"errors");
7221 print img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
7233 $class =
'mod'.$module;
7235 if (class_exists($class)) {
7238 '@phan-var-force DolibarrModules $moduleobj';
7242 dol_print_error($db, $e->getMessage());
7247 $langs->load(
"errors");
7248 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX",
$module));
7252 $outputfilezip =
null;
7253 $arrayversion = explode(
'.',
$moduleobj->version, 3);
7254 if (count($arrayversion)) {
7255 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
7256 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
7261 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
7262 if ($outputfilezip ===
null || !
dol_is_file($outputfilezip)) {
7263 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
7265 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
7266 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
7267 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
7268 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>';
7276 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
7277 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7278 print
'<input type="hidden" name="action" value="generatepackage">';
7279 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
7280 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7281 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
7285 if ($tab ==
'tabs') {
7290 if ($action !=
'editfile' || empty($file)) {
7291 print
'<span class="opacitymedium">';
7292 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
7293 $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);
7294 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
7298 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
7299 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>';
7305 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7306 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7307 print
'<input type="hidden" name="action" value="addproperty">';
7308 print
'<input type="hidden" name="tab" value="objects">';
7309 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag(
$module).
'">';
7310 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
7312 print
'<div class="div-table-responsive">';
7313 print
'<table class="noborder small">';
7315 print
'<tr class="liste_titre">';
7325 foreach ($tabs as $tab) {
7326 $parts = explode(
':', $tab[
'data']);
7328 $objectType = $parts[0];
7329 $tabName = $parts[1];
7330 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
7331 $langFile = isset($parts[3]) ? $parts[3] :
'';
7332 $condition = isset($parts[4]) ? $parts[4] :
'';
7333 $path = isset($parts[5]) ? $parts[5] :
'';
7337 if ($tabName[0] ===
'-') {
7339 $condition = isset($parts[2]) ? $parts[2] :
'';
7342 print
'<tr class="oddeven">';
7349 if ($tabName[0] ===
"+") {
7350 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
7352 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
7375 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
7385 $content = file_get_contents($fullpathoffile);
7388 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
7389 print
'<input type="hidden" name="token" value="'.newToken().
'">';
7390 print
'<input type="hidden" name="action" value="savefile">';
7391 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
7392 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
7393 print
'<input type="hidden" name="module" value="'.$module.
'">';
7395 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
7396 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
7397 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
7400 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
7402 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
7409 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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
static fromAlternatives(array $alternatives, string $message='')
Build a policy from the editor of ModuleBuilder: the predicates of an alternative are combined with A...
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.
const PREDICATES
PHP rendered for each predicate.
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_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
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.
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)
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.
applyModuleBuilderAccessPolicyToPage(string $file, ?AccessPolicyConfig $policy)
Apply an access policy to a generated object page.
applyModuleBuilderAccessPolicyToClass(string $file, ?AccessPolicyConfig $policy)
Store an access policy in the generated object class.
getModuleBuilderCardActionUncommentPatterns($marker)
Build the regular expressions removing the comment fence of a card action generated in 'activate' mod...
getModuleBuilderAccessPolicyFromClassFile(string $file)
Load the access policy stored in a generated object class by renderModuleBuilderAccessPolicyProperty(...
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...
getModuleBuilderAccessPolicyPages()
Return the object pages whose read access is driven by the access policy defined in ModuleBuilder.
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.
treeview li table
No Email.