33if (!defined(
'NOSCANPOSTFORINJECTION')) {
34 define(
'NOSCANPOSTFORINJECTION',
'1');
38require
'../main.inc.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/modulebuilder.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
58$langs->loadLangs(array(
"admin",
"modulebuilder",
"exports",
"other",
"cron",
"errors",
"uxdocumentation"));
61$action =
GETPOST(
'action',
'aZ09');
62$confirm =
GETPOST(
'confirm',
'alpha');
63$cancel =
GETPOST(
'cancel',
'alpha');
65$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66$sortorder =
GETPOST(
'sortorder',
'aZ09');
68$module = (string)
GETPOST(
'module',
'alpha');
69$tab = (string)
GETPOST(
'tab',
'aZ09');
70$tabobj =
GETPOST(
'tabobj',
'alpha');
71$tabdic =
GETPOST(
'tabdic',
'alpha');
72$propertykey =
GETPOST(
'propertykey',
'alpha');
74 $module =
'initmodule';
79'@phan-var-force string $tab';
81 $tabobj =
'newobjectifnoobj';
84 $tabdic =
'newdicifnodic';
86$file =
GETPOST(
'file',
'alpha');
87$find =
GETPOST(
'find',
'alpha');
92$editorname = (string)
GETPOST(
'editorname',
'alpha');
93$editorurl = (string)
GETPOST(
'editorurl',
'alpha');
94$version = (string)
GETPOST(
'version',
'alpha');
95$family = (string)
GETPOST(
'family',
'alpha');
96$picto = (string)
GETPOST(
'idpicto',
'alpha');
97$idmodule = (string)
GETPOST(
'idmodule',
'alpha');
104if (!$user->hasRight(
"modulebuilder",
"run")) {
109$tmp = explode(
',', $dolibarr_main_document_root_alt);
114$tmpdir = explode(
'@', $module);
115if (!empty($tmpdir[1])) {
116 $module = $tmpdir[0];
117 $dirread = $tmpdir[1];
120if (
GETPOST(
'dirins',
'alpha')) {
121 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
125$FILEFLAG =
'modulebuilder.txt';
132if (empty($newmask)) {
141$form =
new Form($db);
144$dirsrootforscan = array($dirread);
148 $dirsrootforscan[] = DOL_DOCUMENT_ROOT;
152$textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
153$listofmodules = array();
154'@phan-var-force array<string,array{modulenamewithcase:string,moduledescriptorrelpath:string,moduledescriptorfullpath:string,moduledescriptorrootpath,moduletype?:string}> $listofmodules';
156foreach ($dirsrootforscan as $tmpdirread) {
157 $moduletype =
'external';
158 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
159 $moduletype =
'internal';
162 $dirsincustom =
dol_dir_list($tmpdirread,
'directories');
163 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
164 foreach ($dirsincustom as $dircustomcursor) {
165 $fullname = $dircustomcursor[
'fullname'];
168 $dirtoscanrel = basename($fullname).
'/core/modules/';
170 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
171 if (empty($descriptorfiles)) {
172 $dirtoscanrel =
'core/modules/';
173 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.strtoupper(basename($fullname)).
'\.class\.php$');
175 $modulenamewithcase =
'';
176 $moduledescriptorrelpath =
'';
177 $moduledescriptorfullpath =
'';
179 foreach ($descriptorfiles as $descriptorcursor) {
180 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
181 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
182 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
183 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
186 if ($modulenamewithcase) {
187 $listofmodules[$dircustomcursor[
'name']] = array(
188 'modulenamewithcase' => $modulenamewithcase,
189 'moduledescriptorrelpath' => $moduledescriptorrelpath,
190 'moduledescriptorfullpath' => $moduledescriptorfullpath,
191 'moduledescriptorrootpath' => $tmpdirread,
192 'moduletype' => $moduletype
200 if ($forceddirread && empty($listofmodules)) {
201 $listofmodules[strtolower($module)] = array(
202 'modulenamewithcase' => $module,
203 'moduledescriptorrelpath' =>
'notyetimplemented',
204 'moduledescriptorfullpath' =>
'notyetimplemented',
205 'moduledescriptorrootpath' =>
'notyetimplemented',
210 $newdircustom = $dirins;
211 if (empty($newdircustom)) {
217 $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
219 $textforlistofdirs .=
', ';
221 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$tmpdirread.
'</strong>';
222 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
224 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
227 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
240 $error = error_get_last();
241 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
243 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
245 if (headers_sent()) {
250register_shutdown_function(
"moduleBuilderShutdownFunction");
262function getLicenceHeader($user, $langs, $now)
264 $licInfo = $user->getFullName($langs);
265 $emailTabs = str_repeat(
"\t", (
int) (max(0, (31 - mb_strlen($licInfo)) / 4)));
266 $licInfo .= ($user->email ? $emailTabs.
'<'.$user->email.
'>' :
'');
276if ($dirins && $action ==
'initmodule' && $modulename ) {
277 $modulename = ucfirst($modulename);
278 $destdir =
'/not_set/';
280 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
282 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
286 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
287 $destdir = $dirins.
'/'.strtolower($modulename);
289 $arrayreplacement = array(
290 'mymodule' => strtolower($modulename),
291 'MyModule' => $modulename
293 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayreplacement);
298 $langs->load(
"errors");
299 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
302 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
308 $tryToCopyFromSetupClass =
true;
309 $backportDest = $destdir .
'/backport/v16/core/class';
310 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
311 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
316 $langs->load(
"errors");
317 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
318 $tryToCopyFromSetupClass =
false;
321 if ($tryToCopyFromSetupClass) {
322 $result =
dol_copy($backportFileSrc, $backportFileDest);
326 $langs->load(
"errors");
327 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
329 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
352 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
353 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
371 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
372 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
374 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
375 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
376 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
377 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
392 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
394 $licInfo = getLicenceHeader($user, $langs, $now);
395 foreach ($listofphpfilestoedit as $phpfileval) {
397 $arrayreplacement = array(
398 'mymodule' => strtolower($modulename),
399 'MyModule' => $modulename,
400 'MYMODULE' => strtoupper($modulename),
401 'My module' => $modulename,
402 'my module' => $modulename,
403 'Mon module' => $modulename,
404 'mon module' => $modulename,
405 'htdocs/modulebuilder/template' => strtolower($modulename),
406 '---Put here your own copyright and developer email---' => $licInfo,
407 '---Replace with your own copyright and developer email---' => $licInfo,
408 'Editor name' => $editorname,
409 'https://www.example.com' => $editorurl,
410 '$this->version = \'1.0\'' =>
'$this->version = \''.$version.
'\'',
411 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
412 "modulefamily" => $family,
413 '500000' => $idmodule
417 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
"\t\t" .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
424 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
429 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
431 file_put_contents($destdir.
'/README.md',
getDolGlobalString(
"MODULEBUILDER_SPECIFIC_README"));
443 $module = $modulename;
445 clearstatcache(
true);
446 if (function_exists(
'opcache_invalidate')) {
450 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
455$destdir =
'/not_set/';
456$destfile =
'/not_set/';
457$srcfile =
'/not_set/';
460if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module) ) {
461 $modulename = ucfirst($module);
462 $objectname = $tabobj;
463 $varnametoupdate =
'';
464 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
465 $destdir = $dirins.
'/'.strtolower($module);
471 if ($action ==
'initapi') {
472 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
473 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php',
'0', 1);
475 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
476 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
477 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
478 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
479 } elseif ($action ==
'initphpunit') {
480 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
481 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
482 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
483 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
484 } elseif ($action ==
'initpagecontact') {
485 dol_mkdir($dirins.
'/'.strtolower($module));
486 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
487 $srcfile = $srcdir.
'/myobject_contact.php';
488 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
489 $varnametoupdate =
'showtabofpagecontact';
490 } elseif ($action ==
'initpagedocument') {
491 dol_mkdir($dirins.
'/'.strtolower($module));
492 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
493 $srcfile = $srcdir.
'/myobject_document.php';
494 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
495 $varnametoupdate =
'showtabofpagedocument';
496 } elseif ($action ==
'initpagenote') {
497 dol_mkdir($dirins.
'/'.strtolower($module));
498 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
499 $srcfile = $srcdir.
'/myobject_note.php';
500 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
501 $varnametoupdate =
'showtabofpagenote';
502 } elseif ($action ==
'initpageagenda') {
503 dol_mkdir($dirins.
'/'.strtolower($module));
504 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
505 $srcfile = $srcdir.
'/myobject_agenda.php';
506 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
507 $varnametoupdate =
'showtabofpageagenda';
510 if (!file_exists($destfile)) {
511 $result =
dol_copy($srcfile, $destfile,
'0', 0);
516 $arrayreplacement = array(
517 'mymodule' => strtolower($modulename),
518 'MyModule' => $modulename,
519 'MYMODULE' => strtoupper($modulename),
520 'My module' => $modulename,
521 'my module' => $modulename,
522 'Mon module' => $modulename,
523 'mon module' => $modulename,
524 'htdocs/modulebuilder/template' => strtolower($modulename),
525 'myobject' => strtolower($objectname),
526 'MyObject' => $objectname,
527 'MYOBJECT' => strtoupper($objectname),
529 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
532 if ($action ==
'initapi') {
533 if (count($objects) >= 1) {
541 if ($varnametoupdate) {
543 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
544 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
549 $langs->load(
"errors");
550 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
556if ($dirins && $action ==
'initsqlextrafields' && !empty($module) ) {
557 $modulename = ucfirst($module);
558 $objectname = $tabobj;
560 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
561 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
562 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
563 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
564 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
565 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
566 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
567 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
569 if ($result1 > 0 && $result2 > 0) {
570 $modulename = ucfirst($module);
573 $arrayreplacement = array(
574 'mymodule' => strtolower($modulename),
575 'MyModule' => $modulename,
576 'MYMODULE' => strtoupper($modulename),
577 'My module' => $modulename,
578 'my module' => $modulename,
579 'Mon module' => $modulename,
580 'mon module' => $modulename,
581 'htdocs/modulebuilder/template' => strtolower($modulename),
582 'My Object' => $objectname,
583 'MyObject' => $objectname,
584 'my object' => strtolower($objectname),
585 'myobject' => strtolower($objectname),
586 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
592 $langs->load(
"errors");
594 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
597 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
602 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
603 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
604 $arrayreplacement = array(
'/\$isextrafieldmanaged = 0;/' =>
'$isextrafieldmanaged = 1;');
610if ($dirins && $action ==
'inithook' && !empty($module) ) {
611 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
612 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
613 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
614 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
615 $result =
dol_copy($srcfile, $destfile,
'0', 0);
618 $modulename = ucfirst($module);
621 $arrayreplacement = array(
622 'mymodule' => strtolower($modulename),
623 'MyModule' => $modulename,
624 'MYMODULE' => strtoupper($modulename),
625 'My module' => $modulename,
626 'my module' => $modulename,
627 'Mon module' => $modulename,
628 'mon module' => $modulename,
629 'htdocs/modulebuilder/template' => strtolower($modulename),
630 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
636 $langs->load(
"errors");
637 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
643if ($dirins && $action ==
'inittrigger' && !empty($module) ) {
644 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
645 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
646 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
647 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
648 $result =
dol_copy($srcfile, $destfile,
'0', 0);
651 $modulename = ucfirst($module);
654 $arrayreplacement = array(
655 'mymodule' => strtolower($modulename),
656 'MyModule' => $modulename,
657 'MYMODULE' => strtoupper($modulename),
658 'My module' => $modulename,
659 'my module' => $modulename,
660 'Mon module' => $modulename,
661 'mon module' => $modulename,
662 'htdocs/modulebuilder/template' => strtolower($modulename),
663 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
669 $langs->load(
"errors");
670 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
676if ($dirins && $action ==
'initwidget' && !empty($module) ) {
677 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
678 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
679 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
680 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
681 $result =
dol_copy($srcfile, $destfile,
'0', 0);
684 $modulename = ucfirst($module);
687 $arrayreplacement = array(
688 'mymodule' => strtolower($modulename),
689 'MyModule' => $modulename,
690 'MYMODULE' => strtoupper($modulename),
691 'My module' => $modulename,
692 'my module' => $modulename,
693 'Mon module' => $modulename,
694 'mon module' => $modulename,
695 'htdocs/modulebuilder/template' => strtolower($modulename),
696 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
702 $langs->load(
"errors");
703 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
709if ($dirins && $action ==
'initemailing' && !empty($module) ) {
710 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
711 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
712 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
713 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
714 $result =
dol_copy($srcfile, $destfile,
'0', 0);
717 $modulename = ucfirst($module);
720 $arrayreplacement = array(
721 'mymodule' => strtolower($modulename),
722 'MyModule' => $modulename,
723 'MYMODULE' => strtoupper($modulename),
724 'My module' => $modulename,
725 'my module' => $modulename,
726 'Mon module' => $modulename,
727 'mon module' => $modulename,
728 'htdocs/modulebuilder/template' => strtolower($modulename),
729 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
735 $langs->load(
"errors");
736 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
742if ($dirins && $action ==
'initcss' && !empty($module) ) {
743 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
744 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
745 $srcfile = $srcdir.
'/css/mymodule.css.php';
746 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
747 $result =
dol_copy($srcfile, $destfile,
'0', 0);
750 $modulename = ucfirst($module);
753 $arrayreplacement = array(
754 'mymodule' => strtolower($modulename),
755 'MyModule' => $modulename,
756 'MYMODULE' => strtoupper($modulename),
757 'My module' => $modulename,
758 'my module' => $modulename,
759 'Mon module' => $modulename,
760 'mon module' => $modulename,
761 'htdocs/modulebuilder/template' => strtolower($modulename),
762 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
769 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
770 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
773 $langs->load(
"errors");
774 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
780if ($dirins && $action ==
'initjs' && !empty($module) ) {
781 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
782 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
783 $srcfile = $srcdir.
'/js/mymodule.js.php';
784 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
785 $result =
dol_copy($srcfile, $destfile,
'0', 0);
788 $modulename = ucfirst($module);
791 $arrayreplacement = array(
792 'mymodule' => strtolower($modulename),
793 'MyModule' => $modulename,
794 'MYMODULE' => strtoupper($modulename),
795 'My module' => $modulename,
796 'my module' => $modulename,
797 'Mon module' => $modulename,
798 'mon module' => $modulename,
799 'htdocs/modulebuilder/template' => strtolower($modulename),
800 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
807 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
808 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
811 $langs->load(
"errors");
812 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
818if ($dirins && $action ==
'initcli' && !empty($module) ) {
819 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
820 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
821 $srcfile = $srcdir.
'/scripts/mymodule.php';
822 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
823 $result =
dol_copy($srcfile, $destfile,
'0', 0);
826 $modulename = ucfirst($module);
829 $arrayreplacement = array(
830 'mymodule' => strtolower($modulename),
831 'MyModule' => $modulename,
832 'MYMODULE' => strtoupper($modulename),
833 'My module' => $modulename,
834 'my module' => $modulename,
835 'Mon module' => $modulename,
836 'mon module' => $modulename,
837 'htdocs/modulebuilder/template' => strtolower($modulename),
838 '__MYCOMPANY_NAME__' =>
$mysoc->name,
839 '__KEYWORDS__' => $modulename,
840 '__USER_FULLNAME__' => $user->getFullName($langs),
841 '__USER_EMAIL__' => $user->email,
843 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
849 $langs->load(
"errors");
850 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
855$moduledescriptorfile =
'/not_set/';
856$modulelowercase =
null;
859if ($dirins && $action ==
'initdoc' && !empty($module) ) {
860 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
861 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
862 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
863 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
864 $result =
dol_copy($srcfile, $destfile,
'0', 0);
867 $modulename = ucfirst($module);
868 $modulelowercase = strtolower($module);
871 $arrayreplacement = array(
872 'mymodule' => strtolower($modulename),
873 'MyModule' => $modulename,
874 'MYMODULE' => strtoupper($modulename),
875 'My module' => $modulename,
876 'my module' => $modulename,
877 'Mon module' => $modulename,
878 'mon module' => $modulename,
879 'htdocs/modulebuilder/template' => strtolower($modulename),
880 '__MYCOMPANY_NAME__' =>
$mysoc->name,
881 '__KEYWORDS__' => $modulename,
882 '__USER_FULLNAME__' => $user->getFullName($langs),
883 '__USER_EMAIL__' => $user->email,
885 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
892 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
893 $destdir = $dirins.
'/'.strtolower($module);
895 foreach ($objects as $path => $obj) {
900 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
904 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
905 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
910 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
911 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
912 $string = file_get_contents($changeLog);
914 $replace = explode(
"\n", $string);
915 $strreplace = array();
916 foreach ($replace as $line) {
920 if (strpos($line,
'##') !==
false) {
921 $strreplace[$line] = str_replace(
'##',
'', $line);
923 $strreplace[$line] = $line;
926 $stringLog = implode(
"\n", $strreplace);
928 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
932 $FILENAMEDOC = $modulelowercase.
'.html';
933 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
934 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
935 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
936 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
937 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
942 $langs->load(
"errors");
943 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
949if ($dirins && $action ==
'addlanguage' && !empty($module) ) {
950 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
953 $modulelowercase = strtolower($module);
958 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
960 $diroflang = $dolibarr_main_document_root;
962 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
963 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
965 $result =
dol_copy($srcfile, $destfile,
'0', 0);
967 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
970 $srcdir = $diroflang.
'/langs/en_US';
971 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
972 $destdir = $diroflang.
'/langs/'.$newlangcode;
974 $arrayofreplacement = array();
976 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
977 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
979 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
982 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
988if ($dirins && $action ==
'confirm_removefile' && !empty($module) ) {
989 $objectname = $tabobj;
990 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
991 $destdir = $dirins.
'/'.strtolower($module);
996 if ($relativefilename) {
997 $dirnametodelete = dirname($relativefilename);
998 $filetodelete = $dirins.
'/'.$relativefilename;
999 $dirtodelete = $dirins.
'/'.$dirnametodelete;
1004 $keyofobjecttodelete = array_search($objectname, $objects);
1005 if ($keyofobjecttodelete !==
false) {
1006 unset($objects[$keyofobjecttodelete]);
1010 if (strpos($relativefilename,
'api') !==
false) {
1011 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
1015 if (count($objects) == 0) {
1027 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1030 if (preg_match(
'/\.sql$/', $relativefilename)) {
1031 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1032 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1033 $filetodelete = $dirins.
'/'.$relativefilename;
1035 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1036 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1037 $filetodelete = $dirins.
'/'.$relativefilename;
1047 if (in_array($tab, array(
'css',
'js'))) {
1048 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1049 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1053 if (preg_match(
'/_extrafields/', $relativefilename)) {
1055 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1056 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1061 $varnametoupdate =
'';
1063 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1064 $varnametoupdate =
'showtabofpage'.$reg[1];
1066 if ($varnametoupdate) {
1067 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1068 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1076if ($dirins && $action ==
'initobject' && $module && $objectname ) {
1079 $objectname = ucfirst($objectname);
1081 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1082 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1084 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1086 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1087 $tabobj =
'newobject';
1089 if (class_exists($objectname)) {
1092 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1093 $tabobj =
'newobject';
1096 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1097 $destdir = $dirins.
'/'.strtolower($module);
1109 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1110 $alreadyfound =
false;
1111 foreach ($dirlist as $key => $val) {
1112 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1113 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1114 $alreadyfound =
true;
1116 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1124 $stringforproperties =
'';
1125 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1127 $_results = $db->DDLDescTable($tablename);
1128 if (empty($_results)) {
1130 $langs->load(
"errors");
1131 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1180 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1181 $stringforproperties .=
'public $fields = array('.
"\n";
1183 while ($obj = $db->fetch_object($_results)) {
1185 $fieldname = $obj->Field;
1188 if ($type ==
'int(11)') {
1190 } elseif ($type ==
'float') {
1192 } elseif (strstr($type,
'tinyint')) {
1194 } elseif (strstr($type,
'url')) {
1195 $type =
'varchar(255)';
1196 } elseif ($obj->Field ==
'fk_soc') {
1197 $type =
'integer:Societe:societe/class/societe.class.php';
1198 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1199 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1200 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1201 $type =
'integer:Product:product/class/product.class.php:1';
1202 } elseif ($obj->Field ==
'fk_warehouse') {
1203 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1204 } elseif (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1205 $type =
'integer:User:user/class/user.class.php';
1209 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1210 if ($fieldname ==
'fk_user_modif') {
1214 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1215 if ($fieldname ==
'rowid') {
1216 $label =
'TechnicalID';
1218 if ($fieldname ==
'import_key') {
1219 $label =
'ImportId';
1221 if ($fieldname ==
'fk_soc') {
1222 $label =
'ThirdParty';
1224 if (in_array($fieldname, array(
'tms',
'date_modification'))) {
1225 $label =
'DateModification';
1227 if (in_array($fieldname, array(
'datec',
'date_creation'))) {
1228 $label =
'DateCreation';
1230 if ($fieldname ==
'date_valid') {
1231 $label =
'DateValidation';
1233 if ($fieldname ==
'datev') {
1234 $label =
'DateValidation';
1236 if ($fieldname ==
'note_private') {
1237 $label =
'NotePublic';
1239 if ($fieldname ==
'note_public') {
1240 $label =
'NotePrivate';
1242 if ($fieldname ==
'fk_user_creat') {
1243 $label =
'UserAuthor';
1245 if ($fieldname ==
'fk_user_modif') {
1246 $label =
'UserModif';
1248 if ($fieldname ==
'fk_user_valid') {
1249 $label =
'UserValidation';
1253 if (in_array($fieldname, array(
'ref',
'label'))) {
1256 if ($fieldname ==
'entity') {
1259 if ($fieldname ==
'entity') {
1262 if ($fieldname ==
'import_key') {
1265 if ($fieldname ==
'fk_user_creat') {
1268 if ($fieldname ==
'fk_user_modif') {
1271 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1278 if ($fieldname ==
'entity') {
1283 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1286 if ($fieldname ==
'import_key') {
1290 $alwayseditable = 0;
1291 if ($fieldname ==
'label') {
1292 $alwayseditable = 1;
1294 $alwayseditable = 0;
1298 if ($fieldname ==
'entity') {
1305 if (preg_match(
'/^fk_/', $fieldname)) {
1306 $css =
'maxwidth500 widthcentpercentminusxx';
1308 if ($fieldname ==
'label') {
1309 $css =
'minwidth300';
1310 $cssview =
'wordbreak';
1312 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1313 $cssview =
'wordbreak';
1315 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1316 $csslist =
'tdoverflowmax150';
1321 if (isset($obj->Picto)) {
1322 $picto = $obj->Picto;
1324 if (preg_match(
'/^fk_soc/', $obj->Field)) {
1326 } elseif (preg_match(
'/^fk_contact/', $obj->Field)) {
1328 } elseif (preg_match(
'/^fk_bank/', $obj->Field)) {
1330 } elseif (preg_match(
'/^fk_user/', $obj->Field)) {
1332 } elseif (preg_match(
'/^fk_warehouse/', $obj->Field)) {
1333 $picto =
'warehouse';
1334 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1336 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1338 } elseif (preg_match(
'/^fk_task/', $obj->Field)) {
1343 $lang = $module.
'@'.$module;
1346 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1347 if ($default !=
'') {
1348 $stringforproperties .=
" 'default' => ".$default.
",";
1350 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1351 $stringforproperties .=
" 'visible' => ".$visible;
1353 $stringforproperties .=
", 'notnull' => ".$notnull;
1355 if ($alwayseditable) {
1356 $stringforproperties .=
", 'alwayseditable' => 1";
1358 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1359 $stringforproperties .=
", 'showoncombobox' => 1";
1361 $stringforproperties .=
", 'position' => ".$position;
1363 $stringforproperties .=
", 'index' => ".$index;
1366 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1369 $stringforproperties .=
", 'css' => '".$css.
"'";
1372 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1375 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1378 $stringforproperties .=
", 'lang' => '".$lang.
"'";
1380 $stringforproperties .=
"),\n";
1383 $stringforproperties .=
');'.
"\n";
1384 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1388 $filetogenerate = array();
1391 $filetogenerate = array(
1392 'myobject_card.php' => strtolower($objectname).
'_card.php',
1393 'myobject_note.php' => strtolower($objectname).
'_note.php',
1394 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1395 'myobject_document.php' => strtolower($objectname).
'_document.php',
1396 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1397 'myobject_list.php' => strtolower($objectname).
'_list.php',
1398 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1399 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1401 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1402 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1403 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1404 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1406 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1408 'ajax/myobject.php' =>
'ajax/'.strtolower($objectname).
'.php',
1411 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1412 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1414 $filetogenerate += array(
1415 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1416 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1417 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1420 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1421 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1422 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1424 $filetogenerate += array(
1425 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1426 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1429 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1430 $firstobjectname =
'myobject';
1431 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1433 $class =
'mod'.$module;
1435 if (class_exists($class)) {
1438 '@phan-var-force DolibarrModules $moduleobj';
1450 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1452 if ($checkComment < 0) {
1453 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1455 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1456 if ($generatePerms < 0) {
1457 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1463 foreach ($filetogenerate as $srcfile => $destfile) {
1464 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1468 $langs->load(
"errors");
1469 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1472 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1475 $arrayreplacement = array(
1476 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1477 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1480 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1485 if (!$error && $stringforproperties) {
1487 $arrayreplacement = array(
1488 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1491 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1495 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1497 $arrayreplacement = array(
1498 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1502 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1504 $arrayreplacement = array(
1505 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1507 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1511 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1513 $arrayreplacement = array(
1514 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1516 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1517 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'',
'0', 0, 1);
1519 $arrayreplacement = array(
1520 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1523 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1530 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1532 $firstobjectname =
'';
1534 foreach ($listofobject as $fileobj) {
1535 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1538 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1542 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1544 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1545 $objectnameloop = $reg[1];
1546 if (empty($firstobjectname)) {
1547 $firstobjectname = $objectnameloop;
1553 \$this->menu[\$r++] = array(
1554 'fk_menu' => 'fk_mainmenu=mymodule',
1556 'titre' => 'MyObject',
1557 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1558 'mainmenu' => 'mymodule',
1559 'leftmenu' => 'myobject',
1560 'url' => '/mymodule/myobject_list.php',
1561 'langs' => 'mymodule@mymodule',
1562 'position' => 1000 + \$r,
1563 'enabled' => 'isModEnabled(\"mymodule\")',
1564 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1567 'object' => 'MyObject'
1569 \$this->menu[\$r++] = array(
1570 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1572 'titre' => 'List MyObject',
1573 'mainmenu' => 'mymodule',
1574 'leftmenu' => 'mymodule_myobject_list',
1575 'url' => '/mymodule/myobject_list.php',
1576 'langs' => 'mymodule@mymodule',
1577 'position' => 1000 + \$r,
1578 'enabled' => 'isModEnabled(\"mymodule\")',
1579 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1582 'object' => 'MyObject'
1584 \$this->menu[\$r++] = array(
1585 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1587 'titre' => 'New MyObject',
1588 'mainmenu' => 'mymodule',
1589 'leftmenu' => 'mymodule_myobject_new',
1590 'url' => '/mymodule/myobject_card.php?action=create',
1591 'langs' => 'mymodule@mymodule',
1592 'position' => 1000 + \$r,
1593 'enabled' => 'isModEnabled(\"mymodule\")',
1594 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1597 'object' => 'MyObject'
1599 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1600 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1601 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1603 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1609 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1611 $class =
'mod'.$module;
1613 if (class_exists($class)) {
1616 '@phan-var-force DolibarrModules $moduleobj';
1629 foreach ($menus as $menu) {
1630 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1636 if ($checkComment < 0) {
1638 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1640 $arrayofreplacement = array(
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */' =>
'/* BEGIN MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.$stringtoadd.
"\n\t\t".
'/* END MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.
"\n\t\t".
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */');
1645 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1650 foreach ($filetogenerate as $destfile) {
1651 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1654 $arrayreplacement = array(
1655 'mymodule' => strtolower($module),
1656 'MyModule' => $module,
1657 'MYMODULE' => strtoupper($module),
1658 'My module' => $module,
1659 'my module' => $module,
1660 'mon module' => $module,
1661 'Mon module' => $module,
1662 'htdocs/modulebuilder/template/' => strtolower($modulename),
1663 'myobject' => strtolower($objectname),
1664 'MyObject' => $objectname,
1666 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
1670 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1676 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1685 if (is_numeric($object) && $object <= 0) {
1686 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1687 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1691 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1692 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1694 if (file_exists($destfile)) {
1700 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1709 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1710 $tabobj = $objectname;
1712 $tabobj =
'newobject';
1717 $result = unActivateModule(strtolower($module));
1722 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1723 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1729if ($dirins && $action ==
'initdic' && $module && empty($cancel) ) {
1730 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1731 $destdir = $dirins.
'/'.strtolower($module);
1732 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1736 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1740 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1743 $newdicname = $dicname;
1744 if (!preg_match(
'/^c_/', $newdicname)) {
1745 $newdicname =
'c_'.$dicname;
1748 $class =
'mod'.$module;
1750 if (class_exists($class)) {
1753 '@phan-var-force DolibarrModules $moduleobj';
1761 $langs->load(
"errors");
1762 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1767 if ($checkComment < 0) {
1768 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1771 if (function_exists(
'opcache_invalidate')) {
1774 clearstatcache(
true);
1775 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1782if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj) ) {
1783 $objectname = $tabobj;
1785 $arrayoftables = array();
1786 if ($action ==
'droptable') {
1787 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1789 if ($action ==
'droptableextrafields') {
1790 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1793 foreach ($arrayoftables as $tabletodrop) {
1795 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1796 $resql = $db->query($sql);
1798 $obj = $db->fetch_object($resql);
1800 $nb = (int) $obj->nb;
1803 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1804 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1810 $resql = $db->DDLDropTable($tabletodrop);
1812 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1813 } elseif ($nb > 0) {
1814 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1819if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) ) {
1824 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1825 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1827 $srcdir = $dirread.
'/'.strtolower($module);
1828 $destdir = $dirins.
'/'.strtolower($module);
1832 if (!in_array($objectname, array_values($objects))) {
1834 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1837 $addfieldentry = array();
1840 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1841 if (!
GETPOST(
'propname',
'aZ09')) {
1843 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1845 if (!
GETPOST(
'proplabel',
'alpha')) {
1847 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1849 if (!
GETPOST(
'proptype',
'alpha')) {
1851 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1855 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1859 $proptype =
GETPOST(
'proptype',
'alpha');
1860 if (strpos($proptype,
':') ===
false && strpos($proptype,
'_') ===
false) {
1861 $proptype = strtolower($proptype);
1863 $addfieldentry = array(
1864 'name' =>
GETPOST(
'propname',
'aZ09'),
1865 'label' =>
GETPOST(
'proplabel',
'alpha'),
1866 'type' => $proptype,
1867 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'nohtml'),
1868 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1869 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1873 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1875 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1876 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1877 'help' =>
GETPOST(
'prophelp',
'alpha'),
1878 'css' =>
GETPOST(
'propcss',
'alpha'),
1879 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1880 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1881 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1882 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
1887 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1888 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1890 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1893 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1905 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1911 if (is_numeric($object) && $object <= 0) {
1912 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1913 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1920 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1923 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1929 clearstatcache(
true);
1931 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1936 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1941if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey ) {
1942 $objectname = $tabobj;
1944 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1945 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1947 $srcdir = $dirread.
'/'.strtolower($module);
1948 $destdir = $dirins.
'/'.strtolower($module);
1955 if (is_numeric($object) && $object <= 0) {
1956 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1957 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1964 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1967 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1973 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1975 clearstatcache(
true);
1978 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1983if ($dirins && $action ==
'confirm_deletemodule' ) {
1984 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1986 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1990 $modulelowercase = strtolower($module);
1993 $dir = $dirins.
'/'.$modulelowercase;
1995 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2005 $class =
'mod'.$module;
2009 if (class_exists($class)) {
2012 '@phan-var-force DolibarrModules $moduleobj';
2020 $langs->load(
"errors");
2021 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
2033 clearstatcache(
true);
2034 if (function_exists(
'opcache_invalidate')) {
2038 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2046 $module =
'deletemodule';
2049if ($dirins && $action ==
'confirm_deleteobject' && $objectname ) {
2050 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2052 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2056 $modulelowercase = strtolower($module);
2057 $objectlowercase = strtolower($objectname);
2060 $dir = $dirins.
'/'.$modulelowercase;
2063 $filetodelete = array(
2064 'myobject_card.php' => strtolower($objectname).
'_card.php',
2065 'myobject_note.php' => strtolower($objectname).
'_note.php',
2066 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
2067 'myobject_document.php' => strtolower($objectname).
'_document.php',
2068 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
2069 'myobject_list.php' => strtolower($objectname).
'_list.php',
2070 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
2071 'ajax/myobject.lib.php' =>
'ajax/'.strtolower($objectname).
'.php',
2072 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
2073 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
2074 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
2075 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
2076 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
2077 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
2078 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
2079 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
2080 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2081 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2082 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2083 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2084 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2085 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2090 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2092 $class =
'mod'.$module;
2094 if (class_exists($class)) {
2097 '@phan-var-force DolibarrModules $moduleobj';
2105 $langs->load(
"errors");
2106 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2109 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2115 if ($rewriteMenu < 0) {
2116 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2118 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2124 if ($rewritePerms < 0) {
2125 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2129 if ($rewritePerms && $rewriteMenu) {
2131 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2134 clearstatcache(
true);
2135 if (function_exists(
'opcache_invalidate')) {
2139 foreach ($filetodelete as $tmpfiletodelete) {
2141 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2147 if ($resultko == 0) {
2150 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2157 $tabobj =
'newobject';
2159 $tabobj =
'deleteobject';
2164 $result = unActivateModule(strtolower($module));
2169 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2170 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2175if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) ) {
2176 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2177 $destdir = $dirins.
'/'.strtolower($module);
2178 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2180 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2182 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2185 if (!empty($dicname)) {
2186 $newdicname = $dicname;
2187 if (!preg_match(
'/^c_/', $newdicname)) {
2188 $newdicname =
'c_'.strtolower($dicname);
2195 $class =
'mod'.$module;
2197 if (class_exists($class)) {
2200 '@phan-var-force DolibarrModules $moduleobj';
2208 $langs->load(
"errors");
2209 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2215 if ($checkComment < 0) {
2217 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2220 if (!empty(
GETPOST(
'dictionnarykey'))) {
2221 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2225 $checkTable =
false;
2226 if ($newdicname !==
null) {
2227 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2230 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2235 $keyToDelete =
null;
2236 foreach ($dicts[
'tabname'] as $key => $table) {
2238 if (strtolower($table) === $newdicname) {
2239 $keyToDelete = $key;
2244 if ($keyToDelete !==
null) {
2245 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2246 foreach ($keysToDelete as $key) {
2247 unset($dicts[$key][$keyToDelete]);
2251 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2253 if (!$error && $newdicname !==
null) {
2255 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2256 if ($_results < 0) {
2258 $langs->load(
"errors");
2259 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2264 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2266 if (function_exists(
'opcache_invalidate')) {
2269 clearstatcache(
true);
2270 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2274if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') ) {
2275 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2277 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2278 $destdir = $dirins.
'/'.strtolower($module);
2279 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2281 $class =
'mod'.$module;
2283 if (class_exists($class)) {
2286 '@phan-var-force DolibarrModules $moduleobj';
2294 $langs->load(
"errors");
2295 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2300 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2301 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2303 if ($checkComment < 0) {
2304 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2307 if ($updateDict > 0) {
2310 if (function_exists(
'opcache_invalidate')) {
2313 clearstatcache(
true);
2314 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2320if ($dirins && $action ==
'generatedoc' ) {
2321 $modulelowercase = strtolower($module);
2326 $FILENAMEDOC = strtolower($module).
'.html';
2328 $util =
new Utils($db);
2329 $result = $util->generateDoc($module);
2332 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2338if ($dirins && $action ==
'generatepackage' ) {
2339 $modulelowercase = strtolower($module);
2341 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2351 $class =
'mod'.$module;
2353 if (class_exists($class)) {
2356 '@phan-var-force DolibarrModules $moduleobj';
2364 $langs->load(
"errors");
2365 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2369 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2370 if (count($arrayversion)) {
2371 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2374 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2380 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2383 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2386 $langs->load(
"errors");
2387 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2391 $langs->load(
"errors");
2392 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2397if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel) ) {
2401 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2403 $class =
'mod'.$module;
2405 if (class_exists($class)) {
2408 '@phan-var-force DolibarrModules $moduleobj';
2417 if (!
GETPOST(
'label',
'alpha')) {
2419 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2421 if (!
GETPOST(
'permissionObj',
'alpha')) {
2423 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2427 $label =
GETPOST(
'label',
'alpha');
2428 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2429 $crud =
GETPOST(
'crud',
'alpha');
2433 $permsForObject = array();
2437 $permissions = array();
2439 $allObject = array();
2441 $countPerms = count($permissions);
2443 for ($i = 0; $i < $countPerms; $i++) {
2444 if ($permissions[$i][4] == $objectForPerms) {
2446 if (count($permsForObject) < 3) {
2447 $permsForObject[] = $permissions[$i];
2450 $allObject[] = $permissions[$i][4];
2454 $countPermsObj = count($permsForObject);
2455 for ($j = 0; $j < $countPermsObj; $j++) {
2456 if (in_array($crud, $permsForObject[$j])) {
2458 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2462 $rightToAdd = array();
2464 $key = $countPerms + 1;
2466 $rightToAdd = array(
2469 4 => $objectForPerms,
2474 $result = unActivateModule(strtolower($module));
2479 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2482 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2486 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2491 clearstatcache(
true);
2492 if (function_exists(
'opcache_invalidate')) {
2495 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2503if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) ) {
2506 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2508 $class =
'mod'.$module;
2510 if (class_exists($class)) {
2513 '@phan-var-force DolibarrModules $moduleobj';
2521 if (!
GETPOST(
'label',
'alpha')) {
2523 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2525 if (!
GETPOST(
'permissionObj',
'alpha')) {
2527 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2530 $label =
GETPOST(
'label',
'alpha');
2531 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2532 $crud =
GETPOST(
'crud',
'alpha');
2535 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2539 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2543 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2555 if (array_key_exists($key, $permissions)) {
2556 $x1 = $permissions[$key][1];
2557 $x2 = $permissions[$key][4];
2558 $x3 = $permissions[$key][5];
2566 $permsForObject = array();
2570 $allObject = array();
2572 $countPerms = count($permissions);
2573 for ($i = 0; $i < $countPerms; $i++) {
2574 if ($permissions[$i][4] == $objectForPerms) {
2576 if (count($permsForObject) < 3) {
2577 $permsForObject[] = $permissions[$i];
2580 $allObject[] = $permissions[$i][4];
2583 if ($label != $x1 && $crud != $x3) {
2584 $countPermsObj = count($permsForObject);
2585 for ($j = 0; $j < $countPermsObj; $j++) {
2586 if (in_array($label, $permsForObject[$j])) {
2588 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2595 $result = unActivateModule(strtolower($module));
2600 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2603 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2607 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2609 $rightUpdated =
null;
2612 clearstatcache(
true);
2613 if (function_exists(
'opcache_invalidate')) {
2616 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2622if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey') ) {
2625 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2627 $class =
'mod'.$module;
2629 if (class_exists($class)) {
2632 '@phan-var-force DolibarrModules $moduleobj';
2646 $result = unActivateModule(strtolower($module));
2651 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2652 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2657 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2660 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2665 clearstatcache(
true);
2666 if (function_exists(
'opcache_invalidate')) {
2670 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2676if ($action ==
'savefile' && empty($cancel) ) {
2677 $relofcustom = basename($dirins);
2681 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2682 $file = $relofcustom.
'/'.$file;
2690 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2693 $check =
'restricthtml';
2695 if ($srclang ==
'md') {
2696 $check =
'restricthtml';
2698 if ($srclang ==
'lang') {
2699 $check =
'restricthtml';
2701 if ($srclang ==
'php') {
2705 $content =
GETPOST(
'editfilecontent', $check);
2710 $result = file_put_contents($pathoffile, $content);
2727if ($action ==
'set' && $user->admin ) {
2730 $param .=
'&module='.urlencode($module);
2733 $param .=
'&tab='.urlencode($tab);
2734 $param .=
'&tabobj='.urlencode($tabobj);
2736 $value =
GETPOST(
'value',
'alpha');
2737 $resarray = activateModule($value);
2738 if (!empty($resarray[
'errors'])) {
2742 if ($resarray[
'nbperms'] > 0) {
2743 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2744 $resqltmp = $db->query($tmpsql);
2746 $obj = $db->fetch_object($resqltmp);
2748 if ($obj && $obj->nb > 1) {
2749 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2757 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2762if ($action ==
'reset' && $user->admin ) {
2765 $param .=
'&module='.urlencode($module);
2767 $param .=
'&tab='.urlencode($tab);
2768 $param .=
'&tabobj='.urlencode($tabobj);
2770 $value =
GETPOST(
'value',
'alpha');
2771 $result = unActivateModule(strtolower($value));
2775 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2780if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') ) {
2783 $result = unActivateModule(strtolower($module));
2788 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2789 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2793 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2795 $class =
'mod'.$module;
2797 if (class_exists($class)) {
2800 '@phan-var-force DolibarrModules $moduleobj';
2808 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2809 $destdir = $dir.
'/'.strtolower($module);
2811 $result = array_map(
'strtolower', $objects);
2815 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2818 if ($checkcomment < 0) {
2819 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2821 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2822 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2823 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2831 clearstatcache(
true);
2832 if (function_exists(
'opcache_invalidate')) {
2837 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2843if ($dirins && $action ==
'addmenu' && empty($cancel) ) {
2846 $result = unActivateModule(strtolower($module));
2851 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2852 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2858 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2860 $class =
'mod'.$module;
2862 if (class_exists($class)) {
2865 '@phan-var-force DolibarrModules $moduleobj';
2876 if (!
GETPOST(
'type',
'alpha')) {
2878 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2880 if (!
GETPOST(
'titre',
'alpha')) {
2882 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2884 if (!
GETPOST(
'user',
'alpha')) {
2886 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2888 if (!
GETPOST(
'url',
'alpha')) {
2890 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2892 if (!empty(
GETPOST(
'target'))) {
2893 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2894 if (!in_array(
GETPOST(
'target'), $targets)) {
2896 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2903 foreach ($menus as $menu) {
2906 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2909 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2911 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2916 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2917 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2919 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2922 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2923 $destdir = $dirins.
'/'.strtolower($module);
2926 if (
GETPOST(
'type',
'alpha') ==
'left') {
2927 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2929 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2932 if (
GETPOST(
'type',
'alpha') ==
'top') {
2934 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2937 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2941 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2942 'type' =>
GETPOST(
'type',
'alpha'),
2943 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2945 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2946 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2947 'url' =>
GETPOST(
'url',
'alpha'),
2948 'langs' => strtolower($module).
"@".strtolower($module),
2950 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2951 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2952 'target' =>
GETPOST(
'target',
'alpha'),
2956 if (
GETPOST(
'type') ==
'left') {
2957 unset($menuToAdd[
'prefix']);
2958 if (empty(
GETPOST(
'fk_menu'))) {
2959 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2961 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2964 if (
GETPOST(
'enabled') ==
'1') {
2965 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2967 $menuToAdd[
'enabled'] =
"0";
2969 if (empty(
GETPOST(
'objects'))) {
2970 $menuToAdd[
'perms'] =
'1';
2974 if ($checkcomment < 0) {
2975 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2978 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2980 clearstatcache(
true);
2981 if (function_exists(
'opcache_invalidate')) {
2990 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2998if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') ) {
2999 $objectname =
GETPOST(
'tabobj');
3000 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3001 $destdir = $dirins.
'/'.strtolower($module);
3004 if (empty($cancel)) {
3006 $result = unActivateModule(strtolower($module));
3011 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3012 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3017 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3019 $class =
'mod'.$module;
3021 if (class_exists($class)) {
3024 '@phan-var-force DolibarrModules $moduleobj';
3034 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3036 $menuModify = array(
3037 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3038 'type' =>
GETPOST(
'type',
'alpha'),
3039 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
3041 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3042 'leftmenu' => $menus[$key][
'leftmenu'],
3043 'url' =>
GETPOST(
'url',
'alpha'),
3044 'langs' => strtolower($module).
"@".strtolower($module),
3046 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3047 'perms' =>
GETPOST(
'perms',
'alpha'),
3048 'target' =>
GETPOST(
'target',
'alpha'),
3051 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3052 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3053 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3054 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3056 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3058 if ($menuModify[
'enabled'] ===
'') {
3059 $menuModify[
'enabled'] =
'1';
3061 if ($menuModify[
'perms'] ===
'') {
3062 $menuModify[
'perms'] =
'1';
3065 if (
GETPOST(
'type',
'alpha') ==
'top') {
3067 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3074 if ($checkComment < 0) {
3075 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3078 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3080 clearstatcache(
true);
3081 if (function_exists(
'opcache_invalidate')) {
3088 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));
3093 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3098 $_POST[
'type'] =
'';
3099 $_POST[
'titre'] =
'';
3100 $_POST[
'fk_menu'] =
'';
3101 $_POST[
'leftmenu'] =
'';
3107if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) ) {
3109 $result = unActivateModule(strtolower($module));
3114 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3115 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3118 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3119 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3120 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
3124 $class =
'mod'.$module;
3126 if (class_exists($class)) {
3129 '@phan-var-force DolibarrModules $moduleobj';
3137 $keydescription =
GETPOST(
'keydescription',
'alpha');
3138 switch ($keydescription) {
3140 $propertyToUpdate =
'description';
3147 $propertyToUpdate = $keydescription;
3150 $error =
GETPOST(
'keydescription');
3154 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3155 $newValue =
GETPOST(
'propsmodule');
3156 $patternToFindLine =
'^\s*\$this->'.$propertyToUpdate.
'\s*=';
3157 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3159 $fileLines = file($moduledescriptorfile);
3162 foreach ($fileLines as &$line) {
3163 if (preg_match(
'/'.$patternToFindLine.
'/', $line)) {
3164 $result =
dolReplaceInFile($moduledescriptorfile, array($line => $newLine));
3167 } elseif ($result <= -1) {
3168 $langs->load(
"errors");
3169 setEventMessages($langs->trans(
'ErrorFailToEditFile', $moduledescriptorfile),
null,
'warnings');
3177 if ($changedone && $propertyToUpdate ===
'version') {
3181 clearstatcache(
true);
3182 if (function_exists(
'opcache_invalidate')) {
3186 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3191 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3201$form =
new Form($db);
3212 '/includes/ace/src/ace.js',
3213 '/includes/ace/src/ext-statusbar.js',
3214 '/includes/ace/src/ext-language_tools.js',
3219llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3222$text = $langs->trans(
"ModuleBuilder");
3224$morehtmlright =
'<a href="'.DOL_URL_ROOT.
'/admin/tools/ui/index.php" target="_blank" rel="noopener">'.
img_picto(
'',
'book',
'class="pictofixedwidth"').$langs->trans(
"UxComponentsDoc").
'</a>';
3228print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development').
'</span>';
3229print
'<br class="hideonsmartphone">';
3238 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3243 $langs->load(
"errors");
3244 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3248 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3257$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3261$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3262$allowonlineinstall =
true;
3263if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3264 $allowonlineinstall =
false;
3266if (empty($allowonlineinstall)) {
3269 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3272 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3287if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3288 $modulelowercase = strtolower($module);
3289 $loadclasserrormessage =
'';
3293 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3298 $class =
'mod'.$module;
3299 }
catch (Throwable $e) {
3300 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3301 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3302 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3306 if (class_exists($class)) {
3309 '@phan-var-force DolibarrModules $moduleobj';
3313 print $e->getMessage();
3316 if (empty($forceddirread)) {
3319 $langs->load(
"errors");
3320 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3321 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3322 print $loadclasserrormessage;
3333$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3334$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3335$head[$h][2] =
'initmodule';
3338$linktoenabledisable =
'';
3340if ( count($listofmodules) > 0) {
3342 $modulelowercase = strtolower($module);
3346 $param .=
'&module='.urlencode($module);
3349 $param .=
'&tab='.urlencode($tab);
3350 $param .=
'&tabobj='.urlencode($tabobj);
3352 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3356 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3357 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'', 0, 0, 0,
'',
'', 1);
3358 $linktoenabledisable .=
'</a>';
3360 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3363 $backtourlparam =
'';
3364 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3365 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3366 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3369 if (is_array($objMod->config_page_url)) {
3371 foreach ($objMod->config_page_url as $page) {
3374 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3377 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3378 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3379 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
3383 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3384 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
3388 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3389 $linktoenabledisable .=
' <a href="'.dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1).
'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 8px"').
'</a>';
3393 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3394 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip', 1);
3395 $linktoenabledisable .=
"</a>\n";
3400 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3401 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3402 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3403 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3405 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3406 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3413$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3414$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3415$head[$h][2] =
'deletemodule';
3421if ($module ==
'initmodule') {
3423 print
'<!-- section init module -->'.
"\n";
3424 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3425 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3426 print
'<input type="hidden" name="action" value="initmodule">';
3427 print
'<input type="hidden" name="module" value="initmodule">';
3432 print
'<div class="tagtable table-border">';
3434 print
'<div class="tagtr"><div class="tagtd paddingright">';
3435 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3436 print
'</div><div class="tagtd">';
3437 print
'<input type="number" min="100000" name="idmodule" class="width100" value="500000">';
3438 print
'<span class="opacitymedium small">';
3439 print
' ';
3440 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info&hidetitle=1',
'',
'');
3442 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3444 print
'</div></div>';
3446 print
'<div class="tagtr"><div class="tagtd paddingright">';
3447 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3448 print
'</div><div class="tagtd">';
3449 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3450 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3451 print
'</div></div>';
3453 print
'<div class="tagtr"><div class="tagtd paddingright">';
3454 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3455 print
'</div><div class="tagtd">';
3456 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3457 print
'</div></div>';
3459 print
'<div class="tagtr"><div class="tagtd paddingright">';
3460 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3461 print
'</div><div class="tagtd">';
3462 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")).
'">';
3463 print
'</div></div>';
3465 print
'<div class="tagtr"><div class="tagtd paddingright">';
3466 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3467 print
'</div><div class="tagtd">';
3468 print
'<select name="family" id="family" class="minwidth400">';
3469 $arrayoffamilies = array(
3470 'hr' =>
"ModuleFamilyHr",
3471 'crm' =>
"ModuleFamilyCrm",
3472 'srm' =>
"ModuleFamilySrm",
3473 'financial' =>
'ModuleFamilyFinancial',
3474 'products' =>
'ModuleFamilyProducts',
3475 'projects' =>
'ModuleFamilyProjects',
3476 'ecm' =>
'ModuleFamilyECM',
3477 'technic' =>
'ModuleFamilyTechnic',
3478 'portal' =>
'ModuleFamilyPortal',
3479 'interface' =>
'ModuleFamilyInterface',
3480 'base' =>
'ModuleFamilyBase',
3481 'other' =>
'ModuleFamilyOther'
3483 foreach ($arrayoffamilies as $key => $value) {
3484 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>';
3488 print
'</div></div>';
3490 print
'<div class="tagtr"><div class="tagtd paddingright">';
3491 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3492 print
'</div><div class="tagtd">';
3493 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3494 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3496 print
' ';
3498 print
'<span class="opacitymedium small">';
3499 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',
'',
'');
3502 print
'</div></div>';
3504 print
'<div class="tagtr"><div class="tagtd paddingright">';
3505 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3506 print
'</div><div class="tagtd">';
3508 print
'</div></div>';
3510 print
'<div class="tagtr"><div class="tagtd paddingright">';
3511 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3512 print
'</div><div class="tagtd">';
3513 print
'<input type="text" name="editorurl" value="'.(GETPOSTISSET(
'editorurl') ?
GETPOST(
'editorurl') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_URL',
$mysoc->url)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorUrl")).
'"><br>';
3514 print
'</div></div>';
3518 print
'<br><center>';
3519 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3522} elseif ($module ==
'deletemodule') {
3523 print
'<!-- Form to init a module -->'.
"\n";
3524 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3525 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3526 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3527 print
'<input type="hidden" name="module" value="deletemodule">';
3529 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3531 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3532 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3534} elseif (!empty($module) && $modulelowercase !==
null) {
3537 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3538 $destdir = $dirread.
'/'.strtolower($module);
3542 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3556 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3557 $head2[$h][1] = $langs->trans(
"Description");
3558 $head2[$h][2] =
'description';
3561 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3562 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3563 $head2[$h][2] =
'objects';
3566 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3567 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3568 $head2[$h][2] =
'languages';
3571 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3572 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3573 $head2[$h][2] =
'permissions';
3576 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3577 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3578 $head2[$h][2] =
'dictionaries';
3581 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3582 $head2[$h][1] = $langs->trans(
"Tabs");
3583 $head2[$h][2] =
'tabs';
3586 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3587 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3588 $head2[$h][2] =
'menus';
3591 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3592 $head2[$h][1] = $langs->trans(
"Hooks");
3593 $head2[$h][2] =
'hooks';
3596 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3597 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3598 $head2[$h][2] =
'triggers';
3601 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3602 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3603 $head2[$h][2] =
'widgets';
3606 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3607 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3608 $head2[$h][2] =
'emailings';
3611 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3612 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3613 $head2[$h][2] =
'exportimport';
3616 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3617 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3618 $head2[$h][2] =
'css';
3621 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3622 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3623 $head2[$h][2] =
'js';
3626 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3627 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3628 $head2[$h][2] =
'cli';
3631 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3632 $head2[$h][1] = $langs->trans(
"CronList");
3633 $head2[$h][2] =
'cron';
3636 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3637 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="marginleftonlyshort badge">'.$hasDoc.
"</span>");
3638 $head2[$h][2] =
'specifications';
3641 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3642 $head2[$h][1] = $langs->trans(
"BuildPackage");
3643 $head2[$h][2] =
'buildpackage';
3646 $MAXTABFOROBJECT = 12;
3648 print
'<!-- Section for a given module -->';
3652 if ($tab ==
'description') {
3653 print
'<!-- tab=description -->'.
"\n";
3654 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3655 $pathtofilereadme = $modulelowercase.
'/README.md';
3656 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3658 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3660 if ($action !=
'editfile' || empty($file)) {
3661 $morehtmlright =
'';
3662 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3663 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3666 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3668 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3674 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3675 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>';
3679 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3680 foreach ($listofsetuppages as $setuppage) {
3683 print
'<span class="fa fa-file"></span> ';
3684 if ($setuppage[
'relativename'] ==
'about.php') {
3685 print $langs->trans(
"AboutFile");
3687 print $langs->trans(
"SetupFile");
3690 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3691 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>';
3695 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3696 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>';
3699 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3700 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>';
3706 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3709 print
'<div class="underbanner clearboth"></div>';
3710 print
'<div class="fichecenter">';
3711 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3712 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3713 print
'<input type="hidden" name="action" value="update_props_module">';
3714 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3715 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3716 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3718 print
'<div class="div-table-responsive-no-min">';
3719 print
'<table class="border centpercent">';
3720 print
'<tr class="liste_titre"><td class="titlefield">';
3721 print $langs->trans(
"Parameter");
3723 print $langs->trans(
"Value");
3727 print $langs->trans(
"IdModule");
3730 print
'<span class="opacitymedium">';
3732 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3733 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3738 print $langs->trans(
"ModuleName");
3744 print $langs->trans(
"Description");
3746 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3747 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'">';
3748 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3749 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3752 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>';
3754 $moduledescritpionautotrans =
$moduleobj->getDesc();
3755 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
3757 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3758 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
3760 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3766 print $langs->trans(
"Version");
3768 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3769 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
3770 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3771 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3774 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>';
3779 print $langs->trans(
"Family");
3782 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3783 print
'<select name="propsmodule" id="family" class="minwidth400">';
3784 $arrayoffamilies = array(
3785 'hr' =>
"ModuleFamilyHr",
3786 'crm' =>
"ModuleFamilyCrm",
3787 'srm' =>
"ModuleFamilySrm",
3788 'financial' =>
'ModuleFamilyFinancial',
3789 'products' =>
'ModuleFamilyProducts',
3790 'projects' =>
'ModuleFamilyProjects',
3791 'ecm' =>
'ModuleFamilyECM',
3792 'technic' =>
'ModuleFamilyTechnic',
3793 'portal' =>
'ModuleFamilyPortal',
3794 'interface' =>
'ModuleFamilyInterface',
3795 'base' =>
'ModuleFamilyBase',
3796 'other' =>
'ModuleFamilyOther'
3798 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>';
3799 foreach ($arrayoffamilies as $key => $value) {
3801 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3805 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3806 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3809 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>';
3813 print
'<!-- picto of module -->'.
"\n";
3815 print $langs->trans(
"Picto");
3817 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3818 print
'<input class="minwidth200 maxwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'">';
3820 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\'');
3822 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3823 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3825 print
' ';
3827 print
'<span class="opacitymedium small">';
3828 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',
'',
'');
3832 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3833 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>';
3838 print $langs->trans(
"EditorName");
3840 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3841 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'">';
3842 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3843 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3846 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>';
3851 print $langs->trans(
"EditorUrl");
3853 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3854 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'">';
3855 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3856 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3859 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3861 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>';
3869 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3876 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3878 print
'<!-- readme file -->';
3879 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3880 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3882 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3888 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3890 print
'<!-- changelog file -->';
3892 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3894 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3903 if ($fullpathoffile) {
3904 $content = file_get_contents($fullpathoffile);
3908 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3909 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3910 print
'<input type="hidden" name="action" value="savefile">';
3911 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3912 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3913 print
'<input type="hidden" name="module" value="'.$module.
'">';
3917 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
3918 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3919 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3924 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3926 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3932 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3935 if ($tab ==
'languages') {
3936 print
'<!-- tab=languages -->'.
"\n";
3937 if ($action !=
'editfile' || empty($file)) {
3938 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3942 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3943 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3944 print
'<input type="hidden" name="action" value="addlanguage">';
3945 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3946 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3947 print
'<input type="hidden" name="module" value="'.$module.
'">';
3948 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
3949 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3955 $modulelowercase = strtolower($module);
3959 $diroflang .=
'/langs';
3960 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3962 if (!preg_match(
'/custom/', $dirread)) {
3964 $diroflang = $dirread;
3965 $diroflang .=
'/langs';
3966 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3969 print
'<table class="none">';
3970 foreach ($langfiles as $langfile) {
3971 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3972 if (!preg_match(
'/custom/', $dirread)) {
3973 $pathtofile =
'langs/'.$langfile[
'relativename'];
3975 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3976 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>';
3977 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>';
3988 $content = file_get_contents($fullpathoffile);
3991 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3992 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3993 print
'<input type="hidden" name="action" value="savefile">';
3994 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3995 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3996 print
'<input type="hidden" name="module" value="'.$module.
'">';
3998 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3999 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
4002 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4004 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4011 if ($tab ==
'objects') {
4012 print
'<!-- tab=objects -->'.
"\n";
4017 $dir = $dirread.
'/'.$modulelowercase.
'/class';
4019 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
4020 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4021 $head3[$h][2] =
'newobject';
4025 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
4027 $firstobjectname =
'';
4028 foreach ($listofobject as $fileobj) {
4029 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
4032 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
4036 $tmpcontent = file_get_contents($fileobj[
'fullname']);
4037 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
4039 $objectname = $reg[1];
4040 if (empty($firstobjectname)) {
4041 $firstobjectname = $objectname;
4043 $pictoname =
'generic';
4044 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
4045 $pictoname = $reg[1];
4048 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
4049 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
4050 $head3[$h][2] = $objectname;
4056 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4057 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4058 $head3[$h][2] =
'deleteobject';
4063 if ($tabobj ==
'newobjectifnoobj') {
4064 if ($firstobjectname) {
4065 $tabobj = $firstobjectname;
4067 $tabobj =
'newobject';
4071 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4074 if ($tabobj ==
'newobject') {
4076 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4077 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4078 print
'<input type="hidden" name="action" value="initobject">';
4079 print
'<input type="hidden" name="tab" value="objects">';
4080 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4082 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4084 print
'<div class="tagtable">';
4086 print
'<div class="tagtr"><div class="tagtd">';
4087 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4088 print
'</div><div class="tagtd">';
4089 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
4090 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4091 print
'</div></div>';
4093 print
'<div class="tagtr"><div class="tagtd">';
4094 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4095 print
'</div><div class="tagtd">';
4096 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4098 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\'');
4100 print
'<span class="opacitymedium small">';
4101 print
' ';
4102 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',
'',
'');
4105 print
'</div></div>';
4107 print
'<div class="tagtr"><div class="tagtd">';
4108 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4109 print
'</div><div class="tagtd">';
4110 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4111 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4112 print
'</div></div>';
4117 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>';
4118 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4119 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4121 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4137 } elseif ($tabobj ==
'createproperty') {
4138 $attributesUnique = array(
4139 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4140 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4141 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4142 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4143 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4144 'propdefault' => $langs->trans(
"DefaultValue"),
4145 'propindex' => $langs->trans(
"DatabaseIndex"),
4146 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4147 'propposition' => $langs->trans(
"Position"),
4148 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4149 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4150 'propnoteditable' => $langs->trans(
"NotEditable"),
4152 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4153 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4154 'propcss' => $langs->trans(
"CSSClass"),
4155 'propcssview' => $langs->trans(
"CSSViewClass"),
4156 'propcsslist' => $langs->trans(
"CSSListClass"),
4157 'prophelp' => $langs->trans(
"KeyForTooltip"),
4158 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4160 'propcomment' => $langs->trans(
"Comment"),
4162 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4163 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4164 print
'<input type="hidden" name="action" value="addproperty">';
4165 print
'<input type="hidden" name="tab" value="objects">';
4166 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4167 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4169 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4171 foreach ($attributesUnique as $key => $attribute) {
4172 if ($counter % 2 === 0) {
4175 if ($key ==
'propname' || $key ==
'proplabel') {
4176 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>';
4177 } elseif ($key ==
'proptype') {
4178 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4179 print
'<input class="maxwidth200" name="'.$key.
'" id="'.$key.
'" list="datalist'.$key.
'" type="text" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4181 print
'<datalist id="datalist'.$key.
'">';
4182 print
'<option>varchar(128)</option>';
4183 print
'<option>email</option>';
4184 print
'<option>phone</option>';
4185 print
'<option>ip</option>';
4186 print
'<option>url</option>';
4187 print
'<option>password</option>';
4188 print
'<option>text</option>';
4189 print
'<option>html</option>';
4190 print
'<option>date</option>';
4191 print
'<option>datetime</option>';
4192 print
'<option>integer</option>';
4193 print
'<option>stars(5)</option>';
4194 print
'<option>double(28,4)</option>';
4195 print
'<option>real</option>';
4196 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4205 print
'</datalist>';
4209 } elseif ($key ==
'propvisible') {
4210 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>';
4211 } elseif ($key ==
'propenabled') {
4214 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>';
4215 } elseif ($key ==
'proparrayofkeyval') {
4216 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>';
4218 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>';
4221 if ($counter % 2 === 0) {
4225 if ($counter % 2 !== 0) {
4226 while ($counter % 2 !== 0) {
4232 print
'</table><br>'.
"\n";
4233 print
'<div class="center">';
4234 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4235 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4241 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4242 window.location.href = url;
4244 $(document).ready(function() {
4245 $("#proplabel").on("keyup", function() {
4246 console.log("key up on label");
4247 s = cleanString($("#proplabel").val());
4248 $("#propname").val(s);
4251 function cleanString( stringtoclean )
4253 // allow "a-z", "A-Z", "0-9" and "_"
4254 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4255 stringtoclean = stringtoclean.toLowerCase();
4256 if (!isNaN(stringtoclean)) {
4259 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4260 stringtoclean = stringtoclean.substr(1)
4262 if (stringtoclean.length > 28) {
4263 stringtoclean = stringtoclean.substring(0, 27);
4265 return stringtoclean;
4270 } elseif ($tabobj ==
'deleteobject') {
4272 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4273 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4274 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4275 print
'<input type="hidden" name="tab" value="objects">';
4276 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4277 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4279 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4281 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4282 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4286 if ($action ==
'deleteproperty') {
4287 $formconfirm = $form->formconfirm(
4288 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4289 $langs->trans(
'Delete'),
4290 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4291 'confirm_deleteproperty',
4300 if ($action !=
'editfile' || empty($file)) {
4304 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4305 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4306 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4307 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4308 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4309 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4310 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4311 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4312 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4315 clearstatcache(
true);
4316 if (function_exists(
'opcache_invalidate')) {
4317 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4320 if (empty($forceddirread) && empty($dirread)) {
4322 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4324 $result = include_once $dirread.
'/'.$pathtoclass;
4325 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4328 if (class_exists($tabobj)) {
4330 $tmpobject = @
new $tabobj($db);
4332 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4335 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4339 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4342 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4345 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4348 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4351 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4352 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4355 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4358 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4361 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4364 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4366 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4368 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4369 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4371 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4372 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4374 $tmpobject = $tmpobject ??
null;
4375 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4376 $pathtopicto = $tmpobject->picto;
4377 $realpathtopicto =
'';
4379 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4380 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4385 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4386 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4387 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4388 $realpathtocard = $dirread.
'/'.$pathtocard;
4389 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4390 $realpathtolist = $dirread.
'/'.$pathtolist;
4391 $realpathtonote = $dirread.
'/'.$pathtonote;
4392 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4393 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4394 $realpathtosql = $dirread.
'/'.$pathtosql;
4395 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4396 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4397 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4398 $realpathtolib = $dirread.
'/'.$pathtolib;
4399 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4401 if (empty($realpathtoapi)) {
4402 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4403 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4413 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4414 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.(
dol_is_file($realpathtopicto) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtopicto).(
dol_is_file($realpathtopicto) ?
'' :
'</strike>').
'</strong>';
4415 $htmltooltip .=
'<br>';
4416 } elseif (!empty($tmpobject)) {
4417 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4418 $htmltooltip .=
'<br>';
4420 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsExtraFieldManaged").
' : '.
yn(empty($tmpobject->isextrafieldmanaged) ? 0 : 1, 1, 2);
4421 $htmltooltip .=
'<br>';
4422 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsMultiEntityManaged").
' : '.
yn(empty($tmpobject->ismultientitymanaged) ? 0 : 1, 1, 2);
4423 $htmltooltip .=
'<br>';
4425 print
'<!-- section for object -->';
4426 print
'<div class="fichehalfleft smallxxx">';
4428 print
'<span class="fa fa-file"></span> '.$langs->trans(
"ClassFile").
' : <strong>'.(
dol_is_file($realpathtoclass) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoclass).(
dol_is_file($realpathtoclass) ?
'' :
'</strike>').
'</strong>';
4429 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>';
4430 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmiddle', 1);
4435 print
'<span class="fa fa-file"></span> '.$langs->trans(
"ApiClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoapi) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoapi).(
dol_is_file($realpathtoapi) ?
'' :
'</span></strike>').
'</strong>';
4437 $file = file_get_contents($realpathtoapi);
4438 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4439 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>';
4441 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>';
4442 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4446 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4448 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4451 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>';
4454 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>';
4458 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TestClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtophpunit) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtophpunit).(
dol_is_file($realpathtophpunit) ?
'' :
'</span></strike>').
'</strong>';
4460 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>';
4462 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>';
4464 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>';
4470 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtolib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtolib).(
dol_is_file($realpathtolib) ?
'' :
'</strike>').
'</strong>';
4471 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>';
4473 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForObjLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoobjlib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoobjlib).(
dol_is_file($realpathtoobjlib) ?
'' :
'</strike>').
'</strong>';
4474 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>';
4478 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosql) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosql).(
dol_is_file($realpathtosql) ?
'' :
'</strike>').
'</strong>';
4479 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>';
4480 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>';
4483 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileKey").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlkey) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlkey).(
dol_is_file($realpathtosqlkey) ?
'' :
'</strike>').
'</strong>';
4484 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>';
4487 if (!empty($tmpobject->isextrafieldmanaged)) {
4488 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextra) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextra).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4490 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>';
4492 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>';
4494 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>';
4496 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>';
4501 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SqlFileKeyExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextrakey) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextrakey).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4503 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>';
4505 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>';
4507 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>';
4513 print
'<div class="fichehalfleft smallxxxx">';
4514 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(
'/^'.strtolower($module).
'\//',
'', $pathtolist).(
dol_is_file($realpathtolist) ?
'' :
'</span></strike>').
'</a></strong>';
4515 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>';
4517 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(
'/^'.strtolower($module).
'\//',
'', $pathtocard).(
dol_is_file($realpathtocard) ?
'' :
'</strike>').
'?action=create</a></strong>';
4518 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>';
4521 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForContactTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtocontact) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtocontact).(
dol_is_file($realpathtocontact) ?
'' :
'</span></strike>').
'</strong>';
4522 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>';
4525 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>';
4527 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>';
4531 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForDocumentTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtodocument) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtodocument).(
dol_is_file($realpathtodocument) ?
'' :
'</span></strike>').
'</strong>';
4532 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>';
4535 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>';
4537 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>';
4541 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForNoteTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtonote) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtonote).(
dol_is_file($realpathtonote) ?
'' :
'</span></strike>').
'</strong>';
4542 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>';
4545 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>';
4547 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>';
4551 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageForAgendaTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoagenda) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoagenda).(
dol_is_file($realpathtoagenda) ?
'' :
'</span></strike>').
'</strong>';
4552 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>';
4555 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>';
4557 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>';
4564 print
'<br><br><br>';
4566 if (!empty($tmpobject)) {
4567 $reflector =
new ReflectionClass($tabobj);
4568 $reflectorproperties = $reflector->getProperties();
4569 $reflectorpropdefault = $reflector->getDefaultProperties();
4573 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4574 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4575 print
'<input type="hidden" name="action" value="addproperty">';
4576 print
'<input type="hidden" name="tab" value="objects">';
4577 print
'<input type="hidden" name="page_y" value="">';
4578 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4579 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4581 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4582 print
'<br><br class="clearboth">';
4583 print
'<br class="clearboth">';
4585 $mod = strtolower($module);
4586 $obj = strtolower($tabobj);
4587 $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));
4588 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4590 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
4593 print
'<!-- Table with properties of object -->'.
"\n";
4594 print
'<div class="div-table-responsive">';
4595 print
'<table class="noborder small">';
4596 print
'<tr class="liste_titre">';
4597 if (!empty($conf->main_checkbox_left_column)) {
4598 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4600 print
'<th class="tdsticky tdstickygray">';
4601 $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>';
4602 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4605 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4607 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4608 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4609 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4610 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4611 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4612 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4613 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4614 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4615 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4616 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4618 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4619 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4620 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4621 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4622 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4623 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4624 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4626 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4627 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4628 if (empty($conf->main_checkbox_left_column)) {
4629 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4636 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4637 if (!empty($properties)) {
4639 foreach ($properties as $propkey => $propval) {
4654 $propname = $propkey;
4655 $proplabel = $propval[
'label'];
4656 $proptype = $propval[
'type'];
4657 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4658 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4659 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4660 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4661 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4662 $propposition = $propval[
'position'];
4663 $propenabled = $propval[
'enabled'];
4664 $propvisible = $propval[
'visible'];
4665 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4667 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4668 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4669 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4670 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4671 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4672 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4673 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4675 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4676 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4678 print
'<!-- line for object property -->'.
"\n";
4679 print
'<tr class="oddeven">';
4681 if (!empty($conf->main_checkbox_left_column)) {
4682 if ($action ==
'editproperty' && $propname == $propertykey) {
4683 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4684 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4685 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4688 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4689 if ($propname !=
'rowid') {
4690 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>';
4691 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>';
4696 print
'<td class="tdsticky tdstickygray">';
4699 if ($action ==
'editproperty' && $propname == $propertykey) {
4701 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4702 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4704 print
'<td class="tdoverflowmax150">';
4705 print
'<input name="proptype" id="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'" list="datalistproptype"></input>';
4707 print
'<datalist id="datalistproptype">';
4708 print
'<option>varchar(128)</option>';
4709 print
'<option>email</option>';
4710 print
'<option>phone</option>';
4711 print
'<option>ip</option>';
4712 print
'<option>url</option>';
4713 print
'<option>password</option>';
4714 print
'<option>text</option>';
4715 print
'<option>html</option>';
4716 print
'<option>date</option>';
4717 print
'<option>datetime</option>';
4718 print
'<option>integer</option>';
4719 print
'<option>stars(5)</option>';
4720 print
'<option>double(28,4)</option>';
4721 print
'<option>real</option>';
4722 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4731 print
'</datalist>';
4734 print
'<td class="tdoverflowmax200">';
4735 print
'<textarea name="proparrayofkeyval">';
4736 if (isset($proparrayofkeyval)) {
4737 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4741 print
'</textarea>';
4744 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4747 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4749 print
'<td class="center">';
4750 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4753 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4756 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4759 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4762 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4765 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4771 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4774 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4777 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4780 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4783 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4786 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4789 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4792 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4795 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4797 if (empty($conf->main_checkbox_left_column)) {
4798 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4799 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4800 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4804 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4807 print
'<td class="tdoverflowmax200">';
4810 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4811 $pictoType =
'varchar';
4812 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4813 $pictoType =
'link';
4814 } elseif (strpos($proptype,
'integer') === 0) {
4815 $pictoType = substr($proptype, 0, 3);
4816 } elseif (strpos($proptype,
'timestamp') === 0) {
4817 $pictoType =
'datetime';
4818 } elseif (strpos($proptype,
'real') === 0) {
4819 $pictoType =
'double';
4820 } elseif (strpos($proptype,
'stars') === 0) {
4821 $pictoType =
'stars';
4825 print
'<td class="tdoverflowmax200">';
4826 if ($proparrayofkeyval) {
4827 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4832 print
'<td class="center">';
4838 print
'<td class="center">';
4839 print $propindex ?
'1' :
'';
4841 print
'<td class="center">';
4844 print
'<td class="right">';
4847 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4851 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4855 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4861 print
'<td class="center">';
4862 print $propsearchall ?
'1' :
'';
4864 print
'<td class="center">';
4867 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4870 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4873 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4877 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4880 print
'<td class="center">';
4886 print
'<td class="center">';
4889 print
'<td class="tdoverflowmax200">';
4890 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4894 if (empty($conf->main_checkbox_left_column)) {
4895 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4896 if ($propname !=
'rowid') {
4897 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>';
4898 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>';
4906 if ($tab ==
'specifications') {
4907 if ($action !=
'editfile' || empty($file)) {
4908 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4913 foreach ($specs as $spec) {
4914 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4915 $format =
'asciidoc';
4916 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4917 $format =
'markdown';
4919 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4920 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>';
4930 $content = file_get_contents($fullpathoffile);
4933 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4934 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4935 print
'<input type="hidden" name="action" value="savefile">';
4936 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4937 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4938 print
'<input type="hidden" name="module" value="'.$module.
'">';
4940 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4941 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4944 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4946 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4952 print
'<tr><td><span class="warning">'.$langs->trans(
'Property %s not found in the class. The class was probably not generated by modulebuilder.', $field).
'</warning></td></tr>';
4959 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4963 print $e->getMessage();
4967 if (empty($forceddirread)) {
4970 $fullpathoffile = $dirread.
'/'.$file;
4973 $content = file_get_contents($fullpathoffile);
4976 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4977 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4978 print
'<input type="hidden" name="action" value="savefile">';
4979 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4980 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4981 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4982 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4984 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4985 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4988 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4990 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5000 if ($tab ==
'dictionaries') {
5001 print
'<!-- tab=dictionaries -->'.
"\n";
5002 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5006 if ($action ==
'deletedict') {
5007 $formconfirm = $form->formconfirm(
5008 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5009 $langs->trans(
'Delete'),
5010 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
5011 'confirm_deletedictionary',
5019 if ($action !=
'editfile' || empty($file)) {
5020 print
'<span class="opacitymedium">';
5021 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
5022 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
5023 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5027 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5028 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>';
5030 if (is_array($dicts) && !empty($dicts)) {
5031 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
5032 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
5043 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
5044 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
5045 $head3[$h][2] =
'newdictionary';
5086 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).
'&tabdic=newdictionary');
5087 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
5089 if ($tabdic !=
'newdictionary') {
5090 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5091 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5092 print
'<input type="hidden" name="action" value="addDictionary">';
5093 print
'<input type="hidden" name="tab" value="dictionaries">';
5094 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5095 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
5097 print
'<div class="div-table-responsive">';
5098 print
'<table class="noborder">';
5100 print
'<tr class="liste_titre">';
5101 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
5114 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
5116 $maxi = count($dicts[
'tabname']);
5117 while ($i < $maxi) {
5118 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5119 print
'<tr class="oddeven">';
5120 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5121 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5122 print
'<input type="hidden" name="tab" value="dictionaries">';
5123 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5124 print
'<input type="hidden" name="action" value="updatedictionary">';
5125 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5127 print
'<td class="tdsticky tdstickygray">';
5132 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5136 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5140 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5144 print
'<select name="tabsqlsort">';
5145 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5149 print
'<td><select name="tabfield" >';
5150 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5151 print
'</select></td>';
5153 print
'<td><select name="tabfieldvalue" >';
5154 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5155 print
'</select></td>';
5157 print
'<td><select name="tabfieldinsert" >';
5158 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5159 print
'</select></td>';
5162 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5166 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5169 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5170 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5172 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5178 print
'<tr class="oddeven">';
5180 print
'<td class="tdsticky tdstickygray">';
5185 print $dicts[
'tabname'][$i];
5189 print $dicts[
'tablib'][$i];
5193 print $dicts[
'tabsql'][$i];
5197 print $dicts[
'tabsqlsort'][$i];
5201 print $dicts[
'tabfield'][$i];
5205 print $dicts[
'tabfieldvalue'][$i];
5209 print $dicts[
'tabfieldinsert'][$i];
5213 print $dicts[
'tabrowid'][$i];
5217 print $dicts[
'tabcond'][$i];
5220 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5221 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>';
5222 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>';
5230 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5239 if ($tabdic ==
'newdictionary') {
5241 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5242 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5243 print
'<input type="hidden" name="action" value="initdic">';
5244 print
'<input type="hidden" name="tab" value="dictionaries">';
5245 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5247 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5249 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5252 print
'<table class="border centpercent">';
5254 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>';
5255 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>';
5256 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>';
5257 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>';
5258 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5259 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5260 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5261 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5263 print
'</tbody></table>';
5264 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5265 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5269 $(document).ready(function() {
5270 $("input[name=\'dicname\']").on("blur", function() {
5271 if ($(this).val().length > 0) {
5272 $("input[name=\'label\']").val($(this).val());
5273 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5274 $("input[name=\'sqlsort\']").val("label ASC");
5275 $("input[name=\'field\']").val("code,label");
5276 $("input[name=\'fieldvalue\']").val("code,label");
5277 $("input[name=\'fieldinsert\']").val("code,label");
5278 $("input[name=\'rowid\']").val("rowid");
5280 $("input[name=\'label\']").val("");
5281 $("input[name=\'sql\']").val("");
5282 $("input[name=\'sqlsort\']").val("");
5283 $("input[name=\'field\']").val("");
5284 $("input[name=\'fieldvalue\']").val("");
5285 $("input[name=\'fieldinsert\']").val("");
5286 $("input[name=\'rowid\']").val("");
5289 $("input[id=\'cancel\']").click(function() {
5290 window.history.back();
5307 } elseif ($tabdic ==
'deletedictionary') {
5309 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5310 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5311 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5312 print
'<input type="hidden" name="tab" value="dictionaries">';
5313 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5315 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5317 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5318 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5326 $content = file_get_contents($fullpathoffile);
5329 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5330 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5331 print
'<input type="hidden" name="action" value="savefile">';
5332 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5333 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5334 print
'<input type="hidden" name="module" value="'.$module.
'">';
5336 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5337 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5338 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5341 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5343 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5350 if ($tab ==
'menus') {
5351 print
'<!-- tab=menus -->'.
"\n";
5352 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5353 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
5354 $destdir = $dirins.
'/'.strtolower($module);
5355 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5358 $leftmenus = array();
5363 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5366 $groupedRights = array();
5367 foreach ($permissions as $right) {
5369 if (!isset($groupedRights[$key])) {
5370 $groupedRights[$key] = array();
5372 $groupedRights[$key][] = $right;
5374 $groupedRights_json = json_encode($groupedRights);
5376 if ($action ==
'deletemenu') {
5377 $formconfirms = $form->formconfirm(
5378 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5379 $langs->trans(
'Delete'),
5380 ($menus[
GETPOST(
'menukey')][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module) ? $langs->trans(
'Warning: you will delete all menus linked to this one.',
GETPOSTINT(
'menukey')) : $langs->trans(
'Confirm Delete Menu',
GETPOSTINT(
'menukey'))),
5381 'confirm_deletemenu',
5386 print $formconfirms;
5388 if ($action !=
'editfile' || empty($file)) {
5389 print
'<span class="opacitymedium">';
5390 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5391 $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);
5392 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5397 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5398 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>';
5402 $listODifferentUrlsInMenu = array();
5403 foreach ($menus as $obj) {
5404 if (preg_match(
'/^\/'.preg_quote(strtolower($module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5405 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5408 $pathtofile = $obj[
'url'];
5409 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5410 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5411 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>';
5420 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5421 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5422 print
'<input type="hidden" name="action" value="addmenu">';
5423 print
'<input type="hidden" name="tab" value="menus">';
5424 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5425 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5427 print
'<div class="div-table-responsive">';
5428 print
'<table class="noborder small">';
5430 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5431 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5432 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5433 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(strtolower($module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5434 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5435 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5436 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(strtolower($module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5438 print
'<tr class="liste_titre">';
5439 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5442 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5445 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5447 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5448 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5449 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5450 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5451 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5452 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5455 $r = count($menus) + 1;
5458 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5459 print
'<td class="center">';
5460 print
'<select class="maxwidth50" name="type">';
5461 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5462 print
'</select></td>';
5463 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5464 print
'<td class="left">';
5465 print
'<select name="fk_menu">';
5466 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5467 foreach ($menus as $obj) {
5468 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5469 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5474 print
'<td class="left"><input type="text" class="left maxwidth50" name="mainmenu" value="'.(empty(
GETPOST(
'mainmenu')) ? strtolower($module) :
dol_escape_htmltag(
GETPOST(
'mainmenu',
'alpha'))).
'"></td>';
5475 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5477 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5478 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5480 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5482 print
'<td class="center">';
5483 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.$module.
'\')').
'">';
5492 print
'<td class="left">';
5493 print
'<select class="maxwidth" name="objects" id="objects">';
5494 print
'<option value=""></option>';
5495 if (is_array($objects)) {
5496 foreach ($objects as $value) {
5497 print
'<option value="'.strtolower($value).
'">'.
dol_escape_htmltag(strtolower($value)).
'</option>';
5501 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5504 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5505 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>';
5507 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5508 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5516 if (count($menus)) {
5518 foreach ($menus as $menu) {
5522 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
5524 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5525 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5526 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5527 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5528 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5529 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5530 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5531 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5532 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5534 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5535 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5539 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5541 print
'<tr class="oddeven">';
5542 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5543 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5544 print
'<input type="hidden" name="action" value="update_menu">';
5545 print
'<input type="hidden" name="tab" value="menus">';
5546 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5547 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5549 print
'<td class="tdsticky tdstickygray">';
5553 print
'<td class="center">
5554 <select class="center maxwidth50" name="type">
5555 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5558 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5559 if ($menu[
'type'] ==
'left') {
5564 print
'</option></select></td>';
5566 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5577 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5579 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5580 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5582 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5583 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5585 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5587 print
'<td class="nowraponall">';
5588 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag($module).
"')").
'">';
5589 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5590 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5591 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5592 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag($module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5593 print $form->textwithpicto('', $htmltext);
5595 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5596 print '<option value=
"1">1 (always enabled)</option>
';
5597 print '<option value=
"0">0 (always
disabled)</option>
';
5603 print '<td
class=
"nowraponall">
';
5604 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5606 if (!empty($objPerms)) {
5607 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5608 print '<select
class=
"center maxwidth50" name=
"perms">
';
5609 if (!empty($valPerms)) {
5610 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5611 foreach ($crud as $key => $val) {
5612 if ($valPerms != $key) {
5613 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5619 print '<select
class=
"center maxwidth50" name=
"objects">
';
5620 print '<option></option>
';
5621 foreach ($objects as $obj) {
5622 print '<option value=
"'.dol_escape_htmltag(strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5625 print '<select
class=
"center maxwidth50" name=
"perms">
';
5626 foreach ($crud as $key => $val) {
5627 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5633 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5634 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>
';
5635 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5636 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5637 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5642 print '<tr
class=
"oddeven">
';
5644 print '<td
class=
"tdsticky tdstickygray">
';
5648 print '<td
class=
"center">
';
5649 print dol_escape_htmltag($menu['type']);
5654 print dol_escape_htmltag($menu['titre
']);
5658 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5659 print dol_escape_htmltag($menu['fk_menu
']);
5663 print dol_escape_htmltag($menu['mainmenu
']);
5667 print dol_escape_htmltag($menu['leftmenu
']);
5670 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5671 print dol_escape_htmltag($menu['url
']);
5675 print dol_escape_htmltag($menu['langs
']);
5679 print '<td
class=
"center">
';
5680 print dol_escape_htmltag((string) $menu['position']);
5684 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5685 print dol_escape_htmltag($menu['enabled
']);
5689 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5690 print dol_escape_htmltag($langs->trans($menu['perms
']));
5694 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5695 print dol_escape_htmltag($menu['target
']);
5698 print '<td
class=
"center">
';
5699 if ($menu['user'] == 2) {
5700 print $langs->trans("AllMenus");
5701 } elseif ($menu['user'] == 0) {
5702 print $langs->trans('Internal
');
5703 } elseif ($menu['user'] == 1) {
5704 print $langs->trans('External
');
5706 print $menu['user']; // should not happen
5709 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
5710 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
5711 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>
';
5712 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>
';
5719 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
5728 $(document).ready(
function() {
5730 $(
"#leftmenu").on(
"input",
function() {
5731 var inputLeftMenu = $(
"#leftmenu").val();
5732 if (inputLeftMenu !== \
'\') {
5733 var url = \
''.dol_escape_js(strtolower($module)).
'\' + inputLeftMenu + \
'.php\';
5740 var groupedRights = ' . $groupedRights_json .
';
5741 var objectsSelect = $("select[id=\'objects\']");
5742 var permsSelect = $("select[id=\'perms\']");
5744 objectsSelect.change(function() {
5745 var selectedObject = $(this).val();
5747 permsSelect.empty();
5749 var rights = groupedRights[selectedObject];
5752 for (var i = 0; i < rights.length; i++) {
5753 var right = rights[i];
5754 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
5755 permsSelect.append(option);
5758 var option = $("<option></option>").attr("value", "read").text("read");
5759 permsSelect.append(option);
5762 if (selectedObject !== "" && selectedObject !== null && rights) {
5767 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
5778 $content = file_get_contents($fullpathoffile);
5781 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5782 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5783 print
'<input type="hidden" name="action" value="savefile">';
5784 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5785 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5786 print
'<input type="hidden" name="module" value="'.$module.
'">';
5788 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5789 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5790 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5793 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5795 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5802 if ($tab ==
'permissions') {
5803 print
'<!-- tab=permissions -->'.
"\n";
5804 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5809 $dir = $dirread.
'/'.$modulelowercase.
'/class';
5810 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
5811 $objects = array(
'myobject');
5813 foreach ($listofobject as $fileobj) {
5814 $tmpcontent = file_get_contents($fileobj[
'fullname']);
5815 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
5816 $objects[$fileobj[
'fullname']] = $reg[1];
5821 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5822 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
5824 $action =
GETPOST(
'action',
'alpha');
5826 if ($action ==
'deleteright') {
5827 $formconfirm = $form->formconfirm(
5828 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)),
5829 $langs->trans(
'Delete'),
5830 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
5831 'confirm_deleteright',
5839 if ($action !=
'editfile' || empty($file)) {
5840 print
'<!-- Tab to manage permissions -->'.
"\n";
5841 print
'<span class="opacitymedium">';
5842 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
5843 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
5844 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5848 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5849 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>';
5855 print
'<!-- form to add permissions -->'.
"\n";
5856 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5857 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5858 print
'<input type="hidden" name="action" value="addright">';
5859 print
'<input type="hidden" name="tab" value="permissions">';
5860 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5861 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5863 print
'<div class="div-table-responsive">';
5864 print
'<table class="noborder">';
5866 print
'<tr class="liste_titre">';
5868 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
5875 print
'<tr class="small">';
5876 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
5878 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
5879 print
'<option value=""></option>';
5880 foreach ($objects as $obj) {
5881 if ($obj !=
'myobject') {
5882 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
5885 print
'</select></td>';
5887 print
'<td><select class="maxwidth75" name="crud" id="crud">';
5888 print
'<option value=""></option>';
5889 foreach ($crud as $key => $val) {
5890 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
5895 print
'<input type="text" name="label" id="label" class="minwidth200">';
5898 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5899 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5903 if (count($perms)) {
5905 foreach ($perms as $perm) {
5909 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
5910 print
'<tr class="oddeven">';
5911 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
5912 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5913 print
'<input type="hidden" name="tab" value="permissions">';
5914 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5915 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5916 print
'<input type="hidden" name="action" value="update_right">';
5917 print
'<input type="hidden" name="counter" value="'.$i.
'">';
5919 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
5921 print
'<td class="tdsticky tdstickygray">';
5922 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
5926 print
'<select name="crud">';
5927 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
5928 foreach ($crud as $i => $x) {
5929 if ($perm[5] != $i) {
5930 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
5936 print
'<td><select name="permissionObj" >';
5937 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
5938 print
'</select></td>';
5941 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
5944 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5945 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
5947 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5954 print
'<tr class="oddeven">';
5961 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5969 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5970 print ucfirst($langs->trans($perm[5]));
5972 print ucfirst($langs->trans($perm[4]));
5977 print $langs->trans($perm[1]);
5980 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5981 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>';
5982 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>';
5990 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5998 function updateInputField() {
5999 value1 = $("#crud").val();
6000 value2 = $("#permissionObj").val();
6002 // Vérifie si les deux sélections sont faites
6003 if (value1 && value2) {
6004 switch(value1.toLowerCase()){
6006 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
6009 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
6012 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
6020 $("#crud, #permissionObj").change(function(){
6021 console.log("We change selection");
6029 $content = file_get_contents($fullpathoffile);
6032 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6033 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6034 print
'<input type="hidden" name="action" value="savefile">';
6035 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6036 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6037 print
'<input type="hidden" name="module" value="'.$module.
'">';
6039 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6040 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6041 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6044 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6046 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6053 if ($tab ==
'hooks') {
6054 print
'<!-- tab=hooks -->'.
"\n";
6055 if ($action !=
'editfile' || empty($file)) {
6056 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
6061 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6063 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6065 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>';
6069 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
6070 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
6072 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6074 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> ';
6075 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>';
6077 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6078 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>';
6085 $content = file_get_contents($fullpathoffile);
6088 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6089 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6090 print
'<input type="hidden" name="action" value="savefile">';
6091 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6092 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6093 print
'<input type="hidden" name="module" value="'.$module.
'">';
6095 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6096 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6097 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6100 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6102 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6109 if ($tab ==
'triggers') {
6110 print
'<!-- tab=triggers -->'.
"\n";
6111 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
6114 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
6116 if ($action !=
'editfile' || empty($file)) {
6117 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6122 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6124 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6126 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>';
6129 if (!empty($triggers)) {
6130 foreach ($triggers as $trigger) {
6131 $pathtofile = $trigger[
'relpath'];
6134 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6135 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>';
6136 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>';
6141 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6142 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6143 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>';
6152 $content = file_get_contents($fullpathoffile);
6155 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6156 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6157 print
'<input type="hidden" name="action" value="savefile">';
6158 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6159 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6160 print
'<input type="hidden" name="module" value="'.$module.
'">';
6162 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6163 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6164 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6167 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6169 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6176 if ($tab ==
'css') {
6177 print
'<!-- tab=css -->'.
"\n";
6178 if ($action !=
'editfile' || empty($file)) {
6179 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6185 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
6186 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6188 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6189 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>';
6190 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>';
6192 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6193 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>';
6199 $content = file_get_contents($fullpathoffile);
6202 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6203 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6204 print
'<input type="hidden" name="action" value="savefile">';
6205 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6206 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6207 print
'<input type="hidden" name="module" value="'.$module.
'">';
6209 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6210 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6213 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6215 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6223 print
'<!-- tab=js -->'.
"\n";
6224 if ($action !=
'editfile' || empty($file)) {
6225 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6231 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
6232 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6234 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6235 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>';
6236 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>';
6238 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6239 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>';
6245 $content = file_get_contents($fullpathoffile);
6248 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6249 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6250 print
'<input type="hidden" name="action" value="savefile">';
6251 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6252 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6253 print
'<input type="hidden" name="module" value="'.$module.
'">';
6255 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6256 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6259 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6261 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6268 if ($tab ==
'widgets') {
6269 print
'<!-- tab=widgets -->'.
"\n";
6270 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6274 if ($action !=
'editfile' || empty($file)) {
6275 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6279 if (!empty($widgets)) {
6280 foreach ($widgets as $widget) {
6281 $pathtofile = $widget[
'relpath'];
6283 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6284 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>';
6285 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>';
6289 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6290 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>';
6297 $content = file_get_contents($fullpathoffile);
6300 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6301 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6302 print
'<input type="hidden" name="action" value="savefile">';
6303 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6304 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6305 print
'<input type="hidden" name="module" value="'.$module.
'">';
6307 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6308 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6311 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6313 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6320 if ($tab ==
'emailings') {
6321 print
'<!-- tab=emailings -->'.
"\n";
6322 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6326 if ($action !=
'editfile' || empty($file)) {
6327 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6331 if (!empty($emailingselectors)) {
6332 foreach ($emailingselectors as $emailingselector) {
6333 $pathtofile = $emailingselector[
'relpath'];
6335 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6336 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>';
6337 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>';
6341 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6342 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>';
6349 $content = file_get_contents($fullpathoffile);
6352 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6353 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6354 print
'<input type="hidden" name="action" value="savefile">';
6355 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6356 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6357 print
'<input type="hidden" name="module" value="'.$module.
'">';
6359 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6360 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6363 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6365 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6372 if ($tab ==
'exportimport') {
6373 print
'<!-- tab=exportimport -->'.
"\n";
6374 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6379 if ($action !=
'editfile' || empty($file)) {
6380 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6383 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6384 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>';
6386 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6387 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>';
6392 $content = file_get_contents($fullpathoffile);
6395 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6396 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6397 print
'<input type="hidden" name="action" value="savefile">';
6398 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6399 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6400 print
'<input type="hidden" name="module" value="'.$module.
'">';
6402 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6403 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6404 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6407 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6409 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6416 if ($tab ==
'cli') {
6417 print
'<!-- tab=cli -->'.
"\n";
6418 $clifiles = array();
6421 $dircli = array(
'/'.strtolower($module).
'/scripts');
6423 foreach ($dircli as $reldir) {
6428 if (!is_dir($newdir)) {
6432 $handle = opendir($newdir);
6434 if (is_resource($handle)) {
6435 while (($tmpfile = readdir($handle)) !==
false) {
6436 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6437 if (preg_match(
'/\.back$/', $tmpfile)) {
6441 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6450 if ($action !=
'editfile' || empty($file)) {
6451 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6455 if (!empty($clifiles)) {
6456 foreach ($clifiles as $clifile) {
6457 $pathtofile = $clifile[
'relpath'];
6459 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6460 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>';
6461 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>';
6465 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6466 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>';
6473 $content = file_get_contents($fullpathoffile);
6476 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6477 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6478 print
'<input type="hidden" name="action" value="savefile">';
6479 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6480 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6481 print
'<input type="hidden" name="module" value="'.$module.
'">';
6483 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6484 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6487 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6489 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6496 if ($tab ==
'cron') {
6497 print
'<!-- tab=cron -->'.
"\n";
6498 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6502 if ($action !=
'editfile' || empty($file)) {
6503 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>';
6506 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6507 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>';
6513 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6514 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6515 print
'<input type="hidden" name="action" value="addproperty">';
6516 print
'<input type="hidden" name="tab" value="objects">';
6517 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6518 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6520 print
'<div class="div-table-responsive">';
6521 print
'<table class="noborder">';
6523 print
'<tr class="liste_titre">';
6531 if (count($cronjobs)) {
6532 foreach ($cronjobs as $cron) {
6533 print
'<tr class="oddeven">';
6536 print $cron[
'label'];
6541 if ($cron[
'jobtype'] ==
'method') {
6542 $text = $langs->trans(
"CronClass");
6543 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
6544 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6545 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6546 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6547 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6548 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6549 } elseif ($cron[
'jobtype'] ==
'command') {
6550 $text = $langs->trans(
'CronCommand');
6551 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6552 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6553 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6555 print $form->textwithpicto($text, $texttoshow, 1);
6559 if ($cron[
'unitfrequency'] ==
"60") {
6560 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6562 if ($cron[
'unitfrequency'] ==
"3600") {
6563 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6565 if ($cron[
'unitfrequency'] ==
"86400") {
6566 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6568 if ($cron[
'unitfrequency'] ==
"604800") {
6569 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6574 print $cron[
'status'];
6578 if (!empty($cron[
'comment'])) {
6579 print $cron[
'comment'];
6586 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6596 $content = file_get_contents($fullpathoffile);
6599 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6600 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6601 print
'<input type="hidden" name="action" value="savefile">';
6602 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6603 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6604 print
'<input type="hidden" name="module" value="'.$module.
'">';
6606 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6607 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6608 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6611 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6613 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6620 if ($tab ==
'specifications') {
6621 print
'<!-- tab=specifications -->'.
"\n";
6624 if ($action !=
'editfile' || empty($file)) {
6625 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6629 if (is_array($specs) && !empty($specs)) {
6630 foreach ($specs as $spec) {
6631 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6632 $format =
'asciidoc';
6633 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6634 $format =
'markdown';
6637 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6638 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>';
6639 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>';
6644 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6645 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>';
6656 $content = file_get_contents($fullpathoffile);
6659 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6660 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6661 print
'<input type="hidden" name="action" value="savefile">';
6662 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6663 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6664 print
'<input type="hidden" name="module" value="'.$module.
'">';
6666 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6667 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6670 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6672 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6678 print
'<br><br><br>';
6680 $FILENAMEDOC = $modulelowercase.
'.html';
6681 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6682 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6683 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6684 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6685 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6686 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6687 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6690 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6692 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6695 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6696 print $outputfiledoc;
6699 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6700 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>';
6702 print
'</strong><br>';
6705 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
6707 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6710 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
6711 print $outputfiledocpdf;
6714 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
6715 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>';
6717 print
'</strong><br>';
6721 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
6722 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6723 print
'<input type="hidden" name="action" value="generatedoc">';
6724 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6725 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6726 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
6727 if (!is_array($specs) || empty($specs)) {
6728 print
' disabled="disabled"';
6734 if ($tab ==
'buildpackage') {
6735 print
'<!-- tab=buildpackage -->'.
"\n";
6736 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
6739 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
6740 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
6744 $modulelowercase = strtolower($module);
6750 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6752 $class =
'mod'.$module;
6754 if (class_exists($class)) {
6757 '@phan-var-force DolibarrModules $moduleobj';
6766 $langs->load(
"errors");
6767 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
6771 $arrayversion = explode(
'.',
$moduleobj->version, 3);
6772 if (count($arrayversion)) {
6773 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
6774 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
6779 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
6780 if ($outputfilezip ===
null || !
dol_is_file($outputfilezip)) {
6781 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6783 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
6784 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
6785 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
6786 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>';
6794 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
6795 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6796 print
'<input type="hidden" name="action" value="generatepackage">';
6797 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6798 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6799 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
6803 if ($tab ==
'tabs') {
6804 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6808 if ($action !=
'editfile' || empty($file)) {
6809 print
'<span class="opacitymedium">';
6810 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
6811 $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);
6812 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6816 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
6817 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>';
6823 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6824 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6825 print
'<input type="hidden" name="action" value="addproperty">';
6826 print
'<input type="hidden" name="tab" value="objects">';
6827 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6828 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6830 print
'<div class="div-table-responsive">';
6831 print
'<table class="noborder small">';
6833 print
'<tr class="liste_titre">';
6843 foreach ($tabs as $tab) {
6844 $parts = explode(
':', $tab[
'data']);
6846 $objectType = $parts[0];
6847 $tabName = $parts[1];
6848 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
6849 $langFile = isset($parts[3]) ? $parts[3] :
'';
6850 $condition = isset($parts[4]) ? $parts[4] :
'';
6851 $path = isset($parts[5]) ? $parts[5] :
'';
6855 if ($tabName[0] ===
'-') {
6857 $condition = isset($parts[2]) ? $parts[2] :
'';
6860 print
'<tr class="oddeven">';
6867 if ($tabName[0] ===
"+") {
6868 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6870 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6893 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6903 $content = file_get_contents($fullpathoffile);
6906 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6907 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6908 print
'<input type="hidden" name="action" value="savefile">';
6909 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6910 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6911 print
'<input type="hidden" name="module" value="'.$module.
'">';
6913 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6914 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6915 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6918 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6920 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6927 if ($tab !=
'description') {
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
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='')
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.
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.
Class to manage utility methods.
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_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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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.
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.
getPictoForType($key, $morecss='')
Return the picto for a data type.
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'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
treeview li table
No Email.
foreach( $dirsrootforscan as $tmpdirread) moduleBuilderShutdownFunction()
Add management to catch fatal errors - shutdown handler.
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.
createNewDictionnary($modulename, $file, $namedic, $dictionnaires=null)
Create a new dictionary table.
countItemsInDirectory($path, $type=1)
count directories or files in modulebuilder folder
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.
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.
rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array(), $delfieldentry='')
Regenerate files .class.php.
reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $module, $action)
Rewriting all permissions after any actions.
checkExistComment($file, $number)
Function to check if comment BEGIN and END exists in modMyModule class.
addObjectsToApiFile($srcfile, $file, $objects, $modulename)
Add Object in ModuleApi File.
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.