33if (!defined(
'NOSCANPOSTFORINJECTION')) {
34 define(
'NOSCANPOSTFORINJECTION',
'1');
38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/modulebuilder.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
59$langs->loadLangs(array(
"admin",
"modulebuilder",
"exports",
"other",
"cron",
"errors",
"uxdocumentation"));
62$action =
GETPOST(
'action',
'aZ09');
63$confirm =
GETPOST(
'confirm',
'alpha');
64$cancel =
GETPOST(
'cancel',
'alpha');
66$sortfield =
GETPOST(
'sortfield',
'alpha');
67$sortorder =
GETPOST(
'sortorder',
'aZ09');
69$module = (string)
GETPOST(
'module',
'alpha');
70$tab = (string)
GETPOST(
'tab',
'aZ09');
71$tabobj =
GETPOST(
'tabobj',
'alpha');
72$tabdic =
GETPOST(
'tabdic',
'alpha');
73$propertykey =
GETPOST(
'propertykey',
'alpha');
75 $module =
'initmodule';
80'@phan-var-force string $tab';
82 $tabobj =
'newobjectifnoobj';
85 $tabdic =
'newdicifnodic';
87$file =
GETPOST(
'file',
'alpha');
88$find =
GETPOST(
'find',
'alpha');
93$editorname = (string)
GETPOST(
'editorname',
'alpha');
94$editorurl = (string)
GETPOST(
'editorurl',
'alpha');
95$version = (string)
GETPOST(
'version',
'alpha');
96$family = (string)
GETPOST(
'family',
'alpha');
97$picto = (string)
GETPOST(
'idpicto',
'alpha');
98$idmodule = (string)
GETPOST(
'idmodule',
'alpha');
102if (!isModEnabled(
'modulebuilder')) {
105if (!$user->hasRight(
"modulebuilder",
"run")) {
110$tmp = explode(
',', $dolibarr_main_document_root_alt);
115$tmpdir = explode(
'@', $module);
116if (!empty($tmpdir[1])) {
117 $module = $tmpdir[0];
118 $dirread = $tmpdir[1];
121if (
GETPOST(
'dirins',
'alpha')) {
122 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
126$FILEFLAG =
'modulebuilder.txt';
133if (empty($newmask)) {
142$form =
new Form($db);
145$dirsrootforscan = array($dirread);
149 $dirsrootforscan[] = DOL_DOCUMENT_ROOT;
153$textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
154$listofmodules = array();
155'@phan-var-force array<string,array{modulenamewithcase:string,moduledescriptorrelpath:string,moduledescriptorfullpath:string,moduledescriptorrootpath,moduletype?:string}> $listofmodules';
157foreach ($dirsrootforscan as $tmpdirread) {
158 $moduletype =
'external';
159 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
160 $moduletype =
'internal';
163 $dirsincustom =
dol_dir_list($tmpdirread,
'directories');
164 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
165 foreach ($dirsincustom as $dircustomcursor) {
166 $fullname = $dircustomcursor[
'fullname'];
169 $dirtoscanrel = basename($fullname).
'/core/modules/';
171 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
172 if (empty($descriptorfiles)) {
173 $dirtoscanrel =
'core/modules/';
174 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.strtoupper(basename($fullname)).
'\.class\.php$');
176 $modulenamewithcase =
'';
177 $moduledescriptorrelpath =
'';
178 $moduledescriptorfullpath =
'';
180 foreach ($descriptorfiles as $descriptorcursor) {
181 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
182 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
183 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
184 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
187 if ($modulenamewithcase) {
188 $listofmodules[$dircustomcursor[
'name']] = array(
189 'modulenamewithcase' => $modulenamewithcase,
190 'moduledescriptorrelpath' => $moduledescriptorrelpath,
191 'moduledescriptorfullpath' => $moduledescriptorfullpath,
192 'moduledescriptorrootpath' => $tmpdirread,
193 'moduletype' => $moduletype
201 if ($forceddirread && empty($listofmodules)) {
202 $listofmodules[strtolower($module)] = array(
203 'modulenamewithcase' => $module,
204 'moduledescriptorrelpath' =>
'notyetimplemented',
205 'moduledescriptorfullpath' =>
'notyetimplemented',
206 'moduledescriptorrootpath' =>
'notyetimplemented',
211 $newdircustom = $dirins;
212 if (empty($newdircustom)) {
218 $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
220 $textforlistofdirs .=
', ';
222 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$tmpdirread.
'</strong>';
223 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
225 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
228 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
241 $error = error_get_last();
242 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
244 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
246 if (headers_sent()) {
251register_shutdown_function(
"moduleBuilderShutdownFunction");
263function getLicenceHeader($user, $langs, $now)
265 $licInfo = $user->getFullName($langs);
266 $emailTabs = str_repeat(
"\t", (
int) (max(0, (31 - mb_strlen($licInfo)) / 4)));
267 $licInfo .= ($user->email ? $emailTabs.
'<'.$user->email.
'>' :
'');
276if ($dirins && $action ==
'initmodule' && $modulename && $user->hasRight(
"modulebuilder",
"run")) {
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',
$conf->global->MODULEBUILDER_SPECIFIC_README);
442 $module = $modulename;
444 clearstatcache(
true);
445 if (function_exists(
'opcache_invalidate')) {
449 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
454$destdir =
'/not_set/';
455$destfile =
'/not_set/';
456$srcfile =
'/not_set/';
459if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
460 $modulename = ucfirst($module);
461 $objectname = $tabobj;
462 $varnametoupdate =
'';
463 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
464 $destdir = $dirins.
'/'.strtolower($module);
470 if ($action ==
'initapi') {
471 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
472 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php',
'0', 1);
474 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
475 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
476 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
477 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
478 } elseif ($action ==
'initphpunit') {
479 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
480 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
481 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
482 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
483 } elseif ($action ==
'initpagecontact') {
484 dol_mkdir($dirins.
'/'.strtolower($module));
485 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
486 $srcfile = $srcdir.
'/myobject_contact.php';
487 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
488 $varnametoupdate =
'showtabofpagecontact';
489 } elseif ($action ==
'initpagedocument') {
490 dol_mkdir($dirins.
'/'.strtolower($module));
491 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
492 $srcfile = $srcdir.
'/myobject_document.php';
493 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
494 $varnametoupdate =
'showtabofpagedocument';
495 } elseif ($action ==
'initpagenote') {
496 dol_mkdir($dirins.
'/'.strtolower($module));
497 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
498 $srcfile = $srcdir.
'/myobject_note.php';
499 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
500 $varnametoupdate =
'showtabofpagenote';
501 } elseif ($action ==
'initpageagenda') {
502 dol_mkdir($dirins.
'/'.strtolower($module));
503 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
504 $srcfile = $srcdir.
'/myobject_agenda.php';
505 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
506 $varnametoupdate =
'showtabofpageagenda';
509 if (!file_exists($destfile)) {
510 $result =
dol_copy($srcfile, $destfile,
'0', 0);
515 $arrayreplacement = array(
516 'mymodule' => strtolower($modulename),
517 'MyModule' => $modulename,
518 'MYMODULE' => strtoupper($modulename),
519 'My module' => $modulename,
520 'my module' => $modulename,
521 'Mon module' => $modulename,
522 'mon module' => $modulename,
523 'htdocs/modulebuilder/template' => strtolower($modulename),
524 'myobject' => strtolower($objectname),
525 'MyObject' => $objectname,
526 'MYOBJECT' => strtoupper($objectname),
528 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
531 if ($action ==
'initapi') {
532 if (count($objects) >= 1) {
540 if ($varnametoupdate) {
542 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
543 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
548 $langs->load(
"errors");
549 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
555if ($dirins && $action ==
'initsqlextrafields' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
556 $modulename = ucfirst($module);
557 $objectname = $tabobj;
559 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
560 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
561 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
562 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
563 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
564 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
565 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
566 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
568 if ($result1 > 0 && $result2 > 0) {
569 $modulename = ucfirst($module);
572 $arrayreplacement = array(
573 'mymodule' => strtolower($modulename),
574 'MyModule' => $modulename,
575 'MYMODULE' => strtoupper($modulename),
576 'My module' => $modulename,
577 'my module' => $modulename,
578 'Mon module' => $modulename,
579 'mon module' => $modulename,
580 'htdocs/modulebuilder/template' => strtolower($modulename),
581 'My Object' => $objectname,
582 'MyObject' => $objectname,
583 'my object' => strtolower($objectname),
584 'myobject' => strtolower($objectname),
585 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
591 $langs->load(
"errors");
593 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
596 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
601 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
602 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
603 $arrayreplacement = array(
'/\$isextrafieldmanaged = 0;/' =>
'$isextrafieldmanaged = 1;');
609if ($dirins && $action ==
'inithook' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
610 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
611 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
612 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
613 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
614 $result =
dol_copy($srcfile, $destfile,
'0', 0);
617 $modulename = ucfirst($module);
620 $arrayreplacement = array(
621 'mymodule' => strtolower($modulename),
622 'MyModule' => $modulename,
623 'MYMODULE' => strtoupper($modulename),
624 'My module' => $modulename,
625 'my module' => $modulename,
626 'Mon module' => $modulename,
627 'mon module' => $modulename,
628 'htdocs/modulebuilder/template' => strtolower($modulename),
629 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
635 $langs->load(
"errors");
636 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
642if ($dirins && $action ==
'inittrigger' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
643 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
644 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
645 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
646 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
647 $result =
dol_copy($srcfile, $destfile,
'0', 0);
650 $modulename = ucfirst($module);
653 $arrayreplacement = array(
654 'mymodule' => strtolower($modulename),
655 'MyModule' => $modulename,
656 'MYMODULE' => strtoupper($modulename),
657 'My module' => $modulename,
658 'my module' => $modulename,
659 'Mon module' => $modulename,
660 'mon module' => $modulename,
661 'htdocs/modulebuilder/template' => strtolower($modulename),
662 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
668 $langs->load(
"errors");
669 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
675if ($dirins && $action ==
'initwidget' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
676 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
677 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
678 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
679 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
680 $result =
dol_copy($srcfile, $destfile,
'0', 0);
683 $modulename = ucfirst($module);
686 $arrayreplacement = array(
687 'mymodule' => strtolower($modulename),
688 'MyModule' => $modulename,
689 'MYMODULE' => strtoupper($modulename),
690 'My module' => $modulename,
691 'my module' => $modulename,
692 'Mon module' => $modulename,
693 'mon module' => $modulename,
694 'htdocs/modulebuilder/template' => strtolower($modulename),
695 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
701 $langs->load(
"errors");
702 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
708if ($dirins && $action ==
'initemailing' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
709 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
710 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
711 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
712 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
713 $result =
dol_copy($srcfile, $destfile,
'0', 0);
716 $modulename = ucfirst($module);
719 $arrayreplacement = array(
720 'mymodule' => strtolower($modulename),
721 'MyModule' => $modulename,
722 'MYMODULE' => strtoupper($modulename),
723 'My module' => $modulename,
724 'my module' => $modulename,
725 'Mon module' => $modulename,
726 'mon module' => $modulename,
727 'htdocs/modulebuilder/template' => strtolower($modulename),
728 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
734 $langs->load(
"errors");
735 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
741if ($dirins && $action ==
'initcss' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
742 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
743 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
744 $srcfile = $srcdir.
'/css/mymodule.css.php';
745 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
746 $result =
dol_copy($srcfile, $destfile,
'0', 0);
749 $modulename = ucfirst($module);
752 $arrayreplacement = array(
753 'mymodule' => strtolower($modulename),
754 'MyModule' => $modulename,
755 'MYMODULE' => strtoupper($modulename),
756 'My module' => $modulename,
757 'my module' => $modulename,
758 'Mon module' => $modulename,
759 'mon module' => $modulename,
760 'htdocs/modulebuilder/template' => strtolower($modulename),
761 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
768 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
769 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
772 $langs->load(
"errors");
773 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
779if ($dirins && $action ==
'initjs' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
780 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
781 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
782 $srcfile = $srcdir.
'/js/mymodule.js.php';
783 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
784 $result =
dol_copy($srcfile, $destfile,
'0', 0);
787 $modulename = ucfirst($module);
790 $arrayreplacement = array(
791 'mymodule' => strtolower($modulename),
792 'MyModule' => $modulename,
793 'MYMODULE' => strtoupper($modulename),
794 'My module' => $modulename,
795 'my module' => $modulename,
796 'Mon module' => $modulename,
797 'mon module' => $modulename,
798 'htdocs/modulebuilder/template' => strtolower($modulename),
799 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
806 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
807 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
810 $langs->load(
"errors");
811 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
817if ($dirins && $action ==
'initcli' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
818 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
819 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
820 $srcfile = $srcdir.
'/scripts/mymodule.php';
821 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
822 $result =
dol_copy($srcfile, $destfile,
'0', 0);
825 $modulename = ucfirst($module);
828 $arrayreplacement = array(
829 'mymodule' => strtolower($modulename),
830 'MyModule' => $modulename,
831 'MYMODULE' => strtoupper($modulename),
832 'My module' => $modulename,
833 'my module' => $modulename,
834 'Mon module' => $modulename,
835 'mon module' => $modulename,
836 'htdocs/modulebuilder/template' => strtolower($modulename),
837 '__MYCOMPANY_NAME__' => $mysoc->name,
838 '__KEYWORDS__' => $modulename,
839 '__USER_FULLNAME__' => $user->getFullName($langs),
840 '__USER_EMAIL__' => $user->email,
842 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
848 $langs->load(
"errors");
849 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
854$moduledescriptorfile =
'/not_set/';
855$modulelowercase =
null;
858if ($dirins && $action ==
'initdoc' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
859 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
860 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
861 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
862 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
863 $result =
dol_copy($srcfile, $destfile,
'0', 0);
866 $modulename = ucfirst($module);
867 $modulelowercase = strtolower($module);
870 $arrayreplacement = array(
871 'mymodule' => strtolower($modulename),
872 'MyModule' => $modulename,
873 'MYMODULE' => strtoupper($modulename),
874 'My module' => $modulename,
875 'my module' => $modulename,
876 'Mon module' => $modulename,
877 'mon module' => $modulename,
878 'htdocs/modulebuilder/template' => strtolower($modulename),
879 '__MYCOMPANY_NAME__' => $mysoc->name,
880 '__KEYWORDS__' => $modulename,
881 '__USER_FULLNAME__' => $user->getFullName($langs),
882 '__USER_EMAIL__' => $user->email,
884 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
891 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
892 $destdir = $dirins.
'/'.strtolower($module);
894 foreach ($objects as $path => $obj) {
899 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
903 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
904 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
909 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
910 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
911 $string = file_get_contents($changeLog);
913 $replace = explode(
"\n", $string);
914 $strreplace = array();
915 foreach ($replace as $line) {
919 if (strpos($line,
'##') !==
false) {
920 $strreplace[$line] = str_replace(
'##',
'', $line);
922 $strreplace[$line] = $line;
925 $stringLog = implode(
"\n", $strreplace);
927 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
931 $FILENAMEDOC = $modulelowercase.
'.html';
932 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
933 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
934 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
935 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
936 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
941 $langs->load(
"errors");
942 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
948if ($dirins && $action ==
'addlanguage' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
949 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
952 $modulelowercase = strtolower($module);
957 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
959 $diroflang = $dolibarr_main_document_root;
961 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
962 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
964 $result =
dol_copy($srcfile, $destfile,
'0', 0);
966 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
969 $srcdir = $diroflang.
'/langs/en_US';
970 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
971 $destdir = $diroflang.
'/langs/'.$newlangcode;
973 $arrayofreplacement = array();
975 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
976 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
978 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
981 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
987if ($dirins && $action ==
'confirm_removefile' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
988 $objectname = $tabobj;
989 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
990 $destdir = $dirins.
'/'.strtolower($module);
995 if ($relativefilename) {
996 $dirnametodelete = dirname($relativefilename);
997 $filetodelete = $dirins.
'/'.$relativefilename;
998 $dirtodelete = $dirins.
'/'.$dirnametodelete;
1003 $keyofobjecttodelete = array_search($objectname, $objects);
1004 if ($keyofobjecttodelete !==
false) {
1005 unset($objects[$keyofobjecttodelete]);
1009 if (strpos($relativefilename,
'api') !==
false) {
1010 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
1014 if (count($objects) == 0) {
1026 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1029 if (preg_match(
'/\.sql$/', $relativefilename)) {
1030 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1031 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1032 $filetodelete = $dirins.
'/'.$relativefilename;
1034 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1035 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1036 $filetodelete = $dirins.
'/'.$relativefilename;
1046 if (in_array($tab, array(
'css',
'js'))) {
1047 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1048 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1052 if (preg_match(
'/_extrafields/', $relativefilename)) {
1054 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1055 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1060 $varnametoupdate =
'';
1062 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1063 $varnametoupdate =
'showtabofpage'.$reg[1];
1065 if ($varnametoupdate) {
1066 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1067 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1075if ($dirins && $action ==
'initobject' && $module && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
1078 $objectname = ucfirst($objectname);
1080 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1081 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1083 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1085 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1086 $tabobj =
'newobject';
1088 if (class_exists($objectname)) {
1091 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1092 $tabobj =
'newobject';
1095 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1096 $destdir = $dirins.
'/'.strtolower($module);
1108 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1109 $alreadyfound =
false;
1110 foreach ($dirlist as $key => $val) {
1111 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1112 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1113 $alreadyfound =
true;
1115 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1123 $stringforproperties =
'';
1124 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1126 $_results = $db->DDLDescTable($tablename);
1127 if (empty($_results)) {
1129 $langs->load(
"errors");
1130 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1179 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1180 $stringforproperties .=
'public $fields = array('.
"\n";
1182 while ($obj = $db->fetch_object($_results)) {
1184 $fieldname = $obj->Field;
1187 if ($type ==
'int(11)') {
1189 } elseif ($type ==
'float') {
1191 } elseif (strstr($type,
'tinyint')) {
1193 } elseif (strstr($type,
'url')) {
1194 $type =
'varchar(255)';
1195 } elseif ($obj->Field ==
'fk_soc') {
1196 $type =
'integer:Societe:societe/class/societe.class.php';
1197 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1198 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1199 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1200 $type =
'integer:Product:product/class/product.class.php:1';
1201 } elseif ($obj->Field ==
'fk_warehouse') {
1202 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1203 } elseif (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1204 $type =
'integer:User:user/class/user.class.php';
1208 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1209 if ($fieldname ==
'fk_user_modif') {
1213 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1214 if ($fieldname ==
'rowid') {
1215 $label =
'TechnicalID';
1217 if ($fieldname ==
'import_key') {
1218 $label =
'ImportId';
1220 if ($fieldname ==
'fk_soc') {
1221 $label =
'ThirdParty';
1223 if (in_array($fieldname, array(
'tms',
'date_modification'))) {
1224 $label =
'DateModification';
1226 if (in_array($fieldname, array(
'datec',
'date_creation'))) {
1227 $label =
'DateCreation';
1229 if ($fieldname ==
'date_valid') {
1230 $label =
'DateValidation';
1232 if ($fieldname ==
'datev') {
1233 $label =
'DateValidation';
1235 if ($fieldname ==
'note_private') {
1236 $label =
'NotePublic';
1238 if ($fieldname ==
'note_public') {
1239 $label =
'NotePrivate';
1241 if ($fieldname ==
'fk_user_creat') {
1242 $label =
'UserAuthor';
1244 if ($fieldname ==
'fk_user_modif') {
1245 $label =
'UserModif';
1247 if ($fieldname ==
'fk_user_valid') {
1248 $label =
'UserValidation';
1252 if (in_array($fieldname, array(
'ref',
'label'))) {
1255 if ($fieldname ==
'entity') {
1258 if ($fieldname ==
'entity') {
1261 if ($fieldname ==
'import_key') {
1264 if ($fieldname ==
'fk_user_creat') {
1267 if ($fieldname ==
'fk_user_modif') {
1270 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1277 if ($fieldname ==
'entity') {
1282 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1285 if ($fieldname ==
'import_key') {
1289 $alwayseditable = 0;
1290 if ($fieldname ==
'label') {
1291 $alwayseditable = 1;
1293 $alwayseditable = 0;
1297 if ($fieldname ==
'entity') {
1304 if (preg_match(
'/^fk_/', $fieldname)) {
1305 $css =
'maxwidth500 widthcentpercentminusxx';
1307 if ($fieldname ==
'label') {
1308 $css =
'minwidth300';
1309 $cssview =
'wordbreak';
1311 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1312 $cssview =
'wordbreak';
1314 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1315 $csslist =
'tdoverflowmax150';
1320 if (isset($obj->Picto)) {
1321 $picto = $obj->Picto;
1323 if (preg_match(
'/^fk_soc/', $obj->Field)) {
1325 } elseif (preg_match(
'/^fk_contact/', $obj->Field)) {
1327 } elseif (preg_match(
'/^fk_bank/', $obj->Field)) {
1329 } elseif (preg_match(
'/^fk_user/', $obj->Field)) {
1331 } elseif (preg_match(
'/^fk_warehouse/', $obj->Field)) {
1332 $picto =
'warehouse';
1333 } elseif (preg_match(
'/^fk_prod/', $obj->Field)) {
1335 } elseif (preg_match(
'/^fk_proj/', $obj->Field)) {
1337 } elseif (preg_match(
'/^fk_task/', $obj->Field)) {
1342 $lang = $module.
'@'.$module;
1345 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1346 if ($default !=
'') {
1347 $stringforproperties .=
" 'default' => ".$default.
",";
1349 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1350 $stringforproperties .=
" 'visible' => ".$visible;
1352 $stringforproperties .=
", 'notnull' => ".$notnull;
1354 if ($alwayseditable) {
1355 $stringforproperties .=
", 'alwayseditable' => 1";
1357 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1358 $stringforproperties .=
", 'showoncombobox' => 1";
1360 $stringforproperties .=
", 'position' => ".$position;
1362 $stringforproperties .=
", 'index' => ".$index;
1365 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1368 $stringforproperties .=
", 'css' => '".$css.
"'";
1371 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1374 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1377 $stringforproperties .=
", 'lang' => '".$lang.
"'";
1379 $stringforproperties .=
"),\n";
1382 $stringforproperties .=
');'.
"\n";
1383 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1387 $filetogenerate = array();
1390 $filetogenerate = array(
1391 'myobject_card.php' => strtolower($objectname).
'_card.php',
1392 'myobject_note.php' => strtolower($objectname).
'_note.php',
1393 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1394 'myobject_document.php' => strtolower($objectname).
'_document.php',
1395 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1396 'myobject_list.php' => strtolower($objectname).
'_list.php',
1397 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1398 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1400 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1401 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1402 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1403 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1405 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1407 'ajax/myobject.php' =>
'ajax/'.strtolower($objectname).
'.php',
1410 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1411 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1413 $filetogenerate += array(
1414 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1415 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1416 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1419 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1420 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1421 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1423 $filetogenerate += array(
1424 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1425 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1428 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1429 $firstobjectname =
'myobject';
1430 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1432 $class =
'mod'.$module;
1434 if (class_exists($class)) {
1437 '@phan-var-force DolibarrModules $moduleobj';
1449 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1451 if ($checkComment < 0) {
1452 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1454 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1455 if ($generatePerms < 0) {
1456 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1462 foreach ($filetogenerate as $srcfile => $destfile) {
1463 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1467 $langs->load(
"errors");
1468 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1471 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1474 $arrayreplacement = array(
1475 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1476 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1479 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1484 if (!$error && $stringforproperties) {
1486 $arrayreplacement = array(
1487 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1490 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1494 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1496 $arrayreplacement = array(
1497 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1501 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1503 $arrayreplacement = array(
1504 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1506 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1510 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1512 $arrayreplacement = array(
1513 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1515 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1516 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'',
'0', 0, 1);
1518 $arrayreplacement = array(
1519 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1522 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1529 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1531 $firstobjectname =
'';
1533 foreach ($listofobject as $fileobj) {
1534 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1537 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1541 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1543 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1544 $objectnameloop = $reg[1];
1545 if (empty($firstobjectname)) {
1546 $firstobjectname = $objectnameloop;
1552 \$this->menu[\$r++] = array(
1553 'fk_menu' => 'fk_mainmenu=mymodule',
1555 'titre' => 'MyObject',
1556 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1557 'mainmenu' => 'mymodule',
1558 'leftmenu' => 'myobject',
1559 'url' => '/mymodule/myobject_list.php',
1560 'langs' => 'mymodule@mymodule',
1561 'position' => 1000 + \$r,
1562 'enabled' => 'isModEnabled(\"mymodule\")',
1563 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1566 'object' => 'MyObject'
1568 \$this->menu[\$r++] = array(
1569 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1571 'titre' => 'List MyObject',
1572 'mainmenu' => 'mymodule',
1573 'leftmenu' => 'mymodule_myobject_list',
1574 'url' => '/mymodule/myobject_list.php',
1575 'langs' => 'mymodule@mymodule',
1576 'position' => 1000 + \$r,
1577 'enabled' => 'isModEnabled(\"mymodule\")',
1578 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1581 'object' => 'MyObject'
1583 \$this->menu[\$r++] = array(
1584 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1586 'titre' => 'New MyObject',
1587 'mainmenu' => 'mymodule',
1588 'leftmenu' => 'mymodule_myobject_new',
1589 'url' => '/mymodule/myobject_card.php?action=create',
1590 'langs' => 'mymodule@mymodule',
1591 'position' => 1000 + \$r,
1592 'enabled' => 'isModEnabled(\"mymodule\")',
1593 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1596 'object' => 'MyObject'
1598 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1599 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1600 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1602 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1608 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1610 $class =
'mod'.$module;
1612 if (class_exists($class)) {
1615 '@phan-var-force DolibarrModules $moduleobj';
1628 foreach ($menus as $menu) {
1629 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1635 if ($checkComment < 0) {
1637 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1639 $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 */');
1644 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1649 foreach ($filetogenerate as $destfile) {
1650 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1653 $arrayreplacement = array(
1654 'mymodule' => strtolower($module),
1655 'MyModule' => $module,
1656 'MYMODULE' => strtoupper($module),
1657 'My module' => $module,
1658 'my module' => $module,
1659 'mon module' => $module,
1660 'Mon module' => $module,
1661 'htdocs/modulebuilder/template/' => strtolower($modulename),
1662 'myobject' => strtolower($objectname),
1663 'MyObject' => $objectname,
1665 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
1669 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1675 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1684 if (is_numeric($object) && $object <= 0) {
1685 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1686 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1690 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1691 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1693 if (file_exists($destfile)) {
1699 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1708 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1709 $tabobj = $objectname;
1711 $tabobj =
'newobject';
1715 if (isModEnabled(strtolower($module))) {
1721 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1722 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1728if ($dirins && $action ==
'initdic' && $module && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
1729 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1730 $destdir = $dirins.
'/'.strtolower($module);
1731 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1735 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1739 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1742 $newdicname = $dicname;
1743 if (!preg_match(
'/^c_/', $newdicname)) {
1744 $newdicname =
'c_'.$dicname;
1747 $class =
'mod'.$module;
1749 if (class_exists($class)) {
1752 '@phan-var-force DolibarrModules $moduleobj';
1760 $langs->load(
"errors");
1761 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1766 if ($checkComment < 0) {
1767 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1770 if (function_exists(
'opcache_invalidate')) {
1773 clearstatcache(
true);
1774 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1781if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj) && $user->hasRight(
"modulebuilder",
"run")) {
1782 $objectname = $tabobj;
1784 $arrayoftables = array();
1785 if ($action ==
'droptable') {
1786 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1788 if ($action ==
'droptableextrafields') {
1789 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1792 foreach ($arrayoftables as $tabletodrop) {
1794 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1795 $resql = $db->query($sql);
1797 $obj = $db->fetch_object($resql);
1802 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1803 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1809 $resql = $db->DDLDropTable($tabletodrop);
1811 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1812 } elseif ($nb > 0) {
1813 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1818if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) && $user->hasRight(
"modulebuilder",
"run")) {
1823 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1824 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1826 $srcdir = $dirread.
'/'.strtolower($module);
1827 $destdir = $dirins.
'/'.strtolower($module);
1831 if (!in_array($objectname, array_values($objects))) {
1833 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1836 $addfieldentry = array();
1839 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1840 if (!
GETPOST(
'propname',
'aZ09')) {
1842 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1844 if (!
GETPOST(
'proplabel',
'alpha')) {
1846 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1848 if (!
GETPOST(
'proptype',
'alpha')) {
1850 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1854 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1855 $addfieldentry = array(
1856 'name' =>
GETPOST(
'propname',
'aZ09'),
1857 'label' =>
GETPOST(
'proplabel',
'alpha'),
1858 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1859 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'nohtml'),
1860 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1861 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1865 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1867 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1868 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1869 'help' =>
GETPOST(
'prophelp',
'alpha'),
1870 'css' =>
GETPOST(
'propcss',
'alpha'),
1871 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1872 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1873 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1874 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
1879 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1880 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1882 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1885 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1897 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1903 if (is_numeric($object) && $object <= 0) {
1904 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1905 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1912 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1915 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1921 clearstatcache(
true);
1923 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1928 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1933if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey && $user->hasRight(
"modulebuilder",
"run")) {
1934 $objectname = $tabobj;
1936 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1937 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1939 $srcdir = $dirread.
'/'.strtolower($module);
1940 $destdir = $dirins.
'/'.strtolower($module);
1947 if (is_numeric($object) && $object <= 0) {
1948 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1949 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1956 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1959 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1965 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1967 clearstatcache(
true);
1970 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1975if ($dirins && $action ==
'confirm_deletemodule' && $user->hasRight(
"modulebuilder",
"run")) {
1976 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1978 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1982 $modulelowercase = strtolower($module);
1985 $dir = $dirins.
'/'.$modulelowercase;
1987 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1997 $class =
'mod'.$module;
2001 if (class_exists($class)) {
2004 '@phan-var-force DolibarrModules $moduleobj';
2012 $langs->load(
"errors");
2013 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
2025 clearstatcache(
true);
2026 if (function_exists(
'opcache_invalidate')) {
2030 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2038 $module =
'deletemodule';
2041if ($dirins && $action ==
'confirm_deleteobject' && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
2042 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2044 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2048 $modulelowercase = strtolower($module);
2049 $objectlowercase = strtolower($objectname);
2052 $dir = $dirins.
'/'.$modulelowercase;
2055 $filetodelete = array(
2056 'myobject_card.php' => strtolower($objectname).
'_card.php',
2057 'myobject_note.php' => strtolower($objectname).
'_note.php',
2058 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
2059 'myobject_document.php' => strtolower($objectname).
'_document.php',
2060 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
2061 'myobject_list.php' => strtolower($objectname).
'_list.php',
2062 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
2063 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
2064 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
2065 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
2066 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
2067 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
2068 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
2069 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
2070 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
2071 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2072 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2073 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2074 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2075 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2076 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2081 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2083 $class =
'mod'.$module;
2085 if (class_exists($class)) {
2088 '@phan-var-force DolibarrModules $moduleobj';
2096 $langs->load(
"errors");
2097 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2100 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2106 if ($rewriteMenu < 0) {
2107 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2109 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2115 if ($rewritePerms < 0) {
2116 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2120 if ($rewritePerms && $rewriteMenu) {
2122 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2125 clearstatcache(
true);
2126 if (function_exists(
'opcache_invalidate')) {
2130 foreach ($filetodelete as $tmpfiletodelete) {
2132 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2138 if ($resultko == 0) {
2141 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2148 $tabobj =
'newobject';
2150 $tabobj =
'deleteobject';
2154 if (isModEnabled(strtolower($module))) {
2160 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2161 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2166if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) && $user->hasRight(
"modulebuilder",
"run")) {
2167 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2168 $destdir = $dirins.
'/'.strtolower($module);
2169 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2171 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2173 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2176 if (!empty($dicname)) {
2177 $newdicname = $dicname;
2178 if (!preg_match(
'/^c_/', $newdicname)) {
2179 $newdicname =
'c_'.strtolower($dicname);
2186 $class =
'mod'.$module;
2188 if (class_exists($class)) {
2191 '@phan-var-force DolibarrModules $moduleobj';
2199 $langs->load(
"errors");
2200 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2206 if ($checkComment < 0) {
2208 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2211 if (!empty(
GETPOST(
'dictionnarykey'))) {
2212 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2216 $checkTable =
false;
2217 if ($newdicname !==
null) {
2218 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2221 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2226 $keyToDelete =
null;
2227 foreach ($dicts[
'tabname'] as $key => $table) {
2229 if (strtolower($table) === $newdicname) {
2230 $keyToDelete = $key;
2235 if ($keyToDelete !==
null) {
2236 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2237 foreach ($keysToDelete as $key) {
2238 unset($dicts[$key][$keyToDelete]);
2242 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2244 if (!$error && $newdicname !==
null) {
2246 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2247 if ($_results < 0) {
2249 $langs->load(
"errors");
2250 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2255 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2257 if (function_exists(
'opcache_invalidate')) {
2260 clearstatcache(
true);
2261 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2265if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') && $user->hasRight(
"modulebuilder",
"run")) {
2266 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2268 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2269 $destdir = $dirins.
'/'.strtolower($module);
2270 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2272 $class =
'mod'.$module;
2274 if (class_exists($class)) {
2277 '@phan-var-force DolibarrModules $moduleobj';
2285 $langs->load(
"errors");
2286 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2291 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2292 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2294 if ($checkComment < 0) {
2295 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2298 if ($updateDict > 0) {
2301 if (function_exists(
'opcache_invalidate')) {
2304 clearstatcache(
true);
2305 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2311if ($dirins && $action ==
'generatedoc' && $user->hasRight(
"modulebuilder",
"run")) {
2312 $modulelowercase = strtolower($module);
2317 $FILENAMEDOC = strtolower($module).
'.html';
2319 $util =
new Utils($db);
2320 $result = $util->generateDoc($module);
2323 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2329if ($dirins && $action ==
'generatepackage' && $user->hasRight(
"modulebuilder",
"run")) {
2330 $modulelowercase = strtolower($module);
2332 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2342 $class =
'mod'.$module;
2344 if (class_exists($class)) {
2347 '@phan-var-force DolibarrModules $moduleobj';
2355 $langs->load(
"errors");
2356 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2360 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2361 if (count($arrayversion)) {
2362 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2365 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2371 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2374 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2377 $langs->load(
"errors");
2378 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2382 $langs->load(
"errors");
2383 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2388if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2392 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2394 $class =
'mod'.$module;
2396 if (class_exists($class)) {
2399 '@phan-var-force DolibarrModules $moduleobj';
2408 if (!
GETPOST(
'label',
'alpha')) {
2410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2412 if (!
GETPOST(
'permissionObj',
'alpha')) {
2414 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2418 $label =
GETPOST(
'label',
'alpha');
2419 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2420 $crud =
GETPOST(
'crud',
'alpha');
2424 $permsForObject = array();
2428 $permissions = array();
2430 $allObject = array();
2432 $countPerms = count($permissions);
2434 for ($i = 0; $i < $countPerms; $i++) {
2435 if ($permissions[$i][4] == $objectForPerms) {
2437 if (count($permsForObject) < 3) {
2438 $permsForObject[] = $permissions[$i];
2441 $allObject[] = $permissions[$i][4];
2445 $countPermsObj = count($permsForObject);
2446 for ($j = 0; $j < $countPermsObj; $j++) {
2447 if (in_array($crud, $permsForObject[$j])) {
2449 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2453 $rightToAdd = array();
2455 $key = $countPerms + 1;
2457 $rightToAdd = array(
2460 4 => $objectForPerms,
2464 if (isModEnabled(strtolower($module))) {
2470 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2473 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2477 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2482 clearstatcache(
true);
2483 if (function_exists(
'opcache_invalidate')) {
2486 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2494if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2497 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2499 $class =
'mod'.$module;
2501 if (class_exists($class)) {
2504 '@phan-var-force DolibarrModules $moduleobj';
2512 if (!
GETPOST(
'label',
'alpha')) {
2514 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2516 if (!
GETPOST(
'permissionObj',
'alpha')) {
2518 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2521 $label =
GETPOST(
'label',
'alpha');
2522 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2523 $crud =
GETPOST(
'crud',
'alpha');
2526 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2530 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2534 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2546 if (array_key_exists($key, $permissions)) {
2547 $x1 = $permissions[$key][1];
2548 $x2 = $permissions[$key][4];
2549 $x3 = $permissions[$key][5];
2557 $permsForObject = array();
2561 $allObject = array();
2563 $countPerms = count($permissions);
2564 for ($i = 0; $i < $countPerms; $i++) {
2565 if ($permissions[$i][4] == $objectForPerms) {
2567 if (count($permsForObject) < 3) {
2568 $permsForObject[] = $permissions[$i];
2571 $allObject[] = $permissions[$i][4];
2574 if ($label != $x1 && $crud != $x3) {
2575 $countPermsObj = count($permsForObject);
2576 for ($j = 0; $j < $countPermsObj; $j++) {
2577 if (in_array($label, $permsForObject[$j])) {
2579 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2585 if (isModEnabled(strtolower($module))) {
2591 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2594 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2598 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2600 $rightUpdated =
null;
2603 clearstatcache(
true);
2604 if (function_exists(
'opcache_invalidate')) {
2607 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2613if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey') && $user->hasRight(
"modulebuilder",
"run")) {
2616 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2618 $class =
'mod'.$module;
2620 if (class_exists($class)) {
2623 '@phan-var-force DolibarrModules $moduleobj';
2636 if (isModEnabled(strtolower($module))) {
2642 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2643 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2648 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2651 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2656 clearstatcache(
true);
2657 if (function_exists(
'opcache_invalidate')) {
2661 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2667if ($action ==
'savefile' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2668 $relofcustom = basename($dirins);
2672 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2673 $file = $relofcustom.
'/'.$file;
2681 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2684 $check =
'restricthtml';
2686 if ($srclang ==
'md') {
2687 $check =
'restricthtml';
2689 if ($srclang ==
'lang') {
2690 $check =
'restricthtml';
2692 if ($srclang ==
'php') {
2696 $content =
GETPOST(
'editfilecontent', $check);
2701 $result = file_put_contents($pathoffile, $content);
2718if ($action ==
'set' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2721 $param .=
'&module='.urlencode($module);
2724 $param .=
'&tab='.urlencode($tab);
2725 $param .=
'&tabobj='.urlencode($tabobj);
2727 $value =
GETPOST(
'value',
'alpha');
2729 if (!empty($resarray[
'errors'])) {
2733 if ($resarray[
'nbperms'] > 0) {
2734 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2735 $resqltmp = $db->query($tmpsql);
2737 $obj = $db->fetch_object($resqltmp);
2739 if ($obj && $obj->nb > 1) {
2740 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2748 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2753if ($action ==
'reset' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2756 $param .=
'&module='.urlencode($module);
2758 $param .=
'&tab='.urlencode($tab);
2759 $param .=
'&tabobj='.urlencode($tabobj);
2761 $value =
GETPOST(
'value',
'alpha');
2766 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2771if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') && $user->hasRight(
"modulebuilder",
"run")) {
2773 if (isModEnabled(strtolower($module))) {
2779 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2780 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2784 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2786 $class =
'mod'.$module;
2788 if (class_exists($class)) {
2791 '@phan-var-force DolibarrModules $moduleobj';
2799 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2800 $destdir = $dir.
'/'.strtolower($module);
2802 $result = array_map(
'strtolower', $objects);
2806 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2809 if ($checkcomment < 0) {
2810 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2812 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2813 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2814 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2822 clearstatcache(
true);
2823 if (function_exists(
'opcache_invalidate')) {
2828 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2834if ($dirins && $action ==
'addmenu' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2836 if (isModEnabled(strtolower($module))) {
2842 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2843 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2849 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2851 $class =
'mod'.$module;
2853 if (class_exists($class)) {
2856 '@phan-var-force DolibarrModules $moduleobj';
2867 if (!
GETPOST(
'type',
'alpha')) {
2869 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2871 if (!
GETPOST(
'titre',
'alpha')) {
2873 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2875 if (!
GETPOST(
'user',
'alpha')) {
2877 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2879 if (!
GETPOST(
'url',
'alpha')) {
2881 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2883 if (!empty(
GETPOST(
'target'))) {
2884 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2885 if (!in_array(
GETPOST(
'target'), $targets)) {
2887 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2894 foreach ($menus as $menu) {
2897 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2900 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2902 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2907 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2908 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2910 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2913 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2914 $destdir = $dirins.
'/'.strtolower($module);
2917 if (
GETPOST(
'type',
'alpha') ==
'left') {
2918 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2920 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2923 if (
GETPOST(
'type',
'alpha') ==
'top') {
2925 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2928 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2932 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2933 'type' =>
GETPOST(
'type',
'alpha'),
2934 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2936 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2937 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2938 'url' =>
GETPOST(
'url',
'alpha'),
2939 'langs' => strtolower($module).
"@".strtolower($module),
2941 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2942 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2943 'target' =>
GETPOST(
'target',
'alpha'),
2947 if (
GETPOST(
'type') ==
'left') {
2948 unset($menuToAdd[
'prefix']);
2949 if (empty(
GETPOST(
'fk_menu'))) {
2950 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2952 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2955 if (
GETPOST(
'enabled') ==
'1') {
2956 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2958 $menuToAdd[
'enabled'] =
"0";
2960 if (empty(
GETPOST(
'objects'))) {
2961 $menuToAdd[
'perms'] =
'1';
2965 if ($checkcomment < 0) {
2966 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2969 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2971 clearstatcache(
true);
2972 if (function_exists(
'opcache_invalidate')) {
2981 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2989if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') && $user->hasRight(
"modulebuilder",
"run")) {
2990 $objectname =
GETPOST(
'tabobj');
2991 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2992 $destdir = $dirins.
'/'.strtolower($module);
2995 if (empty($cancel)) {
2996 if (isModEnabled(strtolower($module))) {
3002 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3003 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3008 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3010 $class =
'mod'.$module;
3012 if (class_exists($class)) {
3015 '@phan-var-force DolibarrModules $moduleobj';
3025 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3027 $menuModify = array(
3028 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3029 'type' =>
GETPOST(
'type',
'alpha'),
3030 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
3032 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3033 'leftmenu' => $menus[$key][
'leftmenu'],
3034 'url' =>
GETPOST(
'url',
'alpha'),
3035 'langs' => strtolower($module).
"@".strtolower($module),
3037 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3038 'perms' =>
GETPOST(
'perms',
'alpha'),
3039 'target' =>
GETPOST(
'target',
'alpha'),
3042 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3043 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3044 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3045 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3047 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3049 if ($menuModify[
'enabled'] ===
'') {
3050 $menuModify[
'enabled'] =
'1';
3052 if ($menuModify[
'perms'] ===
'') {
3053 $menuModify[
'perms'] =
'1';
3056 if (
GETPOST(
'type',
'alpha') ==
'top') {
3058 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3065 if ($checkComment < 0) {
3066 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3069 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3071 clearstatcache(
true);
3072 if (function_exists(
'opcache_invalidate')) {
3079 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));
3084 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3089 $_POST[
'type'] =
'';
3090 $_POST[
'titre'] =
'';
3091 $_POST[
'fk_menu'] =
'';
3092 $_POST[
'leftmenu'] =
'';
3098if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
3099 if (isModEnabled(strtolower($module))) {
3105 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3106 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3109 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3110 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3111 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
3115 $class =
'mod'.$module;
3117 if (class_exists($class)) {
3120 '@phan-var-force DolibarrModules $moduleobj';
3128 $keydescription =
GETPOST(
'keydescription',
'alpha');
3129 switch ($keydescription) {
3131 $propertyToUpdate =
'description';
3138 $propertyToUpdate = $keydescription;
3141 $error =
GETPOST(
'keydescription');
3145 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3146 $newValue =
GETPOST(
'propsmodule');
3147 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3148 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3151 if ($propertyToUpdate ===
'version') {
3155 $fileLines = file($moduledescriptorfile);
3156 foreach ($fileLines as &$line) {
3157 if (strpos($line, $lineToReplace) === 0) {
3163 clearstatcache(
true);
3164 if (function_exists(
'opcache_invalidate')) {
3167 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3168 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3178$form =
new Form($db);
3189 '/includes/ace/src/ace.js',
3190 '/includes/ace/src/ext-statusbar.js',
3191 '/includes/ace/src/ext-language_tools.js',
3196llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3199$text = $langs->trans(
"ModuleBuilder");
3203print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development').
'</span>';
3204print
'<br class="hideonsmartphone">';
3213 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3218 $langs->load(
"errors");
3219 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3223 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3232$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3236$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3237$allowonlineinstall =
true;
3238if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3239 $allowonlineinstall =
false;
3241if (empty($allowonlineinstall)) {
3244 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3247 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3262if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3263 $modulelowercase = strtolower($module);
3264 $loadclasserrormessage =
'';
3268 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3273 $class =
'mod'.$module;
3274 }
catch (Throwable $e) {
3275 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3276 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3277 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3281 if (class_exists($class)) {
3284 '@phan-var-force DolibarrModules $moduleobj';
3288 print $e->getMessage();
3291 if (empty($forceddirread)) {
3294 $langs->load(
"errors");
3295 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3296 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3297 print $loadclasserrormessage;
3308$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3309$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3310$head[$h][2] =
'initmodule';
3313$linktoenabledisable =
'';
3315if ( count($listofmodules) > 0) {
3317 $modulelowercase = strtolower($module);
3321 $param .=
'&module='.urlencode($module);
3324 $param .=
'&tab='.urlencode($tab);
3325 $param .=
'&tabobj='.urlencode($tabobj);
3327 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3330 if (isModEnabled($modulelowercase)) {
3331 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3332 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'', 0, 0, 0,
'',
'', 1);
3333 $linktoenabledisable .=
'</a>';
3335 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3338 $backtourlparam =
'';
3339 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3340 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3341 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3344 if (is_array($objMod->config_page_url)) {
3346 foreach ($objMod->config_page_url as $page) {
3349 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3352 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3353 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3354 $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>';
3358 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3359 $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>';
3363 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3364 $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>';
3368 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3369 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip', 1);
3370 $linktoenabledisable .=
"</a>\n";
3375 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3376 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3377 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3378 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3380 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3381 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3388$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3389$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3390$head[$h][2] =
'deletemodule';
3396if ($module ==
'initmodule') {
3398 print
'<!-- section init module -->'.
"\n";
3399 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3400 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3401 print
'<input type="hidden" name="action" value="initmodule">';
3402 print
'<input type="hidden" name="module" value="initmodule">';
3407 print
'<div class="tagtable">';
3409 print
'<div class="tagtr"><div class="tagtd paddingright">';
3410 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3411 print
'</div><div class="tagtd">';
3412 print
'<input type="number" min="100000" name="idmodule" class="width75" value="500000">';
3413 print
'<span class="opacitymedium small">';
3414 print
' ';
3415 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info&hidetitle=1',
'',
'');
3417 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3419 print
'</div></div>';
3421 print
'<div class="tagtr"><div class="tagtd paddingright">';
3422 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3423 print
'</div><div class="tagtd">';
3424 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3425 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3426 print
'</div></div>';
3428 print
'<div class="tagtr"><div class="tagtd paddingright">';
3429 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3430 print
'</div><div class="tagtd">';
3431 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3432 print
'</div></div>';
3434 print
'<div class="tagtr"><div class="tagtd paddingright">';
3435 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3436 print
'</div><div class="tagtd">';
3437 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")).
'">';
3438 print
'</div></div>';
3440 print
'<div class="tagtr"><div class="tagtd paddingright">';
3441 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3442 print
'</div><div class="tagtd">';
3443 print
'<select name="family" id="family" class="minwidth400">';
3444 $arrayoffamilies = array(
3445 'hr' =>
"ModuleFamilyHr",
3446 'crm' =>
"ModuleFamilyCrm",
3447 'srm' =>
"ModuleFamilySrm",
3448 'financial' =>
'ModuleFamilyFinancial',
3449 'products' =>
'ModuleFamilyProducts',
3450 'projects' =>
'ModuleFamilyProjects',
3451 'ecm' =>
'ModuleFamilyECM',
3452 'technic' =>
'ModuleFamilyTechnic',
3453 'portal' =>
'ModuleFamilyPortal',
3454 'interface' =>
'ModuleFamilyInterface',
3455 'base' =>
'ModuleFamilyBase',
3456 'other' =>
'ModuleFamilyOther'
3458 foreach ($arrayoffamilies as $key => $value) {
3459 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>';
3463 print
'</div></div>';
3465 print
'<div class="tagtr"><div class="tagtd paddingright">';
3466 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3467 print
'</div><div class="tagtd">';
3468 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3469 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3471 print
'<span class="opacitymedium small">';
3472 print
' ';
3473 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',
'',
'');
3476 print
'</div></div>';
3478 print
'<div class="tagtr"><div class="tagtd paddingright">';
3479 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3480 print
'</div><div class="tagtd">';
3481 print
'<input type="text" name="editorname" value="'.(GETPOSTISSET(
'editorname') ?
GETPOST(
'editorname') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_NAME', $mysoc->
name)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorName")).
'"><br>';
3482 print
'</div></div>';
3484 print
'<div class="tagtr"><div class="tagtd paddingright">';
3485 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3486 print
'</div><div class="tagtd">';
3487 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>';
3488 print
'</div></div>';
3492 print
'<br><center>';
3493 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3496} elseif ($module ==
'deletemodule') {
3497 print
'<!-- Form to init a module -->'.
"\n";
3498 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3499 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3500 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3501 print
'<input type="hidden" name="module" value="deletemodule">';
3503 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3505 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3506 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3508} elseif (!empty($module) && $modulelowercase !==
null) {
3511 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3512 $destdir = $dirread.
'/'.strtolower($module);
3516 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3530 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3531 $head2[$h][1] = $langs->trans(
"Description");
3532 $head2[$h][2] =
'description';
3535 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3536 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3537 $head2[$h][2] =
'objects';
3540 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3541 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3542 $head2[$h][2] =
'languages';
3545 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3546 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3547 $head2[$h][2] =
'permissions';
3550 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3551 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3552 $head2[$h][2] =
'dictionaries';
3555 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3556 $head2[$h][1] = $langs->trans(
"Tabs");
3557 $head2[$h][2] =
'tabs';
3560 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3561 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3562 $head2[$h][2] =
'menus';
3565 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3566 $head2[$h][1] = $langs->trans(
"Hooks");
3567 $head2[$h][2] =
'hooks';
3570 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3571 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3572 $head2[$h][2] =
'triggers';
3575 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3576 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3577 $head2[$h][2] =
'widgets';
3580 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3581 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3582 $head2[$h][2] =
'emailings';
3585 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3586 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3587 $head2[$h][2] =
'exportimport';
3590 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3591 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3592 $head2[$h][2] =
'css';
3595 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3596 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3597 $head2[$h][2] =
'js';
3600 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3601 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3602 $head2[$h][2] =
'cli';
3605 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3606 $head2[$h][1] = $langs->trans(
"CronList");
3607 $head2[$h][2] =
'cron';
3610 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3611 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="marginleftonlyshort badge">'.$hasDoc.
"</span>");
3612 $head2[$h][2] =
'specifications';
3615 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3616 $head2[$h][1] = $langs->trans(
"BuildPackage");
3617 $head2[$h][2] =
'buildpackage';
3620 $MAXTABFOROBJECT = 12;
3622 print
'<!-- Section for a given module -->';
3626 if ($tab ==
'description') {
3627 print
'<!-- tab=description -->'.
"\n";
3628 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3629 $pathtofilereadme = $modulelowercase.
'/README.md';
3630 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3632 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3634 if ($action !=
'editfile' || empty($file)) {
3635 $morehtmlright =
'';
3636 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3637 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3640 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3642 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3648 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3649 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>';
3653 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3654 foreach ($listofsetuppages as $setuppage) {
3657 print
'<span class="fa fa-file"></span> ';
3658 if ($setuppage[
'relativename'] ==
'about.php') {
3659 print $langs->trans(
"AboutFile");
3661 print $langs->trans(
"SetupFile");
3664 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3665 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>';
3669 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3670 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>';
3673 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3674 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>';
3680 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3683 print
'<div class="underbanner clearboth"></div>';
3684 print
'<div class="fichecenter">';
3685 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3686 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3687 print
'<input type="hidden" name="action" value="update_props_module">';
3688 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3689 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3690 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3692 print
'<div class="div-table-responsive-no-min">';
3693 print
'<table class="border centpercent">';
3694 print
'<tr class="liste_titre"><td class="titlefield">';
3695 print $langs->trans(
"Parameter");
3697 print $langs->trans(
"Value");
3701 print $langs->trans(
"IdModule");
3704 print
'<span class="opacitymedium">';
3706 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3707 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3712 print $langs->trans(
"ModuleName");
3718 print $langs->trans(
"Description");
3720 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3721 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'">';
3722 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3723 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3726 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>';
3728 $moduledescritpionautotrans =
$moduleobj->getDesc();
3729 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
3731 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3732 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
3734 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3740 print $langs->trans(
"Version");
3742 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3743 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
3744 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3745 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3748 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=version">'.
img_edit().
'</a>';
3753 print $langs->trans(
"Family");
3756 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3757 print
'<select name="propsmodule" id="family" class="minwidth400">';
3758 $arrayoffamilies = array(
3759 'hr' =>
"ModuleFamilyHr",
3760 'crm' =>
"ModuleFamilyCrm",
3761 'srm' =>
"ModuleFamilySrm",
3762 'financial' =>
'ModuleFamilyFinancial',
3763 'products' =>
'ModuleFamilyProducts',
3764 'projects' =>
'ModuleFamilyProjects',
3765 'ecm' =>
'ModuleFamilyECM',
3766 'technic' =>
'ModuleFamilyTechnic',
3767 'portal' =>
'ModuleFamilyPortal',
3768 'interface' =>
'ModuleFamilyInterface',
3769 'base' =>
'ModuleFamilyBase',
3770 'other' =>
'ModuleFamilyOther'
3772 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>';
3773 foreach ($arrayoffamilies as $key => $value) {
3775 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3779 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3780 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3783 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>';
3788 print $langs->trans(
"Picto");
3790 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3791 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'">';
3792 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3793 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3796 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3797 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>';
3802 print $langs->trans(
"EditorName");
3804 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3805 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'">';
3806 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3807 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3810 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>';
3815 print $langs->trans(
"EditorUrl");
3817 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3818 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'">';
3819 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3820 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3823 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3825 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>';
3833 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3840 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3842 print
'<!-- readme file -->';
3843 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3844 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3846 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3852 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3854 print
'<!-- changelog file -->';
3856 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3858 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3867 if ($fullpathoffile) {
3868 $content = file_get_contents($fullpathoffile);
3872 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3873 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3874 print
'<input type="hidden" name="action" value="savefile">';
3875 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3876 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3877 print
'<input type="hidden" name="module" value="'.$module.
'">';
3881 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
3882 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3883 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3888 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3890 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3896 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3899 if ($tab ==
'languages') {
3900 print
'<!-- tab=languages -->'.
"\n";
3901 if ($action !=
'editfile' || empty($file)) {
3902 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3906 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3907 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3908 print
'<input type="hidden" name="action" value="addlanguage">';
3909 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3910 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3911 print
'<input type="hidden" name="module" value="'.$module.
'">';
3912 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
3913 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3919 $modulelowercase = strtolower($module);
3923 $diroflang .=
'/langs';
3924 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3926 if (!preg_match(
'/custom/', $dirread)) {
3928 $diroflang = $dirread;
3929 $diroflang .=
'/langs';
3930 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3933 print
'<table class="none">';
3934 foreach ($langfiles as $langfile) {
3935 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3936 if (!preg_match(
'/custom/', $dirread)) {
3937 $pathtofile =
'langs/'.$langfile[
'relativename'];
3939 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3940 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>';
3941 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>';
3952 $content = file_get_contents($fullpathoffile);
3955 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3956 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3957 print
'<input type="hidden" name="action" value="savefile">';
3958 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3959 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3960 print
'<input type="hidden" name="module" value="'.$module.
'">';
3962 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3963 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3966 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3968 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3975 if ($tab ==
'objects') {
3976 print
'<!-- tab=objects -->'.
"\n";
3981 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3983 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3984 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3985 $head3[$h][2] =
'newobject';
3989 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3991 $firstobjectname =
'';
3992 foreach ($listofobject as $fileobj) {
3993 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3996 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
4000 $tmpcontent = file_get_contents($fileobj[
'fullname']);
4001 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
4003 $objectname = $reg[1];
4004 if (empty($firstobjectname)) {
4005 $firstobjectname = $objectname;
4007 $pictoname =
'generic';
4008 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
4009 $pictoname = $reg[1];
4012 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
4013 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
4014 $head3[$h][2] = $objectname;
4020 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4021 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4022 $head3[$h][2] =
'deleteobject';
4027 if ($tabobj ==
'newobjectifnoobj') {
4028 if ($firstobjectname) {
4029 $tabobj = $firstobjectname;
4031 $tabobj =
'newobject';
4035 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4038 if ($tabobj ==
'newobject') {
4040 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4041 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4042 print
'<input type="hidden" name="action" value="initobject">';
4043 print
'<input type="hidden" name="tab" value="objects">';
4044 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4046 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4048 print
'<div class="tagtable">';
4050 print
'<div class="tagtr"><div class="tagtd">';
4051 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4052 print
'</div><div class="tagtd">';
4053 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
4054 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4055 print
'</div></div>';
4057 print
'<div class="tagtr"><div class="tagtd">';
4058 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4059 print
'</div><div class="tagtd">';
4060 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4062 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
4064 print
'<span class="opacitymedium small">';
4065 print
' ';
4066 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',
'',
'');
4069 print
'</div></div>';
4071 print
'<div class="tagtr"><div class="tagtd">';
4072 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4073 print
'</div><div class="tagtd">';
4074 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4075 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4076 print
'</div></div>';
4081 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>';
4082 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4083 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4085 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4101 } elseif ($tabobj ==
'createproperty') {
4102 $attributesUnique = array(
4103 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4104 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4105 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4106 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4107 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4108 'propdefault' => $langs->trans(
"DefaultValue"),
4109 'propindex' => $langs->trans(
"DatabaseIndex"),
4110 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4111 'propposition' => $langs->trans(
"Position"),
4112 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4113 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4114 'propnoteditable' => $langs->trans(
"NotEditable"),
4116 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4117 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4118 'propcss' => $langs->trans(
"CSSClass"),
4119 'propcssview' => $langs->trans(
"CSSViewClass"),
4120 'propcsslist' => $langs->trans(
"CSSListClass"),
4121 'prophelp' => $langs->trans(
"KeyForTooltip"),
4122 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4124 'propcomment' => $langs->trans(
"Comment"),
4126 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4127 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4128 print
'<input type="hidden" name="action" value="addproperty">';
4129 print
'<input type="hidden" name="tab" value="objects">';
4130 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4131 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4133 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4135 foreach ($attributesUnique as $key => $attribute) {
4136 if ($counter % 2 === 0) {
4139 if ($key ==
'propname' || $key ==
'proplabel') {
4140 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>';
4141 } elseif ($key ==
'proptype') {
4142 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4143 print
'<input class="maxwidth200" name="'.$key.
'" id="'.$key.
'" list="datalist'.$key.
'" type="text" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4145 print
'<datalist id="datalist'.$key.
'">';
4146 print
'<option>varchar(128)</option>';
4147 print
'<option>email</option>';
4148 print
'<option>phone</option>';
4149 print
'<option>ip</option>';
4150 print
'<option>url</option>';
4151 print
'<option>password</option>';
4152 print
'<option>text</option>';
4153 print
'<option>html</option>';
4154 print
'<option>date</option>';
4155 print
'<option>datetime</option>';
4156 print
'<option>integer</option>';
4157 print
'<option>stars(5)</option>';
4158 print
'<option>double(28,4)</option>';
4159 print
'<option>real</option>';
4160 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4169 print
'</datalist>';
4173 } elseif ($key ==
'propvisible') {
4174 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>';
4175 } elseif ($key ==
'propenabled') {
4178 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>';
4179 } elseif ($key ==
'proparrayofkeyval') {
4180 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>';
4182 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>';
4185 if ($counter % 2 === 0) {
4189 if ($counter % 2 !== 0) {
4190 while ($counter % 2 !== 0) {
4196 print
'</table><br>'.
"\n";
4197 print
'<div class="center">';
4198 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4199 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4205 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4206 window.location.href = url;
4208 $(document).ready(function() {
4209 $("#proplabel").on("keyup", function() {
4210 console.log("key up on label");
4211 s = cleanString($("#proplabel").val());
4212 $("#propname").val(s);
4215 function cleanString( stringtoclean )
4217 // allow "a-z", "A-Z", "0-9" and "_"
4218 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4219 stringtoclean = stringtoclean.toLowerCase();
4220 if (!isNaN(stringtoclean)) {
4223 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4224 stringtoclean = stringtoclean.substr(1)
4226 if (stringtoclean.length > 28) {
4227 stringtoclean = stringtoclean.substring(0, 27);
4229 return stringtoclean;
4234 } elseif ($tabobj ==
'deleteobject') {
4236 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4237 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4238 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4239 print
'<input type="hidden" name="tab" value="objects">';
4240 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4241 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4243 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4245 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4246 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4250 if ($action ==
'deleteproperty') {
4251 $formconfirm = $form->formconfirm(
4252 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4253 $langs->trans(
'Delete'),
4254 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4255 'confirm_deleteproperty',
4264 if ($action !=
'editfile' || empty($file)) {
4268 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4269 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4270 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4271 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4272 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4273 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4274 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4275 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4276 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4279 clearstatcache(
true);
4280 if (function_exists(
'opcache_invalidate')) {
4281 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4284 if (empty($forceddirread) && empty($dirread)) {
4286 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4288 $result = include_once $dirread.
'/'.$pathtoclass;
4289 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4292 if (class_exists($tabobj)) {
4294 $tmpobject = @
new $tabobj($db);
4296 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4299 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4303 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4306 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4309 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4312 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4315 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4316 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4319 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4322 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4325 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4328 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4330 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4332 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4333 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4335 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4336 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4338 $tmpobject = $tmpobject ??
null;
4339 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4340 $pathtopicto = $tmpobject->picto;
4341 $realpathtopicto =
'';
4343 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4344 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4349 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4350 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4351 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4352 $realpathtocard = $dirread.
'/'.$pathtocard;
4353 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4354 $realpathtolist = $dirread.
'/'.$pathtolist;
4355 $realpathtonote = $dirread.
'/'.$pathtonote;
4356 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4357 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4358 $realpathtosql = $dirread.
'/'.$pathtosql;
4359 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4360 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4361 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4362 $realpathtolib = $dirread.
'/'.$pathtolib;
4363 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4365 if (empty($realpathtoapi)) {
4366 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4367 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4377 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4378 $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>';
4379 $htmltooltip .=
'<br>';
4380 } elseif (!empty($tmpobject)) {
4381 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4382 $htmltooltip .=
'<br>';
4384 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsExtraFieldManaged").
' : '.
yn(empty($tmpobject->isextrafieldmanaged) ? 0 : 1, 1, 2);
4385 $htmltooltip .=
'<br>';
4386 $htmltooltip .=
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"IsMultiEntityManaged").
' : '.
yn(empty($tmpobject->ismultientitymanaged) ? 0 : 1, 1, 2);
4387 $htmltooltip .=
'<br>';
4389 print
'<!-- section for object -->';
4390 print
'<div class="fichehalfleft smallxxx">';
4392 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>';
4393 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>';
4394 print $form->textwithpicto(
'', $htmltooltip, 1,
'help',
'valignmiddle', 1);
4399 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>';
4401 $file = file_get_contents($realpathtoapi);
4402 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4403 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>';
4405 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>';
4406 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4409 if (!isModEnabled($modulelowercase)) {
4410 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4412 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4415 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>';
4418 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>';
4422 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>';
4424 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>';
4426 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>';
4428 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>';
4434 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>';
4435 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>';
4437 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>';
4438 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>';
4442 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>';
4443 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>';
4444 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>';
4447 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>';
4448 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>';
4451 if (!empty($tmpobject->isextrafieldmanaged)) {
4452 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>';
4454 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>';
4456 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>';
4458 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>';
4460 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>';
4465 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>';
4467 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>';
4469 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>';
4471 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>';
4477 print
'<div class="fichehalfleft smallxxxx">';
4478 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>';
4479 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>';
4481 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>';
4482 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>';
4485 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>';
4486 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>';
4489 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>';
4491 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>';
4495 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>';
4496 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>';
4499 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>';
4501 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>';
4505 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>';
4506 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>';
4509 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>';
4511 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>';
4515 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>';
4516 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>';
4519 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>';
4521 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>';
4528 print
'<br><br><br>';
4530 if (!empty($tmpobject)) {
4531 $reflector =
new ReflectionClass($tabobj);
4532 $reflectorproperties = $reflector->getProperties();
4533 $reflectorpropdefault = $reflector->getDefaultProperties();
4537 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4538 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4539 print
'<input type="hidden" name="action" value="addproperty">';
4540 print
'<input type="hidden" name="tab" value="objects">';
4541 print
'<input type="hidden" name="page_y" value="">';
4542 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4543 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4545 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4546 print
'<br><br class="clearboth">';
4547 print
'<br class="clearboth">';
4549 $mod = strtolower($module);
4550 $obj = strtolower($tabobj);
4551 $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));
4552 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4554 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
4557 print
'<!-- Table with properties of object -->'.
"\n";
4558 print
'<div class="div-table-responsive">';
4559 print
'<table class="noborder small">';
4560 print
'<tr class="liste_titre">';
4561 if (!empty(
$conf->main_checkbox_left_column)) {
4562 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4564 print
'<th class="tdsticky tdstickygray">';
4565 $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>';
4566 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4569 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4571 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4572 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4573 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4574 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4575 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4576 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4577 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4578 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4579 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4580 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4582 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4583 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4584 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4585 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4586 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4587 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4588 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4590 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4591 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4592 if (empty(
$conf->main_checkbox_left_column)) {
4593 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4600 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4601 if (!empty($properties)) {
4603 foreach ($properties as $propkey => $propval) {
4618 $propname = $propkey;
4619 $proplabel = $propval[
'label'];
4620 $proptype = $propval[
'type'];
4621 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4622 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4623 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4624 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4625 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4626 $propposition = $propval[
'position'];
4627 $propenabled = $propval[
'enabled'];
4628 $propvisible = $propval[
'visible'];
4629 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4631 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4632 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4633 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4634 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4635 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4636 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4637 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4639 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4640 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4642 print
'<!-- line for object property -->'.
"\n";
4643 print
'<tr class="oddeven">';
4645 if (!empty(
$conf->main_checkbox_left_column)) {
4646 if ($action ==
'editproperty' && $propname == $propertykey) {
4647 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4648 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4649 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4652 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4653 if ($propname !=
'rowid') {
4654 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>';
4655 print
'<a class="reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteproperty&token='.
newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
4660 print
'<td class="tdsticky tdstickygray">';
4663 if ($action ==
'editproperty' && $propname == $propertykey) {
4665 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4666 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4668 print
'<td class="tdoverflowmax150">';
4669 print
'<input name="proptype" id="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'" list="datalistproptype"></input>';
4671 print
'<datalist id="datalistproptype">';
4672 print
'<option>varchar(128)</option>';
4673 print
'<option>email</option>';
4674 print
'<option>phone</option>';
4675 print
'<option>ip</option>';
4676 print
'<option>url</option>';
4677 print
'<option>password</option>';
4678 print
'<option>text</option>';
4679 print
'<option>html</option>';
4680 print
'<option>date</option>';
4681 print
'<option>datetime</option>';
4682 print
'<option>integer</option>';
4683 print
'<option>stars(5)</option>';
4684 print
'<option>double(28,4)</option>';
4685 print
'<option>real</option>';
4686 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4695 print
'</datalist>';
4698 print
'<td class="tdoverflowmax200">';
4699 print
'<textarea name="proparrayofkeyval">';
4700 if (isset($proparrayofkeyval)) {
4701 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4705 print
'</textarea>';
4708 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4711 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4713 print
'<td class="center">';
4714 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4717 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4720 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4723 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4726 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4729 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4735 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4738 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4741 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4744 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4747 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4750 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4753 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4756 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4759 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4761 if (empty(
$conf->main_checkbox_left_column)) {
4762 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4763 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4764 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4768 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4771 print
'<td class="tdoverflowmax200">';
4774 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4775 $pictoType =
'varchar';
4776 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4777 $pictoType =
'link';
4778 } elseif (strpos($proptype,
'integer') === 0) {
4779 $pictoType = substr($proptype, 0, 3);
4780 } elseif (strpos($proptype,
'timestamp') === 0) {
4781 $pictoType =
'datetime';
4782 } elseif (strpos($proptype,
'real') === 0) {
4783 $pictoType =
'double';
4784 } elseif (strpos($proptype,
'stars') === 0) {
4785 $pictoType =
'stars';
4789 print
'<td class="tdoverflowmax200">';
4790 if ($proparrayofkeyval) {
4791 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4796 print
'<td class="center">';
4802 print
'<td class="center">';
4803 print $propindex ?
'1' :
'';
4805 print
'<td class="center">';
4808 print
'<td class="right">';
4811 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4815 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4819 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4825 print
'<td class="center">';
4826 print $propsearchall ?
'1' :
'';
4828 print
'<td class="center">';
4831 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4834 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4837 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4841 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4844 print
'<td class="center">';
4850 print
'<td class="center">';
4853 print
'<td class="tdoverflowmax200">';
4854 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4858 if (empty(
$conf->main_checkbox_left_column)) {
4859 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4860 if ($propname !=
'rowid') {
4861 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>';
4862 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>';
4870 if ($tab ==
'specifications') {
4871 if ($action !=
'editfile' || empty($file)) {
4872 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4877 foreach ($specs as $spec) {
4878 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4879 $format =
'asciidoc';
4880 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4881 $format =
'markdown';
4883 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4884 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>';
4894 $content = file_get_contents($fullpathoffile);
4897 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4898 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4899 print
'<input type="hidden" name="action" value="savefile">';
4900 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4901 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4902 print
'<input type="hidden" name="module" value="'.$module.
'">';
4904 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4905 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4908 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4910 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4916 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>';
4923 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4927 print $e->getMessage();
4931 if (empty($forceddirread)) {
4934 $fullpathoffile = $dirread.
'/'.$file;
4937 $content = file_get_contents($fullpathoffile);
4940 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4941 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4942 print
'<input type="hidden" name="action" value="savefile">';
4943 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4944 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4945 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4946 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4948 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4949 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4952 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4954 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4964 if ($tab ==
'dictionaries') {
4965 print
'<!-- tab=dictionaries -->'.
"\n";
4966 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4970 if ($action ==
'deletedict') {
4971 $formconfirm = $form->formconfirm(
4972 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
4973 $langs->trans(
'Delete'),
4974 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
4975 'confirm_deletedictionary',
4983 if ($action !=
'editfile' || empty($file)) {
4984 print
'<span class="opacitymedium">';
4985 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4986 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4987 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4991 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4992 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>';
4994 if (is_array($dicts) && !empty($dicts)) {
4995 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4996 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
5007 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
5008 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
5009 $head3[$h][2] =
'newdictionary';
5050 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).
'&tabdic=newdictionary');
5051 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
5053 if ($tabdic !=
'newdictionary') {
5054 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5055 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5056 print
'<input type="hidden" name="action" value="addDictionary">';
5057 print
'<input type="hidden" name="tab" value="dictionaries">';
5058 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5059 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
5061 print
'<div class="div-table-responsive">';
5062 print
'<table class="noborder">';
5064 print
'<tr class="liste_titre">';
5065 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
5078 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
5080 $maxi = count($dicts[
'tabname']);
5081 while ($i < $maxi) {
5082 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5083 print
'<tr class="oddeven">';
5084 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5085 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5086 print
'<input type="hidden" name="tab" value="dictionaries">';
5087 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5088 print
'<input type="hidden" name="action" value="updatedictionary">';
5089 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5091 print
'<td class="tdsticky tdstickygray">';
5096 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5100 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5104 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5108 print
'<select name="tabsqlsort">';
5109 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5113 print
'<td><select name="tabfield" >';
5114 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5115 print
'</select></td>';
5117 print
'<td><select name="tabfieldvalue" >';
5118 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5119 print
'</select></td>';
5121 print
'<td><select name="tabfieldinsert" >';
5122 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5123 print
'</select></td>';
5126 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5130 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5133 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5134 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5136 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5142 print
'<tr class="oddeven">';
5144 print
'<td class="tdsticky tdstickygray">';
5149 print $dicts[
'tabname'][$i];
5153 print $dicts[
'tablib'][$i];
5157 print $dicts[
'tabsql'][$i];
5161 print $dicts[
'tabsqlsort'][$i];
5165 print $dicts[
'tabfield'][$i];
5169 print $dicts[
'tabfieldvalue'][$i];
5173 print $dicts[
'tabfieldinsert'][$i];
5177 print $dicts[
'tabrowid'][$i];
5181 print $dicts[
'tabcond'][$i];
5184 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5185 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>';
5186 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>';
5194 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5203 if ($tabdic ==
'newdictionary') {
5205 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5206 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5207 print
'<input type="hidden" name="action" value="initdic">';
5208 print
'<input type="hidden" name="tab" value="dictionaries">';
5209 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5211 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5213 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5216 print
'<table class="border centpercent">';
5218 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>';
5219 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>';
5220 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>';
5221 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>';
5222 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5223 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5224 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5225 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5227 print
'</tbody></table>';
5228 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5229 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5233 $(document).ready(function() {
5234 $("input[name=\'dicname\']").on("blur", function() {
5235 if ($(this).val().length > 0) {
5236 $("input[name=\'label\']").val($(this).val());
5237 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5238 $("input[name=\'sqlsort\']").val("label ASC");
5239 $("input[name=\'field\']").val("code,label");
5240 $("input[name=\'fieldvalue\']").val("code,label");
5241 $("input[name=\'fieldinsert\']").val("code,label");
5242 $("input[name=\'rowid\']").val("rowid");
5244 $("input[name=\'label\']").val("");
5245 $("input[name=\'sql\']").val("");
5246 $("input[name=\'sqlsort\']").val("");
5247 $("input[name=\'field\']").val("");
5248 $("input[name=\'fieldvalue\']").val("");
5249 $("input[name=\'fieldinsert\']").val("");
5250 $("input[name=\'rowid\']").val("");
5253 $("input[id=\'cancel\']").click(function() {
5254 window.history.back();
5271 } elseif ($tabdic ==
'deletedictionary') {
5273 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5275 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5276 print
'<input type="hidden" name="tab" value="dictionaries">';
5277 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5279 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5281 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5282 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5290 $content = file_get_contents($fullpathoffile);
5293 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5294 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5295 print
'<input type="hidden" name="action" value="savefile">';
5296 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5297 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5298 print
'<input type="hidden" name="module" value="'.$module.
'">';
5300 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5301 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5302 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5305 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5307 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5314 if ($tab ==
'menus') {
5315 print
'<!-- tab=menus -->'.
"\n";
5316 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5317 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
5318 $destdir = $dirins.
'/'.strtolower($module);
5319 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5322 $leftmenus = array();
5327 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5330 $groupedRights = array();
5331 foreach ($permissions as $right) {
5333 if (!isset($groupedRights[$key])) {
5334 $groupedRights[$key] = array();
5336 $groupedRights[$key][] = $right;
5338 $groupedRights_json = json_encode($groupedRights);
5340 if ($action ==
'deletemenu') {
5341 $formconfirms = $form->formconfirm(
5342 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5343 $langs->trans(
'Delete'),
5344 ($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'))),
5345 'confirm_deletemenu',
5350 print $formconfirms;
5352 if ($action !=
'editfile' || empty($file)) {
5353 print
'<span class="opacitymedium">';
5354 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5355 $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);
5356 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5361 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5362 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>';
5366 $listODifferentUrlsInMenu = array();
5367 foreach ($menus as $obj) {
5368 if (preg_match(
'/^\/'.preg_quote(strtolower($module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5369 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5372 $pathtofile = $obj[
'url'];
5373 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5374 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5375 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>';
5384 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5385 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5386 print
'<input type="hidden" name="action" value="addmenu">';
5387 print
'<input type="hidden" name="tab" value="menus">';
5388 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5389 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5391 print
'<div class="div-table-responsive">';
5392 print
'<table class="noborder small">';
5394 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5395 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5396 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5397 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(strtolower($module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5398 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5399 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5400 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(strtolower($module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5402 print
'<tr class="liste_titre">';
5403 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5406 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5409 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5411 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5412 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5413 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5414 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5415 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5416 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5419 $r = count($menus) + 1;
5422 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5423 print
'<td class="center">';
5424 print
'<select class="maxwidth50" name="type">';
5425 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5426 print
'</select></td>';
5427 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5428 print
'<td class="left">';
5429 print
'<select name="fk_menu">';
5430 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5431 foreach ($menus as $obj) {
5432 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5433 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5438 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>';
5439 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5441 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5442 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5444 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5446 print
'<td class="center">';
5447 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.$module.
'\')').
'">';
5456 print
'<td class="left">';
5457 print
'<select class="maxwidth" name="objects" id="objects">';
5458 print
'<option value=""></option>';
5459 if (is_array($objects)) {
5460 foreach ($objects as $value) {
5461 print
'<option value="'.strtolower($value).
'">'.
dol_escape_htmltag(strtolower($value)).
'</option>';
5465 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5468 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5469 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>';
5471 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5472 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5480 if (count($menus)) {
5482 foreach ($menus as $menu) {
5486 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
5488 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5489 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5490 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5491 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5492 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5493 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5494 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5495 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5496 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5498 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5499 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5503 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5505 print
'<tr class="oddeven">';
5506 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5507 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5508 print
'<input type="hidden" name="action" value="update_menu">';
5509 print
'<input type="hidden" name="tab" value="menus">';
5510 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5511 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5513 print
'<td class="tdsticky tdstickygray">';
5517 print
'<td class="center">
5518 <select class="center maxwidth50" name="type">
5519 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5522 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5523 if ($menu[
'type'] ==
'left') {
5528 print
'</option></select></td>';
5530 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5541 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5543 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5544 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5546 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5547 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5549 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5551 print
'<td class="nowraponall">';
5552 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag($module).
"')").
'">';
5553 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5554 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5555 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5556 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag($module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5557 print $form->textwithpicto('', $htmltext);
5559 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5560 print '<option value=
"1">1 (always enabled)</option>
';
5561 print '<option value=
"0">0 (always
disabled)</option>
';
5562 print '<option value=
"isModEnabled(\''.dol_escape_htmltag($module).'\')" >isModEnabled(\
''.
dol_escape_htmltag($module).
'\')</option>
';
5567 print '<td
class=
"nowraponall">
';
5568 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5570 if (!empty($objPerms)) {
5571 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5572 print '<select
class=
"center maxwidth50" name=
"perms">
';
5573 if (!empty($valPerms)) {
5574 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5575 foreach ($crud as $key => $val) {
5576 if ($valPerms != $key) {
5577 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5583 print '<select
class=
"center maxwidth50" name=
"objects">
';
5584 print '<option></option>
';
5585 foreach ($objects as $obj) {
5586 print '<option value=
"'.dol_escape_htmltag(strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5589 print '<select
class=
"center maxwidth50" name=
"perms">
';
5590 foreach ($crud as $key => $val) {
5591 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5597 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5598 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>
';
5599 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5600 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5601 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5606 print '<tr
class=
"oddeven">
';
5608 print '<td
class=
"tdsticky tdstickygray">
';
5612 print '<td
class=
"center">
';
5613 print dol_escape_htmltag($menu['type']);
5618 print dol_escape_htmltag($menu['titre
']);
5622 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5623 print dol_escape_htmltag($menu['fk_menu
']);
5627 print dol_escape_htmltag($menu['mainmenu
']);
5631 print dol_escape_htmltag($menu['leftmenu
']);
5634 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5635 print dol_escape_htmltag($menu['url
']);
5639 print dol_escape_htmltag($menu['langs
']);
5643 print '<td
class=
"center">
';
5644 print dol_escape_htmltag((string) $menu['position']);
5648 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5649 print dol_escape_htmltag($menu['enabled
']);
5653 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5654 print dol_escape_htmltag($langs->trans($menu['perms
']));
5658 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5659 print dol_escape_htmltag($menu['target
']);
5662 print '<td
class=
"center">
';
5663 if ($menu['user'] == 2) {
5664 print $langs->trans("AllMenus");
5665 } elseif ($menu['user'] == 0) {
5666 print $langs->trans('Internal
');
5667 } elseif ($menu['user'] == 1) {
5668 print $langs->trans('External
');
5670 print $menu['user']; // should not happen
5673 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
5674 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
5675 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>
';
5676 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>
';
5683 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
5692 $(document).ready(
function() {
5694 $(
"#leftmenu").on(
"input",
function() {
5695 var inputLeftMenu = $(
"#leftmenu").val();
5696 if (inputLeftMenu !== \
'\') {
5697 var url = \
''.dol_escape_js(strtolower($module)).
'\' + inputLeftMenu + \
'.php\';
5704 var groupedRights = ' . $groupedRights_json .
';
5705 var objectsSelect = $("select[id=\'objects\']");
5706 var permsSelect = $("select[id=\'perms\']");
5708 objectsSelect.change(function() {
5709 var selectedObject = $(this).val();
5711 permsSelect.empty();
5713 var rights = groupedRights[selectedObject];
5716 for (var i = 0; i < rights.length; i++) {
5717 var right = rights[i];
5718 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
5719 permsSelect.append(option);
5722 var option = $("<option></option>").attr("value", "read").text("read");
5723 permsSelect.append(option);
5726 if (selectedObject !== "" && selectedObject !== null && rights) {
5731 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
5742 $content = file_get_contents($fullpathoffile);
5745 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5746 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5747 print
'<input type="hidden" name="action" value="savefile">';
5748 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5749 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5750 print
'<input type="hidden" name="module" value="'.$module.
'">';
5752 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5753 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5754 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5757 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5759 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5766 if ($tab ==
'permissions') {
5767 print
'<!-- tab=permissions -->'.
"\n";
5768 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5773 $dir = $dirread.
'/'.$modulelowercase.
'/class';
5774 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
5775 $objects = array(
'myobject');
5777 foreach ($listofobject as $fileobj) {
5778 $tmpcontent = file_get_contents($fileobj[
'fullname']);
5779 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
5780 $objects[$fileobj[
'fullname']] = $reg[1];
5785 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5786 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
5788 $action =
GETPOST(
'action',
'alpha');
5790 if ($action ==
'deleteright') {
5791 $formconfirm = $form->formconfirm(
5792 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)),
5793 $langs->trans(
'Delete'),
5794 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
5795 'confirm_deleteright',
5803 if ($action !=
'editfile' || empty($file)) {
5804 print
'<!-- Tab to manage permissions -->'.
"\n";
5805 print
'<span class="opacitymedium">';
5806 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
5807 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
5808 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5812 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5813 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>';
5819 print
'<!-- form to add permissions -->'.
"\n";
5820 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5821 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5822 print
'<input type="hidden" name="action" value="addright">';
5823 print
'<input type="hidden" name="tab" value="permissions">';
5824 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5825 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5827 print
'<div class="div-table-responsive">';
5828 print
'<table class="noborder">';
5830 print
'<tr class="liste_titre">';
5832 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
5839 print
'<tr class="small">';
5840 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
5842 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
5843 print
'<option value=""></option>';
5844 foreach ($objects as $obj) {
5845 if ($obj !=
'myobject') {
5846 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
5849 print
'</select></td>';
5851 print
'<td><select class="maxwidth75" name="crud" id="crud">';
5852 print
'<option value=""></option>';
5853 foreach ($crud as $key => $val) {
5854 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
5859 print
'<input type="text" name="label" id="label" class="minwidth200">';
5862 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5863 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5867 if (count($perms)) {
5869 foreach ($perms as $perm) {
5873 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
5874 print
'<tr class="oddeven">';
5875 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
5876 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5877 print
'<input type="hidden" name="tab" value="permissions">';
5878 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5879 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5880 print
'<input type="hidden" name="action" value="update_right">';
5881 print
'<input type="hidden" name="counter" value="'.$i.
'">';
5883 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
5885 print
'<td class="tdsticky tdstickygray">';
5886 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
5890 print
'<select name="crud">';
5891 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
5892 foreach ($crud as $i => $x) {
5893 if ($perm[5] != $i) {
5894 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
5900 print
'<td><select name="permissionObj" >';
5901 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
5902 print
'</select></td>';
5905 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
5908 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5909 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
5911 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5918 print
'<tr class="oddeven">';
5925 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5933 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5934 print ucfirst($langs->trans($perm[5]));
5936 print ucfirst($langs->trans($perm[4]));
5941 print $langs->trans($perm[1]);
5944 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5945 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>';
5946 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>';
5954 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5962 function updateInputField() {
5963 value1 = $("#crud").val();
5964 value2 = $("#permissionObj").val();
5966 // Vérifie si les deux sélections sont faites
5967 if (value1 && value2) {
5968 switch(value1.toLowerCase()){
5970 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
5973 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
5976 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
5984 $("#crud, #permissionObj").change(function(){
5985 console.log("We change selection");
5993 $content = file_get_contents($fullpathoffile);
5996 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5997 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5998 print
'<input type="hidden" name="action" value="savefile">';
5999 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6000 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6001 print
'<input type="hidden" name="module" value="'.$module.
'">';
6003 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6004 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6005 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6008 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6010 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6017 if ($tab ==
'hooks') {
6018 print
'<!-- tab=hooks -->'.
"\n";
6019 if ($action !=
'editfile' || empty($file)) {
6020 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
6025 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6027 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6029 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>';
6033 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
6034 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
6036 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6038 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> ';
6039 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>';
6041 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6042 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>';
6049 $content = file_get_contents($fullpathoffile);
6052 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6053 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6054 print
'<input type="hidden" name="action" value="savefile">';
6055 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6056 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6057 print
'<input type="hidden" name="module" value="'.$module.
'">';
6059 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6060 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6061 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6064 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6066 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6073 if ($tab ==
'triggers') {
6074 print
'<!-- tab=triggers -->'.
"\n";
6075 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
6078 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
6080 if ($action !=
'editfile' || empty($file)) {
6081 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6086 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6088 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6090 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>';
6093 if (!empty($triggers)) {
6094 foreach ($triggers as $trigger) {
6095 $pathtofile = $trigger[
'relpath'];
6098 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6099 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>';
6100 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>';
6105 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6106 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6107 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>';
6116 $content = file_get_contents($fullpathoffile);
6119 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6120 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6121 print
'<input type="hidden" name="action" value="savefile">';
6122 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6123 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6124 print
'<input type="hidden" name="module" value="'.$module.
'">';
6126 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6127 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6128 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6131 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6133 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6140 if ($tab ==
'css') {
6141 print
'<!-- tab=css -->'.
"\n";
6142 if ($action !=
'editfile' || empty($file)) {
6143 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6149 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
6150 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6152 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6153 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>';
6154 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>';
6156 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6157 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>';
6163 $content = file_get_contents($fullpathoffile);
6166 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6167 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6168 print
'<input type="hidden" name="action" value="savefile">';
6169 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6170 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6171 print
'<input type="hidden" name="module" value="'.$module.
'">';
6173 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6174 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6177 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6179 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6187 print
'<!-- tab=js -->'.
"\n";
6188 if ($action !=
'editfile' || empty($file)) {
6189 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6195 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
6196 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6198 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6199 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>';
6200 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>';
6202 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6203 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>';
6209 $content = file_get_contents($fullpathoffile);
6212 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6214 print
'<input type="hidden" name="action" value="savefile">';
6215 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6216 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6217 print
'<input type="hidden" name="module" value="'.$module.
'">';
6219 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6220 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6223 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6225 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6232 if ($tab ==
'widgets') {
6233 print
'<!-- tab=widgets -->'.
"\n";
6234 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6238 if ($action !=
'editfile' || empty($file)) {
6239 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6243 if (!empty($widgets)) {
6244 foreach ($widgets as $widget) {
6245 $pathtofile = $widget[
'relpath'];
6247 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6248 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>';
6249 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>';
6253 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6254 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>';
6261 $content = file_get_contents($fullpathoffile);
6264 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6265 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6266 print
'<input type="hidden" name="action" value="savefile">';
6267 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6268 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6269 print
'<input type="hidden" name="module" value="'.$module.
'">';
6271 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6272 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6275 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6277 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6284 if ($tab ==
'emailings') {
6285 print
'<!-- tab=emailings -->'.
"\n";
6286 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6290 if ($action !=
'editfile' || empty($file)) {
6291 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6295 if (!empty($emailingselectors)) {
6296 foreach ($emailingselectors as $emailingselector) {
6297 $pathtofile = $emailingselector[
'relpath'];
6299 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6300 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>';
6301 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>';
6305 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6306 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>';
6313 $content = file_get_contents($fullpathoffile);
6316 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6317 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6318 print
'<input type="hidden" name="action" value="savefile">';
6319 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6320 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6321 print
'<input type="hidden" name="module" value="'.$module.
'">';
6323 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6324 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6327 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6329 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6336 if ($tab ==
'exportimport') {
6337 print
'<!-- tab=exportimport -->'.
"\n";
6338 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6343 if ($action !=
'editfile' || empty($file)) {
6344 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6347 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6348 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>';
6350 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6351 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>';
6356 $content = file_get_contents($fullpathoffile);
6359 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6360 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6361 print
'<input type="hidden" name="action" value="savefile">';
6362 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6363 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6364 print
'<input type="hidden" name="module" value="'.$module.
'">';
6366 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6367 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6368 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6371 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6373 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6380 if ($tab ==
'cli') {
6381 print
'<!-- tab=cli -->'.
"\n";
6382 $clifiles = array();
6385 $dircli = array(
'/'.strtolower($module).
'/scripts');
6387 foreach ($dircli as $reldir) {
6392 if (!is_dir($newdir)) {
6396 $handle = opendir($newdir);
6398 if (is_resource($handle)) {
6399 while (($tmpfile = readdir($handle)) !==
false) {
6400 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6401 if (preg_match(
'/\.back$/', $tmpfile)) {
6405 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6414 if ($action !=
'editfile' || empty($file)) {
6415 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6419 if (!empty($clifiles)) {
6420 foreach ($clifiles as $clifile) {
6421 $pathtofile = $clifile[
'relpath'];
6423 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6424 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>';
6425 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>';
6429 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6430 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>';
6437 $content = file_get_contents($fullpathoffile);
6440 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6441 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6442 print
'<input type="hidden" name="action" value="savefile">';
6443 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6444 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6445 print
'<input type="hidden" name="module" value="'.$module.
'">';
6447 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6448 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6451 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6453 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6460 if ($tab ==
'cron') {
6461 print
'<!-- tab=cron -->'.
"\n";
6462 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6466 if ($action !=
'editfile' || empty($file)) {
6467 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>';
6470 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6471 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>';
6477 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6478 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6479 print
'<input type="hidden" name="action" value="addproperty">';
6480 print
'<input type="hidden" name="tab" value="objects">';
6481 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6482 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6484 print
'<div class="div-table-responsive">';
6485 print
'<table class="noborder">';
6487 print
'<tr class="liste_titre">';
6495 if (count($cronjobs)) {
6496 foreach ($cronjobs as $cron) {
6497 print
'<tr class="oddeven">';
6500 print $cron[
'label'];
6505 if ($cron[
'jobtype'] ==
'method') {
6506 $text = $langs->trans(
"CronClass");
6507 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
6508 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6509 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6510 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6511 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6512 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6513 } elseif ($cron[
'jobtype'] ==
'command') {
6514 $text = $langs->trans(
'CronCommand');
6515 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6516 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6517 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6519 print $form->textwithpicto($text, $texttoshow, 1);
6523 if ($cron[
'unitfrequency'] ==
"60") {
6524 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6526 if ($cron[
'unitfrequency'] ==
"3600") {
6527 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6529 if ($cron[
'unitfrequency'] ==
"86400") {
6530 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6532 if ($cron[
'unitfrequency'] ==
"604800") {
6533 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6538 print $cron[
'status'];
6542 if (!empty($cron[
'comment'])) {
6543 print $cron[
'comment'];
6550 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6560 $content = file_get_contents($fullpathoffile);
6563 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6565 print
'<input type="hidden" name="action" value="savefile">';
6566 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6567 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6568 print
'<input type="hidden" name="module" value="'.$module.
'">';
6570 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6571 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6572 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6575 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6577 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6584 if ($tab ==
'specifications') {
6585 print
'<!-- tab=specifications -->'.
"\n";
6588 if ($action !=
'editfile' || empty($file)) {
6589 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6593 if (is_array($specs) && !empty($specs)) {
6594 foreach ($specs as $spec) {
6595 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6596 $format =
'asciidoc';
6597 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6598 $format =
'markdown';
6601 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6602 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>';
6603 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>';
6608 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6609 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>';
6620 $content = file_get_contents($fullpathoffile);
6623 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6624 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6625 print
'<input type="hidden" name="action" value="savefile">';
6626 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6627 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6628 print
'<input type="hidden" name="module" value="'.$module.
'">';
6630 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6631 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6634 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6636 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6642 print
'<br><br><br>';
6644 $FILENAMEDOC = $modulelowercase.
'.html';
6645 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6646 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6647 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6648 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6649 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6650 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6651 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6654 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6656 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6659 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6660 print $outputfiledoc;
6663 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6664 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>';
6666 print
'</strong><br>';
6669 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
6671 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6674 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
6675 print $outputfiledocpdf;
6678 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
6679 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>';
6681 print
'</strong><br>';
6685 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
6686 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6687 print
'<input type="hidden" name="action" value="generatedoc">';
6688 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6689 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6690 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
6691 if (!is_array($specs) || empty($specs)) {
6692 print
' disabled="disabled"';
6698 if ($tab ==
'buildpackage') {
6699 print
'<!-- tab=buildpackage -->'.
"\n";
6700 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
6703 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
6704 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
6708 $modulelowercase = strtolower($module);
6714 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6716 $class =
'mod'.$module;
6718 if (class_exists($class)) {
6721 '@phan-var-force DolibarrModules $moduleobj';
6730 $langs->load(
"errors");
6731 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
6735 $arrayversion = explode(
'.',
$moduleobj->version, 3);
6736 if (count($arrayversion)) {
6737 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
6738 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
6743 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
6744 if ($outputfilezip ===
null || !
dol_is_file($outputfilezip)) {
6745 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6747 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
6748 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
6749 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
6750 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>';
6758 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
6759 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6760 print
'<input type="hidden" name="action" value="generatepackage">';
6761 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6762 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6763 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
6767 if ($tab ==
'tabs') {
6768 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6772 if ($action !=
'editfile' || empty($file)) {
6773 print
'<span class="opacitymedium">';
6774 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
6775 $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);
6776 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6780 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
6781 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>';
6787 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6788 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6789 print
'<input type="hidden" name="action" value="addproperty">';
6790 print
'<input type="hidden" name="tab" value="objects">';
6791 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6792 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6794 print
'<div class="div-table-responsive">';
6795 print
'<table class="noborder small">';
6797 print
'<tr class="liste_titre">';
6807 foreach ($tabs as $tab) {
6808 $parts = explode(
':', $tab[
'data']);
6810 $objectType = $parts[0];
6811 $tabName = $parts[1];
6812 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
6813 $langFile = isset($parts[3]) ? $parts[3] :
'';
6814 $condition = isset($parts[4]) ? $parts[4] :
'';
6815 $path = isset($parts[5]) ? $parts[5] :
'';
6819 if ($tabName[0] ===
'-') {
6821 $condition = isset($parts[2]) ? $parts[2] :
'';
6824 print
'<tr class="oddeven">';
6831 if ($tabName[0] ===
"+") {
6832 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6834 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6857 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6867 $content = file_get_contents($fullpathoffile);
6870 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6871 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6872 print
'<input type="hidden" name="action" value="savefile">';
6873 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6874 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6875 print
'<input type="hidden" name="module" value="'.$module.
'">';
6877 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6878 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6879 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6882 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6884 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6891 if ($tab !=
'description') {
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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).
unActivateModule($value, $requiredby=1)
Disable a module.
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
getPictoForType($key, $morecss='')
Return the picto for a data type.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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
$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.