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"));
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 =
GETPOST(
'module',
'alpha');
71$tabobj =
GETPOST(
'tabobj',
'alpha');
72$tabdic =
GETPOST(
'tabdic',
'alpha');
73$propertykey =
GETPOST(
'propertykey',
'alpha');
75 $module =
'initmodule';
81 $tabobj =
'newobjectifnoobj';
84 $tabdic =
'newdicifnodic';
86$file =
GETPOST(
'file',
'alpha');
87$find =
GETPOST(
'find',
'alpha');
92$editorname =
GETPOST(
'editorname',
'alpha');
93$editorurl =
GETPOST(
'editorurl',
'alpha');
94$version =
GETPOST(
'version',
'alpha');
95$family =
GETPOST(
'family',
'alpha');
96$picto =
GETPOST(
'idpicto',
'alpha');
97$idmodule =
GETPOST(
'idmodule',
'alpha');
101if (!isModEnabled(
'modulebuilder')) {
104if (!$user->hasRight(
"modulebuilder",
"run")) {
109$tmp = explode(
',', $dolibarr_main_document_root_alt);
114$tmpdir = explode(
'@', $module);
115if (!empty($tmpdir[1])) {
116 $module = $tmpdir[0];
117 $dirread = $tmpdir[1];
120if (
GETPOST(
'dirins',
'alpha')) {
121 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
125$FILEFLAG =
'modulebuilder.txt';
132if (empty($newmask)) {
141$form =
new Form($db);
144$dirsrootforscan = array($dirread);
148 $dirsrootforscan[] = DOL_DOCUMENT_ROOT;
152$textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
153$listofmodules = array();
154'@phan-var-force array<string,array{modulenamewithcase:string,moduledescriptorrelpath:string,moduledescriptorfullpath:string,moduledescriptorrootpath,moduletype?:string}> $listofmodules';
156foreach ($dirsrootforscan as $tmpdirread) {
157 $moduletype =
'external';
158 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
159 $moduletype =
'internal';
162 $dirsincustom =
dol_dir_list($tmpdirread,
'directories');
163 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
164 foreach ($dirsincustom as $dircustomcursor) {
165 $fullname = $dircustomcursor[
'fullname'];
168 $dirtoscanrel = basename($fullname).
'/core/modules/';
170 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
171 if (empty($descriptorfiles)) {
172 $dirtoscanrel =
'core/modules/';
173 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.strtoupper(basename($fullname)).
'\.class\.php$');
175 $modulenamewithcase =
'';
176 $moduledescriptorrelpath =
'';
177 $moduledescriptorfullpath =
'';
179 foreach ($descriptorfiles as $descriptorcursor) {
180 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
181 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
182 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
183 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
186 if ($modulenamewithcase) {
187 $listofmodules[$dircustomcursor[
'name']] = array(
188 'modulenamewithcase' => $modulenamewithcase,
189 'moduledescriptorrelpath' => $moduledescriptorrelpath,
190 'moduledescriptorfullpath' => $moduledescriptorfullpath,
191 'moduledescriptorrootpath' => $tmpdirread,
192 'moduletype' => $moduletype
200 if ($forceddirread && empty($listofmodules)) {
201 $listofmodules[strtolower($module)] = array(
202 'modulenamewithcase' => $module,
203 'moduledescriptorrelpath' =>
'notyetimplemented',
204 'moduledescriptorfullpath' =>
'notyetimplemented',
205 'moduledescriptorrootpath' =>
'notyetimplemented',
210 $newdircustom = $dirins;
211 if (empty($newdircustom)) {
217 $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
219 $textforlistofdirs .=
', ';
221 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$tmpdirread.
'</strong>';
222 if ($tmpdirread == DOL_DOCUMENT_ROOT) {
224 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
227 $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
240 $error = error_get_last();
241 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
243 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
245 if (headers_sent()) {
250register_shutdown_function(
"moduleBuilderShutdownFunction");
262function getLicenceHeader($user, $langs, $now)
264 $licInfo = $user->getFullName($langs);
265 $emailTabs = str_repeat(
"\t", (
int) (max(0, (31 - mb_strlen($licInfo)) / 4)));
266 $licInfo .= ($user->email ? $emailTabs.
'<'.$user->email.
'>' :
'');
275if ($dirins && $action ==
'initmodule' && $modulename && $user->hasRight(
"modulebuilder",
"run")) {
276 $modulename = ucfirst($modulename);
277 $destdir =
'/not_set/';
279 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
281 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
285 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
286 $destdir = $dirins.
'/'.strtolower($modulename);
288 $arrayreplacement = array(
289 'mymodule' => strtolower($modulename),
290 'MyModule' => $modulename
292 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayreplacement);
297 $langs->load(
"errors");
298 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
301 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
307 $tryToCopyFromSetupClass =
true;
308 $backportDest = $destdir .
'/backport/v16/core/class';
309 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
310 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
315 $langs->load(
"errors");
316 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
317 $tryToCopyFromSetupClass =
false;
320 if ($tryToCopyFromSetupClass) {
321 $result =
dol_copy($backportFileSrc, $backportFileDest);
325 $langs->load(
"errors");
326 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
328 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
351 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
352 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
370 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
371 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
373 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
374 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
375 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
376 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
391 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
393 $licInfo = getLicenceHeader($user, $langs, $now);
394 foreach ($listofphpfilestoedit as $phpfileval) {
396 $arrayreplacement = array(
397 'mymodule' => strtolower($modulename),
398 'MyModule' => $modulename,
399 'MYMODULE' => strtoupper($modulename),
400 'My module' => $modulename,
401 'my module' => $modulename,
402 'Mon module' => $modulename,
403 'mon module' => $modulename,
404 'htdocs/modulebuilder/template' => strtolower($modulename),
405 '---Put here your own copyright and developer email---' => $licInfo,
406 '---Replace with your own copyright and developer email---' => $licInfo,
407 'Editor name' => $editorname,
408 'https://www.example.com' => $editorurl,
409 '$this->version = \'1.0\'' =>
'$this->version = \''.$version.
'\'',
410 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
411 "modulefamily" => $family,
412 '500000' => $idmodule
416 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
"\t\t" .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
423 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
428 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
430 file_put_contents($destdir.
'/README.md',
$conf->global->MODULEBUILDER_SPECIFIC_README);
441 $module = $modulename;
443 clearstatcache(
true);
444 if (function_exists(
'opcache_invalidate')) {
448 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
453$destdir =
'/not_set/';
454$destfile =
'/not_set/';
455$srcfile =
'/not_set/';
458if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
459 $modulename = ucfirst($module);
460 $objectname = $tabobj;
461 $varnametoupdate =
'';
462 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
463 $destdir = $dirins.
'/'.strtolower($module);
469 if ($action ==
'initapi') {
470 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
471 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php',
'0', 1);
473 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
474 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
475 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
476 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
477 } elseif ($action ==
'initphpunit') {
478 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
479 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
480 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
481 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
482 } elseif ($action ==
'initpagecontact') {
483 dol_mkdir($dirins.
'/'.strtolower($module));
484 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
485 $srcfile = $srcdir.
'/myobject_contact.php';
486 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
487 $varnametoupdate =
'showtabofpagecontact';
488 } elseif ($action ==
'initpagedocument') {
489 dol_mkdir($dirins.
'/'.strtolower($module));
490 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
491 $srcfile = $srcdir.
'/myobject_document.php';
492 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
493 $varnametoupdate =
'showtabofpagedocument';
494 } elseif ($action ==
'initpagenote') {
495 dol_mkdir($dirins.
'/'.strtolower($module));
496 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
497 $srcfile = $srcdir.
'/myobject_note.php';
498 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
499 $varnametoupdate =
'showtabofpagenote';
500 } elseif ($action ==
'initpageagenda') {
501 dol_mkdir($dirins.
'/'.strtolower($module));
502 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
503 $srcfile = $srcdir.
'/myobject_agenda.php';
504 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
505 $varnametoupdate =
'showtabofpageagenda';
508 if (!file_exists($destfile)) {
509 $result =
dol_copy($srcfile, $destfile,
'0', 0);
514 $arrayreplacement = array(
515 'mymodule' => strtolower($modulename),
516 'MyModule' => $modulename,
517 'MYMODULE' => strtoupper($modulename),
518 'My module' => $modulename,
519 'my module' => $modulename,
520 'Mon module' => $modulename,
521 'mon module' => $modulename,
522 'htdocs/modulebuilder/template' => strtolower($modulename),
523 'myobject' => strtolower($objectname),
524 'MyObject' => $objectname,
525 'MYOBJECT' => strtoupper($objectname),
527 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
530 if ($action ==
'initapi') {
531 if (count($objects) >= 1) {
539 if ($varnametoupdate) {
541 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
542 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
547 $langs->load(
"errors");
548 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
554if ($dirins && $action ==
'initsqlextrafields' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
555 $modulename = ucfirst($module);
556 $objectname = $tabobj;
558 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
559 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
560 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
561 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
562 $result1 =
dol_copy($srcfile1, $destfile1,
'0', 0);
563 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
564 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
565 $result2 =
dol_copy($srcfile2, $destfile2,
'0', 0);
567 if ($result1 > 0 && $result2 > 0) {
568 $modulename = ucfirst($module);
571 $arrayreplacement = array(
572 'mymodule' => strtolower($modulename),
573 'MyModule' => $modulename,
574 'MYMODULE' => strtoupper($modulename),
575 'My module' => $modulename,
576 'my module' => $modulename,
577 'Mon module' => $modulename,
578 'mon module' => $modulename,
579 'htdocs/modulebuilder/template' => strtolower($modulename),
580 'My Object' => $objectname,
581 'MyObject' => $objectname,
582 'my object' => strtolower($objectname),
583 'myobject' => strtolower($objectname),
584 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
590 $langs->load(
"errors");
592 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
595 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
600 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
601 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
607if ($dirins && $action ==
'inithook' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
608 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
609 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
610 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
611 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
612 $result =
dol_copy($srcfile, $destfile,
'0', 0);
615 $modulename = ucfirst($module);
618 $arrayreplacement = array(
619 'mymodule' => strtolower($modulename),
620 'MyModule' => $modulename,
621 'MYMODULE' => strtoupper($modulename),
622 'My module' => $modulename,
623 'my module' => $modulename,
624 'Mon module' => $modulename,
625 'mon module' => $modulename,
626 'htdocs/modulebuilder/template' => strtolower($modulename),
627 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
633 $langs->load(
"errors");
634 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
640if ($dirins && $action ==
'inittrigger' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
641 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
642 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
643 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
644 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
645 $result =
dol_copy($srcfile, $destfile,
'0', 0);
648 $modulename = ucfirst($module);
651 $arrayreplacement = array(
652 'mymodule' => strtolower($modulename),
653 'MyModule' => $modulename,
654 'MYMODULE' => strtoupper($modulename),
655 'My module' => $modulename,
656 'my module' => $modulename,
657 'Mon module' => $modulename,
658 'mon module' => $modulename,
659 'htdocs/modulebuilder/template' => strtolower($modulename),
660 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
666 $langs->load(
"errors");
667 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
673if ($dirins && $action ==
'initwidget' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
674 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
675 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
676 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
677 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
678 $result =
dol_copy($srcfile, $destfile,
'0', 0);
681 $modulename = ucfirst($module);
684 $arrayreplacement = array(
685 'mymodule' => strtolower($modulename),
686 'MyModule' => $modulename,
687 'MYMODULE' => strtoupper($modulename),
688 'My module' => $modulename,
689 'my module' => $modulename,
690 'Mon module' => $modulename,
691 'mon module' => $modulename,
692 'htdocs/modulebuilder/template' => strtolower($modulename),
693 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
699 $langs->load(
"errors");
700 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
706if ($dirins && $action ==
'initemailing' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
707 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
708 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
709 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
710 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
711 $result =
dol_copy($srcfile, $destfile,
'0', 0);
714 $modulename = ucfirst($module);
717 $arrayreplacement = array(
718 'mymodule' => strtolower($modulename),
719 'MyModule' => $modulename,
720 'MYMODULE' => strtoupper($modulename),
721 'My module' => $modulename,
722 'my module' => $modulename,
723 'Mon module' => $modulename,
724 'mon module' => $modulename,
725 'htdocs/modulebuilder/template' => strtolower($modulename),
726 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
732 $langs->load(
"errors");
733 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
739if ($dirins && $action ==
'initcss' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
740 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
741 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
742 $srcfile = $srcdir.
'/css/mymodule.css.php';
743 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
744 $result =
dol_copy($srcfile, $destfile,
'0', 0);
747 $modulename = ucfirst($module);
750 $arrayreplacement = array(
751 'mymodule' => strtolower($modulename),
752 'MyModule' => $modulename,
753 'MYMODULE' => strtoupper($modulename),
754 'My module' => $modulename,
755 'my module' => $modulename,
756 'Mon module' => $modulename,
757 'mon module' => $modulename,
758 'htdocs/modulebuilder/template' => strtolower($modulename),
759 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
766 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
767 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
770 $langs->load(
"errors");
771 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
777if ($dirins && $action ==
'initjs' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
778 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
779 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
780 $srcfile = $srcdir.
'/js/mymodule.js.php';
781 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
782 $result =
dol_copy($srcfile, $destfile,
'0', 0);
785 $modulename = ucfirst($module);
788 $arrayreplacement = array(
789 'mymodule' => strtolower($modulename),
790 'MyModule' => $modulename,
791 'MYMODULE' => strtoupper($modulename),
792 'My module' => $modulename,
793 'my module' => $modulename,
794 'Mon module' => $modulename,
795 'mon module' => $modulename,
796 'htdocs/modulebuilder/template' => strtolower($modulename),
797 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
804 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
805 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
808 $langs->load(
"errors");
809 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
815if ($dirins && $action ==
'initcli' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
816 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
817 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
818 $srcfile = $srcdir.
'/scripts/mymodule.php';
819 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
820 $result =
dol_copy($srcfile, $destfile,
'0', 0);
823 $modulename = ucfirst($module);
826 $arrayreplacement = array(
827 'mymodule' => strtolower($modulename),
828 'MyModule' => $modulename,
829 'MYMODULE' => strtoupper($modulename),
830 'My module' => $modulename,
831 'my module' => $modulename,
832 'Mon module' => $modulename,
833 'mon module' => $modulename,
834 'htdocs/modulebuilder/template' => strtolower($modulename),
835 '__MYCOMPANY_NAME__' => $mysoc->name,
836 '__KEYWORDS__' => $modulename,
837 '__USER_FULLNAME__' => $user->getFullName($langs),
838 '__USER_EMAIL__' => $user->email,
840 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
846 $langs->load(
"errors");
847 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
852$moduledescriptorfile =
'/not_set/';
855if ($dirins && $action ==
'initdoc' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
856 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
857 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
858 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
859 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
860 $result =
dol_copy($srcfile, $destfile,
'0', 0);
863 $modulename = ucfirst($module);
864 $modulelowercase = strtolower($module);
867 $arrayreplacement = array(
868 'mymodule' => strtolower($modulename),
869 'MyModule' => $modulename,
870 'MYMODULE' => strtoupper($modulename),
871 'My module' => $modulename,
872 'my module' => $modulename,
873 'Mon module' => $modulename,
874 'mon module' => $modulename,
875 'htdocs/modulebuilder/template' => strtolower($modulename),
876 '__MYCOMPANY_NAME__' => $mysoc->name,
877 '__KEYWORDS__' => $modulename,
878 '__USER_FULLNAME__' => $user->getFullName($langs),
879 '__USER_EMAIL__' => $user->email,
881 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
888 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
889 $destdir = $dirins.
'/'.strtolower($module);
891 foreach ($objects as $path => $obj) {
896 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
900 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
901 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
906 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
907 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
908 $string = file_get_contents($changeLog);
910 $replace = explode(
"\n", $string);
911 $strreplace = array();
912 foreach ($replace as $line) {
916 if (strpos($line,
'##') !==
false) {
917 $strreplace[$line] = str_replace(
'##',
'', $line);
919 $strreplace[$line] = $line;
922 $stringLog = implode(
"\n", $strreplace);
924 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
928 $FILENAMEDOC = $modulelowercase.
'.html';
929 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
930 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
931 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
932 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
933 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
938 $langs->load(
"errors");
939 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
945if ($dirins && $action ==
'addlanguage' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
946 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
949 $modulelowercase = strtolower($module);
954 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
956 $diroflang = $dolibarr_main_document_root;
958 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
959 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
961 $result =
dol_copy($srcfile, $destfile,
'0', 0);
963 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
966 $srcdir = $diroflang.
'/langs/en_US';
967 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
968 $destdir = $diroflang.
'/langs/'.$newlangcode;
970 $arrayofreplacement = array();
972 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
973 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
975 $result =
dolCopyDir($srcdir, $destdir,
'0', 0, $arrayofreplacement);
978 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
984if ($dirins && $action ==
'confirm_removefile' && !empty($module) && $user->hasRight(
"modulebuilder",
"run")) {
985 $objectname = $tabobj;
986 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
987 $destdir = $dirins.
'/'.strtolower($module);
992 if ($relativefilename) {
993 $dirnametodelete = dirname($relativefilename);
994 $filetodelete = $dirins.
'/'.$relativefilename;
995 $dirtodelete = $dirins.
'/'.$dirnametodelete;
1000 $keyofobjecttodelete = array_search($objectname, $objects);
1001 if ($keyofobjecttodelete !==
false) {
1002 unset($objects[$keyofobjecttodelete]);
1006 if (strpos($relativefilename,
'api') !==
false) {
1007 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
1011 if (count($objects) == 0) {
1023 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1026 if (preg_match(
'/\.sql$/', $relativefilename)) {
1027 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1028 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1029 $filetodelete = $dirins.
'/'.$relativefilename;
1031 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1032 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1033 $filetodelete = $dirins.
'/'.$relativefilename;
1043 if (in_array($tab, array(
'css',
'js'))) {
1044 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1045 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1049 if (preg_match(
'/_extrafields/', $relativefilename)) {
1051 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1052 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1057 $varnametoupdate =
'';
1059 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1060 $varnametoupdate =
'showtabofpage'.$reg[1];
1062 if ($varnametoupdate) {
1063 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1064 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1072if ($dirins && $action ==
'initobject' && $module && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
1075 $objectname = ucfirst($objectname);
1077 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1078 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1080 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1082 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1083 $tabobj =
'newobject';
1085 if (class_exists($objectname)) {
1088 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1089 $tabobj =
'newobject';
1092 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1093 $destdir = $dirins.
'/'.strtolower($module);
1105 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1106 $alreadyfound =
false;
1107 foreach ($dirlist as $key => $val) {
1108 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1109 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1110 $alreadyfound =
true;
1112 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1120 $stringforproperties =
'';
1121 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1123 $_results = $db->DDLDescTable($tablename);
1124 if (empty($_results)) {
1126 $langs->load(
"errors");
1127 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1176 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1177 $stringforproperties .=
'public $fields = array('.
"\n";
1179 while ($obj = $db->fetch_object($_results)) {
1181 $fieldname = $obj->Field;
1184 if ($type ==
'int(11)') {
1187 if ($type ==
'float') {
1190 if (strstr($type,
'tinyint')) {
1193 if ($obj->Field ==
'fk_soc') {
1194 $type =
'integer:Societe:societe/class/societe.class.php';
1196 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1197 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1199 if (preg_match(
'/^fk_prod/', $obj->Field)) {
1200 $type =
'integer:Product:product/class/product.class.php:1';
1202 if ($obj->Field ==
'fk_warehouse') {
1203 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1205 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1206 $type =
'integer:User:user/class/user.class.php';
1210 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1211 if ($fieldname ==
'fk_user_modif') {
1215 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1216 if ($fieldname ==
'rowid') {
1217 $label =
'TechnicalID';
1219 if ($fieldname ==
'import_key') {
1220 $label =
'ImportId';
1222 if ($fieldname ==
'fk_soc') {
1223 $label =
'ThirdParty';
1225 if ($fieldname ==
'tms') {
1226 $label =
'DateModification';
1228 if ($fieldname ==
'datec') {
1229 $label =
'DateCreation';
1231 if ($fieldname ==
'date_valid') {
1232 $label =
'DateValidation';
1234 if ($fieldname ==
'datev') {
1235 $label =
'DateValidation';
1237 if ($fieldname ==
'note_private') {
1238 $label =
'NotePublic';
1240 if ($fieldname ==
'note_public') {
1241 $label =
'NotePrivate';
1243 if ($fieldname ==
'fk_user_creat') {
1244 $label =
'UserAuthor';
1246 if ($fieldname ==
'fk_user_modif') {
1247 $label =
'UserModif';
1249 if ($fieldname ==
'fk_user_valid') {
1250 $label =
'UserValidation';
1254 if (in_array($fieldname, array(
'ref',
'label'))) {
1257 if ($fieldname ==
'entity') {
1260 if ($fieldname ==
'entity') {
1263 if ($fieldname ==
'import_key') {
1266 if ($fieldname ==
'fk_user_creat') {
1269 if ($fieldname ==
'fk_user_modif') {
1272 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1279 if ($fieldname ==
'entity') {
1284 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1287 if ($fieldname ==
'import_key') {
1292 if ($fieldname ==
'label') {
1293 $alwayseditable = 1;
1295 $alwayseditable = 0;
1299 if ($fieldname ==
'entity') {
1306 if (preg_match(
'/^fk_/', $fieldname)) {
1307 $css =
'maxwidth500 widthcentpercentminusxx';
1309 if ($fieldname ==
'label') {
1310 $css =
'minwidth300';
1311 $cssview =
'wordbreak';
1313 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1314 $cssview =
'wordbreak';
1316 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1317 $csslist =
'tdoverflowmax150';
1322 if (isset($obj->Picto)) {
1323 $picto = $obj->Picto;
1325 if ($obj->Field ==
'fk_soc') {
1328 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1333 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1334 if ($default !=
'') {
1335 $stringforproperties .=
" 'default' => ".$default.
",";
1337 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1338 $stringforproperties .=
" 'visible' => ".$visible;
1340 $stringforproperties .=
", 'notnull' => ".$notnull;
1342 if ($alwayseditable) {
1343 $stringforproperties .=
", 'alwayseditable' => 1";
1345 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1346 $stringforproperties .=
", 'showoncombobox' => 1";
1348 $stringforproperties .=
", 'position' => ".$position;
1350 $stringforproperties .=
", 'index' => ".$index;
1353 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1356 $stringforproperties .=
", 'css' => '".$css.
"'";
1359 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1362 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1364 $stringforproperties .=
"),\n";
1367 $stringforproperties .=
');'.
"\n";
1368 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1372 $filetogenerate = array();
1375 $filetogenerate = array(
1376 'myobject_card.php' => strtolower($objectname).
'_card.php',
1377 'myobject_note.php' => strtolower($objectname).
'_note.php',
1378 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1379 'myobject_document.php' => strtolower($objectname).
'_document.php',
1380 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1381 'myobject_list.php' => strtolower($objectname).
'_list.php',
1382 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1383 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1385 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1386 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1387 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1388 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1390 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1392 'ajax/myobject.php' =>
'ajax/'.strtolower($objectname).
'.php',
1395 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1396 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1398 $filetogenerate += array(
1399 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1400 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1401 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1404 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1405 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1406 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1408 $filetogenerate += array(
1409 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1410 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1413 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1414 $firstobjectname =
'myobject';
1415 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1417 $class =
'mod'.$module;
1419 if (class_exists($class)) {
1422 '@phan-var-force DolibarrModules $moduleobj';
1434 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1436 if ($checkComment < 0) {
1437 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1439 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1440 if ($generatePerms < 0) {
1441 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1447 foreach ($filetogenerate as $srcfile => $destfile) {
1448 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1452 $langs->load(
"errors");
1453 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1456 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1459 $arrayreplacement = array(
1460 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1461 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1464 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1469 if (!$error && $stringforproperties) {
1471 $arrayreplacement = array(
1472 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1475 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1479 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1481 $arrayreplacement = array(
1482 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1486 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1488 $arrayreplacement = array(
1489 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1491 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1495 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1497 $arrayreplacement = array(
1498 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1500 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1501 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'',
'0', 0, 1);
1503 $arrayreplacement = array(
1504 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1507 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1514 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1516 $firstobjectname =
'';
1518 foreach ($listofobject as $fileobj) {
1519 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1522 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1526 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1528 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1529 $objectnameloop = $reg[1];
1530 if (empty($firstobjectname)) {
1531 $firstobjectname = $objectnameloop;
1537 \$this->menu[\$r++] = array(
1538 'fk_menu' => 'fk_mainmenu=mymodule',
1540 'titre' => 'MyObject',
1541 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1542 'mainmenu' => 'mymodule',
1543 'leftmenu' => 'myobject',
1544 'url' => '/mymodule/myobject_list.php',
1545 'langs' => 'mymodule@mymodule',
1546 'position' => 1000 + \$r,
1547 'enabled' => 'isModEnabled(\"mymodule\")',
1548 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1551 'object' => 'MyObject'
1553 \$this->menu[\$r++] = array(
1554 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1556 'titre' => 'List MyObject',
1557 'mainmenu' => 'mymodule',
1558 'leftmenu' => 'mymodule_myobject_list',
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' => 'New MyObject',
1572 'mainmenu' => 'mymodule',
1573 'leftmenu' => 'mymodule_myobject_new',
1574 'url' => '/mymodule/myobject_card.php?action=create',
1575 'langs' => 'mymodule@mymodule',
1576 'position' => 1000 + \$r,
1577 'enabled' => 'isModEnabled(\"mymodule\")',
1578 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1581 'object' => 'MyObject'
1583 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1584 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1585 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1587 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1593 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1595 $class =
'mod'.$module;
1597 if (class_exists($class)) {
1600 '@phan-var-force DolibarrModules $moduleobj';
1613 foreach ($menus as $menu) {
1614 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1620 if ($checkComment < 0) {
1622 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1624 $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 */');
1629 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1634 foreach ($filetogenerate as $destfile) {
1635 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1638 $arrayreplacement = array(
1639 'mymodule' => strtolower($module),
1640 'MyModule' => $module,
1641 'MYMODULE' => strtoupper($module),
1642 'My module' => $module,
1643 'my module' => $module,
1644 'mon module' => $module,
1645 'Mon module' => $module,
1646 'htdocs/modulebuilder/template/' => strtolower($modulename),
1647 'myobject' => strtolower($objectname),
1648 'MyObject' => $objectname,
1650 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
1654 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1660 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1669 if (is_numeric($object) && $object <= 0) {
1670 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1671 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1675 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1676 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1678 if (file_exists($destfile)) {
1684 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1693 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1694 $tabobj = $objectname;
1696 $tabobj =
'newobject';
1700 if (isModEnabled(strtolower($module))) {
1706 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1707 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1713if ($dirins && $action ==
'initdic' && $module && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
1714 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1715 $destdir = $dirins.
'/'.strtolower($module);
1716 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1720 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1724 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1727 $newdicname = $dicname;
1728 if (!preg_match(
'/^c_/', $newdicname)) {
1729 $newdicname =
'c_'.$dicname;
1732 $class =
'mod'.$module;
1734 if (class_exists($class)) {
1737 '@phan-var-force DolibarrModules $moduleobj';
1745 $langs->load(
"errors");
1746 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1751 if ($checkComment < 0) {
1752 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1755 if (function_exists(
'opcache_invalidate')) {
1758 clearstatcache(
true);
1759 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1766if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj) && $user->hasRight(
"modulebuilder",
"run")) {
1767 $objectname = $tabobj;
1769 $arrayoftables = array();
1770 if ($action ==
'droptable') {
1771 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1773 if ($action ==
'droptableextrafields') {
1774 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1777 foreach ($arrayoftables as $tabletodrop) {
1779 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1780 $resql = $db->query($sql);
1782 $obj = $db->fetch_object($resql);
1787 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1788 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1794 $resql = $db->DDLDropTable($tabletodrop);
1796 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1797 } elseif ($nb > 0) {
1798 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1803if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) && $user->hasRight(
"modulebuilder",
"run")) {
1808 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1809 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1811 $srcdir = $dirread.
'/'.strtolower($module);
1812 $destdir = $dirins.
'/'.strtolower($module);
1816 if (!in_array($objectname, array_values($objects))) {
1818 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1821 $addfieldentry = array();
1824 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1825 if (!
GETPOST(
'propname',
'aZ09')) {
1827 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1829 if (!
GETPOST(
'proplabel',
'alpha')) {
1831 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1833 if (!
GETPOST(
'proptype',
'alpha')) {
1835 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1839 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1840 $addfieldentry = array(
1841 'name' =>
GETPOST(
'propname',
'aZ09'),
1842 'label' =>
GETPOST(
'proplabel',
'alpha'),
1843 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1844 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'nohtml'),
1845 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1846 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1850 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1852 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1853 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1854 'help' =>
GETPOST(
'prophelp',
'alpha'),
1855 'css' =>
GETPOST(
'propcss',
'alpha'),
1856 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1857 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1858 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1859 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
1864 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1865 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1867 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1870 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1882 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1888 if (is_numeric($object) && $object <= 0) {
1889 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1890 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1897 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1900 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1906 clearstatcache(
true);
1908 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1913 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1918if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey && $user->hasRight(
"modulebuilder",
"run")) {
1919 $objectname = $tabobj;
1921 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1922 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1924 $srcdir = $dirread.
'/'.strtolower($module);
1925 $destdir = $dirins.
'/'.strtolower($module);
1932 if (is_numeric($object) && $object <= 0) {
1933 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1934 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1941 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1944 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1950 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1952 clearstatcache(
true);
1955 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1960if ($dirins && $action ==
'confirm_deletemodule' && $user->hasRight(
"modulebuilder",
"run")) {
1961 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1963 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1967 $modulelowercase = strtolower($module);
1970 $dir = $dirins.
'/'.$modulelowercase;
1972 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1982 $class =
'mod'.$module;
1986 if (class_exists($class)) {
1989 '@phan-var-force DolibarrModules $moduleobj';
1997 $langs->load(
"errors");
1998 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
2010 clearstatcache(
true);
2011 if (function_exists(
'opcache_invalidate')) {
2015 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2023 $module =
'deletemodule';
2026if ($dirins && $action ==
'confirm_deleteobject' && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
2027 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2029 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2033 $modulelowercase = strtolower($module);
2034 $objectlowercase = strtolower($objectname);
2037 $dir = $dirins.
'/'.$modulelowercase;
2040 $filetodelete = array(
2041 'myobject_card.php' => strtolower($objectname).
'_card.php',
2042 'myobject_note.php' => strtolower($objectname).
'_note.php',
2043 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
2044 'myobject_document.php' => strtolower($objectname).
'_document.php',
2045 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
2046 'myobject_list.php' => strtolower($objectname).
'_list.php',
2047 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
2048 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
2049 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
2050 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
2051 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
2052 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
2053 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
2054 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
2055 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
2056 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2057 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2058 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2059 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2060 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2061 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2066 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2068 $class =
'mod'.$module;
2070 if (class_exists($class)) {
2073 '@phan-var-force DolibarrModules $moduleobj';
2081 $langs->load(
"errors");
2082 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2085 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2091 if ($rewriteMenu < 0) {
2092 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2094 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2100 if ($rewritePerms < 0) {
2101 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2105 if ($rewritePerms && $rewriteMenu) {
2107 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2110 clearstatcache(
true);
2111 if (function_exists(
'opcache_invalidate')) {
2115 foreach ($filetodelete as $tmpfiletodelete) {
2117 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2123 if ($resultko == 0) {
2126 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2133 $tabobj =
'newobject';
2135 $tabobj =
'deleteobject';
2139 if (isModEnabled(strtolower($module))) {
2145 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2146 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2151if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) && $user->hasRight(
"modulebuilder",
"run")) {
2152 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2153 $destdir = $dirins.
'/'.strtolower($module);
2154 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2156 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2158 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2161 if (!empty($dicname)) {
2162 $newdicname = $dicname;
2163 if (!preg_match(
'/^c_/', $newdicname)) {
2164 $newdicname =
'c_'.strtolower($dicname);
2171 $class =
'mod'.$module;
2173 if (class_exists($class)) {
2176 '@phan-var-force DolibarrModules $moduleobj';
2184 $langs->load(
"errors");
2185 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2191 if ($checkComment < 0) {
2193 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2196 if (!empty(
GETPOST(
'dictionnarykey'))) {
2197 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2201 $checkTable =
false;
2202 if ($newdicname !==
null) {
2203 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2206 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2211 $keyToDelete =
null;
2212 foreach ($dicts[
'tabname'] as $key => $table) {
2214 if (strtolower($table) === $newdicname) {
2215 $keyToDelete = $key;
2220 if ($keyToDelete !==
null) {
2221 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2222 foreach ($keysToDelete as $key) {
2223 unset($dicts[$key][$keyToDelete]);
2227 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2229 if (!$error && $newdicname !==
null) {
2231 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2232 if ($_results < 0) {
2234 $langs->load(
"errors");
2235 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2240 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2242 if (function_exists(
'opcache_invalidate')) {
2245 clearstatcache(
true);
2246 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2250if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') && $user->hasRight(
"modulebuilder",
"run")) {
2251 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2253 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2254 $destdir = $dirins.
'/'.strtolower($module);
2255 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2257 $class =
'mod'.$module;
2259 if (class_exists($class)) {
2262 '@phan-var-force DolibarrModules $moduleobj';
2270 $langs->load(
"errors");
2271 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2276 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2277 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2279 if ($checkComment < 0) {
2280 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2283 if ($updateDict > 0) {
2286 if (function_exists(
'opcache_invalidate')) {
2289 clearstatcache(
true);
2290 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2296if ($dirins && $action ==
'generatedoc' && $user->hasRight(
"modulebuilder",
"run")) {
2297 $modulelowercase = strtolower($module);
2302 $FILENAMEDOC = strtolower($module).
'.html';
2304 $util =
new Utils($db);
2305 $result = $util->generateDoc($module);
2308 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2314if ($dirins && $action ==
'generatepackage' && $user->hasRight(
"modulebuilder",
"run")) {
2315 $modulelowercase = strtolower($module);
2317 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2327 $class =
'mod'.$module;
2329 if (class_exists($class)) {
2332 '@phan-var-force DolibarrModules $moduleobj';
2340 $langs->load(
"errors");
2341 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2345 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2346 if (count($arrayversion)) {
2347 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2350 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2356 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2362 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2365 $langs->load(
"errors");
2366 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2370 $langs->load(
"errors");
2371 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2376if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2380 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2382 $class =
'mod'.$module;
2384 if (class_exists($class)) {
2387 '@phan-var-force DolibarrModules $moduleobj';
2396 if (!
GETPOST(
'label',
'alpha')) {
2398 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2400 if (!
GETPOST(
'permissionObj',
'alpha')) {
2402 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2406 $label =
GETPOST(
'label',
'alpha');
2407 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2408 $crud =
GETPOST(
'crud',
'alpha');
2412 $permsForObject = array();
2416 $permissions = array();
2418 $allObject = array();
2420 $countPerms = count($permissions);
2422 for ($i = 0; $i < $countPerms; $i++) {
2423 if ($permissions[$i][4] == $objectForPerms) {
2425 if (count($permsForObject) < 3) {
2426 $permsForObject[] = $permissions[$i];
2429 $allObject[] = $permissions[$i][4];
2433 $countPermsObj = count($permsForObject);
2434 for ($j = 0; $j < $countPermsObj; $j++) {
2435 if (in_array($crud, $permsForObject[$j])) {
2437 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2441 $rightToAdd = array();
2443 $key = $countPerms + 1;
2445 $rightToAdd = array(
2448 4 => $objectForPerms,
2452 if (isModEnabled(strtolower($module))) {
2458 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2461 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2465 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2470 clearstatcache(
true);
2471 if (function_exists(
'opcache_invalidate')) {
2474 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2481if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2484 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2486 $class =
'mod'.$module;
2488 if (class_exists($class)) {
2491 '@phan-var-force DolibarrModules $moduleobj';
2499 if (!
GETPOST(
'label',
'alpha')) {
2501 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2503 if (!
GETPOST(
'permissionObj',
'alpha')) {
2505 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2508 $label =
GETPOST(
'label',
'alpha');
2509 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2510 $crud =
GETPOST(
'crud',
'alpha');
2513 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2517 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2521 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2533 if (array_key_exists($key, $permissions)) {
2534 $x1 = $permissions[$key][1];
2535 $x2 = $permissions[$key][4];
2536 $x3 = $permissions[$key][5];
2544 $permsForObject = array();
2548 $allObject = array();
2550 $countPerms = count($permissions);
2551 for ($i = 0; $i < $countPerms; $i++) {
2552 if ($permissions[$i][4] == $objectForPerms) {
2554 if (count($permsForObject) < 3) {
2555 $permsForObject[] = $permissions[$i];
2558 $allObject[] = $permissions[$i][4];
2561 if ($label != $x1 && $crud != $x3) {
2562 $countPermsObj = count($permsForObject);
2563 for ($j = 0; $j < $countPermsObj; $j++) {
2564 if (in_array($label, $permsForObject[$j])) {
2566 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2572 if (isModEnabled(strtolower($module))) {
2578 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2581 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2585 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2587 $rightUpdated =
null;
2590 clearstatcache(
true);
2591 if (function_exists(
'opcache_invalidate')) {
2594 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2600if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey') && $user->hasRight(
"modulebuilder",
"run")) {
2603 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2605 $class =
'mod'.$module;
2607 if (class_exists($class)) {
2610 '@phan-var-force DolibarrModules $moduleobj';
2623 if (isModEnabled(strtolower($module))) {
2629 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2630 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2635 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2638 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2643 clearstatcache(
true);
2644 if (function_exists(
'opcache_invalidate')) {
2648 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2654if ($action ==
'savefile' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2655 $relofcustom = basename($dirins);
2659 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2660 $file = $relofcustom.
'/'.$file;
2668 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2671 $check =
'restricthtml';
2673 if ($srclang ==
'md') {
2674 $check =
'restricthtml';
2676 if ($srclang ==
'lang') {
2677 $check =
'restricthtml';
2679 if ($srclang ==
'php') {
2683 $content =
GETPOST(
'editfilecontent', $check);
2688 $result = file_put_contents($pathoffile, $content);
2705if ($action ==
'set' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2708 $param .=
'&module='.urlencode($module);
2711 $param .=
'&tab='.urlencode($tab);
2714 $param .=
'&tabobj='.urlencode($tabobj);
2717 $value =
GETPOST(
'value',
'alpha');
2719 if (!empty($resarray[
'errors'])) {
2723 if ($resarray[
'nbperms'] > 0) {
2724 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2725 $resqltmp = $db->query($tmpsql);
2727 $obj = $db->fetch_object($resqltmp);
2729 if ($obj && $obj->nb > 1) {
2730 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2738 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2743if ($action ==
'reset' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2746 $param .=
'&module='.urlencode($module);
2749 $param .=
'&tab='.urlencode($tab);
2752 $param .=
'&tabobj='.urlencode($tabobj);
2755 $value =
GETPOST(
'value',
'alpha');
2760 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2765if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') && $user->hasRight(
"modulebuilder",
"run")) {
2767 if (isModEnabled(strtolower($module))) {
2773 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2774 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2778 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2780 $class =
'mod'.$module;
2782 if (class_exists($class)) {
2785 '@phan-var-force DolibarrModules $moduleobj';
2793 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2794 $destdir = $dir.
'/'.strtolower($module);
2796 $result = array_map(
'strtolower', $objects);
2800 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2803 if ($checkcomment < 0) {
2804 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2806 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2807 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2808 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2816 clearstatcache(
true);
2817 if (function_exists(
'opcache_invalidate')) {
2822 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2828if ($dirins && $action ==
'addmenu' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2830 if (isModEnabled(strtolower($module))) {
2836 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2837 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2843 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2845 $class =
'mod'.$module;
2847 if (class_exists($class)) {
2850 '@phan-var-force DolibarrModules $moduleobj';
2861 if (!
GETPOST(
'type',
'alpha')) {
2863 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2865 if (!
GETPOST(
'titre',
'alpha')) {
2867 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2869 if (!
GETPOST(
'user',
'alpha')) {
2871 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2873 if (!
GETPOST(
'url',
'alpha')) {
2875 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2877 if (!empty(
GETPOST(
'target'))) {
2878 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2879 if (!in_array(
GETPOST(
'target'), $targets)) {
2881 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2888 foreach ($menus as $menu) {
2891 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2894 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2896 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2901 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2902 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2904 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2907 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2908 $destdir = $dirins.
'/'.strtolower($module);
2911 if (
GETPOST(
'type',
'alpha') ==
'left') {
2912 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2914 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2917 if (
GETPOST(
'type',
'alpha') ==
'top') {
2919 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2922 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2926 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2927 'type' =>
GETPOST(
'type',
'alpha'),
2928 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2930 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2931 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2932 'url' =>
GETPOST(
'url',
'alpha'),
2933 'langs' => strtolower($module).
"@".strtolower($module),
2935 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2936 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2937 'target' =>
GETPOST(
'target',
'alpha'),
2941 if (
GETPOST(
'type') ==
'left') {
2942 unset($menuToAdd[
'prefix']);
2943 if (empty(
GETPOST(
'fk_menu'))) {
2944 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2946 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2949 if (
GETPOST(
'enabled') ==
'1') {
2950 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2952 $menuToAdd[
'enabled'] =
"0";
2954 if (empty(
GETPOST(
'objects'))) {
2955 $menuToAdd[
'perms'] =
'1';
2959 if ($checkcomment < 0) {
2960 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2963 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2965 clearstatcache(
true);
2966 if (function_exists(
'opcache_invalidate')) {
2975 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2983if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') && $user->hasRight(
"modulebuilder",
"run")) {
2984 $objectname =
GETPOST(
'tabobj');
2985 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2986 $destdir = $dirins.
'/'.strtolower($module);
2989 if (empty($cancel)) {
2990 if (isModEnabled(strtolower($module))) {
2996 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2997 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3002 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3004 $class =
'mod'.$module;
3006 if (class_exists($class)) {
3009 '@phan-var-force DolibarrModules $moduleobj';
3019 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3021 $menuModify = array(
3022 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3023 'type' =>
GETPOST(
'type',
'alpha'),
3024 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
3026 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3027 'leftmenu' => $menus[$key][
'leftmenu'],
3028 'url' =>
GETPOST(
'url',
'alpha'),
3029 'langs' => strtolower($module).
"@".strtolower($module),
3031 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3032 'perms' =>
GETPOST(
'perms',
'alpha'),
3033 'target' =>
GETPOST(
'target',
'alpha'),
3036 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3037 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3038 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3039 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3041 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3043 if ($menuModify[
'enabled'] ===
'') {
3044 $menuModify[
'enabled'] =
'1';
3046 if ($menuModify[
'perms'] ===
'') {
3047 $menuModify[
'perms'] =
'1';
3050 if (
GETPOST(
'type',
'alpha') ==
'top') {
3052 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3059 if ($checkComment < 0) {
3060 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3063 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3065 clearstatcache(
true);
3066 if (function_exists(
'opcache_invalidate')) {
3073 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));
3078 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3083 $_POST[
'type'] =
'';
3084 $_POST[
'titre'] =
'';
3085 $_POST[
'fk_menu'] =
'';
3086 $_POST[
'leftmenu'] =
'';
3092if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
3093 if (isModEnabled(strtolower($module))) {
3099 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3100 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3103 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3104 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3105 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
3109 $class =
'mod'.$module;
3111 if (class_exists($class)) {
3114 '@phan-var-force DolibarrModules $moduleobj';
3122 $keydescription =
GETPOST(
'keydescription',
'alpha');
3123 switch ($keydescription) {
3125 $propertyToUpdate =
'description';
3132 $propertyToUpdate = $keydescription;
3135 $error =
GETPOST(
'keydescription');
3139 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3140 $newValue =
GETPOST(
'propsmodule');
3141 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3142 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3145 if ($propertyToUpdate ===
'version') {
3149 $fileLines = file($moduledescriptorfile);
3150 foreach ($fileLines as &$line) {
3151 if (strpos($line, $lineToReplace) === 0) {
3157 clearstatcache(
true);
3158 if (function_exists(
'opcache_invalidate')) {
3161 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3162 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3172$form =
new Form($db);
3183 '/includes/ace/src/ace.js',
3184 '/includes/ace/src/ext-statusbar.js',
3185 '/includes/ace/src/ext-language_tools.js',
3190llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3193$text = $langs->trans(
"ModuleBuilder");
3197print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
3198print
'<br class="hideonsmartphone">';
3207 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3212 $langs->load(
"errors");
3213 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3217 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3226$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3230$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3231$allowonlineinstall =
true;
3232if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3233 $allowonlineinstall =
false;
3235if (empty($allowonlineinstall)) {
3238 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3241 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3256if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3257 $modulelowercase = strtolower($module);
3258 $loadclasserrormessage =
'';
3262 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3267 $class =
'mod'.$module;
3268 }
catch (Throwable $e) {
3269 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3270 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3271 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3275 if (class_exists($class)) {
3278 '@phan-var-force DolibarrModules $moduleobj';
3282 print $e->getMessage();
3285 if (empty($forceddirread)) {
3288 $langs->load(
"errors");
3289 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3290 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3291 print $loadclasserrormessage;
3302$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3303$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3304$head[$h][2] =
'initmodule';
3307$linktoenabledisable =
'';
3309if (is_array($listofmodules) && count($listofmodules) > 0) {
3311 $modulelowercase = strtolower($module);
3315 $param .=
'&tab='.urlencode($tab);
3318 $param .=
'&module='.urlencode($module);
3321 $param .=
'&tabobj='.urlencode($tabobj);
3324 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3327 if (isModEnabled($modulelowercase)) {
3328 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3329 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'', 0, 0, 0,
'',
'', 1);
3330 $linktoenabledisable .=
'</a>';
3332 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3335 $backtourlparam =
'';
3336 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3338 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3340 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3343 if (is_array($objMod->config_page_url)) {
3345 foreach ($objMod->config_page_url as $page) {
3348 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3351 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3352 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3353 $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>';
3357 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3358 $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>';
3362 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3363 $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>';
3367 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3368 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip', 1);
3369 $linktoenabledisable .=
"</a>\n";
3374 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3375 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3376 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3377 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3379 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3380 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3387$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3388$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3389$head[$h][2] =
'deletemodule';
3395if ($module ==
'initmodule') {
3397 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3398 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3399 print
'<input type="hidden" name="action" value="initmodule">';
3400 print
'<input type="hidden" name="module" value="initmodule">';
3405 print
'<div class="tagtable">';
3407 print
'<div class="tagtr"><div class="tagtd paddingright">';
3408 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3409 print
'</div><div class="tagtd">';
3410 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
3411 print
'<span class="opacitymedium">';
3413 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3415 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3418 print
'</div></div>';
3420 print
'<div class="tagtr"><div class="tagtd paddingright">';
3421 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3422 print
'</div><div class="tagtd">';
3423 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3424 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3425 print
'</div></div>';
3427 print
'<div class="tagtr"><div class="tagtd paddingright">';
3428 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3429 print
'</div><div class="tagtd">';
3430 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3431 print
'</div></div>';
3433 print
'<div class="tagtr"><div class="tagtd paddingright">';
3434 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3435 print
'</div><div class="tagtd">';
3436 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")).
'">';
3437 print
'</div></div>';
3439 print
'<div class="tagtr"><div class="tagtd paddingright">';
3440 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3441 print
'</div><div class="tagtd">';
3442 print
'<select name="family" id="family" class="minwidth400">';
3443 $arrayoffamilies = array(
3444 'hr' =>
"ModuleFamilyHr",
3445 'crm' =>
"ModuleFamilyCrm",
3446 'srm' =>
"ModuleFamilySrm",
3447 'financial' =>
'ModuleFamilyFinancial',
3448 'products' =>
'ModuleFamilyProducts',
3449 'projects' =>
'ModuleFamilyProjects',
3450 'ecm' =>
'ModuleFamilyECM',
3451 'technic' =>
'ModuleFamilyTechnic',
3452 'portal' =>
'ModuleFamilyPortal',
3453 'interface' =>
'ModuleFamilyInterface',
3454 'base' =>
'ModuleFamilyBase',
3455 'other' =>
'ModuleFamilyOther'
3457 foreach ($arrayoffamilies as $key => $value) {
3458 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>';
3462 print
'</div></div>';
3464 print
'<div class="tagtr"><div class="tagtd paddingright">';
3465 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3466 print
'</div><div class="tagtd">';
3467 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3468 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3469 print
'</div></div>';
3471 print
'<div class="tagtr"><div class="tagtd paddingright">';
3472 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3473 print
'</div><div class="tagtd">';
3474 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>';
3475 print
'</div></div>';
3477 print
'<div class="tagtr"><div class="tagtd paddingright">';
3478 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3479 print
'</div><div class="tagtd">';
3480 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>';
3481 print
'</div></div>';
3483 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3485} elseif ($module ==
'deletemodule') {
3486 print
'<!-- Form to init a module -->'.
"\n";
3487 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3488 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3489 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3490 print
'<input type="hidden" name="module" value="deletemodule">';
3492 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3494 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3495 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3497} elseif (!empty($module) && isset($modulelowercase)) {
3500 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3501 $destdir = $dirread.
'/'.strtolower($module);
3505 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3519 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3520 $head2[$h][1] = $langs->trans(
"Description");
3521 $head2[$h][2] =
'description';
3524 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3525 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3526 $head2[$h][2] =
'objects';
3529 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3530 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3531 $head2[$h][2] =
'languages';
3534 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3535 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3536 $head2[$h][2] =
'dictionaries';
3539 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3540 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3541 $head2[$h][2] =
'permissions';
3544 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3545 $head2[$h][1] = $langs->trans(
"Tabs");
3546 $head2[$h][2] =
'tabs';
3549 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3550 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3551 $head2[$h][2] =
'menus';
3554 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3555 $head2[$h][1] = $langs->trans(
"Hooks");
3556 $head2[$h][2] =
'hooks';
3559 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3560 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3561 $head2[$h][2] =
'triggers';
3564 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3565 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3566 $head2[$h][2] =
'widgets';
3569 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3570 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3571 $head2[$h][2] =
'emailings';
3574 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3575 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3576 $head2[$h][2] =
'exportimport';
3579 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3580 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3581 $head2[$h][2] =
'css';
3584 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3585 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3586 $head2[$h][2] =
'js';
3589 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3590 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3591 $head2[$h][2] =
'cli';
3594 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3595 $head2[$h][1] = $langs->trans(
"CronList");
3596 $head2[$h][2] =
'cron';
3599 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3600 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="paddingleft badge">'.$hasDoc.
"</span>");
3601 $head2[$h][2] =
'specifications';
3604 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3605 $head2[$h][1] = $langs->trans(
"BuildPackage");
3606 $head2[$h][2] =
'buildpackage';
3609 $MAXTABFOROBJECT = 15;
3611 print
'<!-- Section for a given module -->';
3615 if ($tab ==
'description') {
3616 print
'<!-- tab=description -->'.
"\n";
3617 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3618 $pathtofilereadme = $modulelowercase.
'/README.md';
3619 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3621 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3623 if ($action !=
'editfile' || empty($file)) {
3624 $morehtmlright =
'';
3625 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3626 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3629 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3631 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3637 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3638 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>';
3642 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3643 foreach ($listofsetuppages as $setuppage) {
3646 print
'<span class="fa fa-file"></span> ';
3647 if ($setuppage[
'relativename'] ==
'about.php') {
3648 print $langs->trans(
"AboutFile");
3650 print $langs->trans(
"SetupFile");
3653 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3654 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>';
3658 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3659 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>';
3662 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3663 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>';
3669 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3672 print
'<div class="underbanner clearboth"></div>';
3673 print
'<div class="fichecenter">';
3674 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3675 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3676 print
'<input type="hidden" name="action" value="update_props_module">';
3677 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3678 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3679 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3680 print
'<table class="border centpercent">';
3681 print
'<tr class="liste_titre"><td class="titlefield">';
3682 print $langs->trans(
"Parameter");
3684 print $langs->trans(
"Value");
3688 print $langs->trans(
"IdModule");
3691 print
'<span class="opacitymedium">';
3693 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3694 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3699 print $langs->trans(
"ModuleName");
3705 print $langs->trans(
"Description");
3707 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3708 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'">';
3709 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3710 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3713 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>';
3715 $moduledescritpionautotrans =
$moduleobj->getDesc();
3716 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
3718 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3719 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
3721 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3727 print $langs->trans(
"Version");
3729 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3730 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
3731 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3732 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3735 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>';
3740 print $langs->trans(
"Family");
3743 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3744 print
'<select name="propsmodule" id="family" class="minwidth400">';
3745 $arrayoffamilies = array(
3746 'hr' =>
"ModuleFamilyHr",
3747 'crm' =>
"ModuleFamilyCrm",
3748 'srm' =>
"ModuleFamilySrm",
3749 'financial' =>
'ModuleFamilyFinancial',
3750 'products' =>
'ModuleFamilyProducts',
3751 'projects' =>
'ModuleFamilyProjects',
3752 'ecm' =>
'ModuleFamilyECM',
3753 'technic' =>
'ModuleFamilyTechnic',
3754 'portal' =>
'ModuleFamilyPortal',
3755 'interface' =>
'ModuleFamilyInterface',
3756 'base' =>
'ModuleFamilyBase',
3757 'other' =>
'ModuleFamilyOther'
3759 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>';
3760 foreach ($arrayoffamilies as $key => $value) {
3762 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3766 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3767 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3770 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>';
3775 print $langs->trans(
"Picto");
3777 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3778 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'">';
3779 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3780 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3783 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3784 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>';
3789 print $langs->trans(
"EditorName");
3791 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3792 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'">';
3793 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3794 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3797 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>';
3802 print $langs->trans(
"EditorUrl");
3804 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3805 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'">';
3806 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3807 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3810 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3812 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>';
3819 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3826 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3828 print
'<!-- readme file -->';
3829 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3830 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3832 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3838 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3840 print
'<!-- changelog file -->';
3842 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3844 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3852 if ($fullpathoffile) {
3853 $content = file_get_contents($fullpathoffile);
3857 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3858 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3859 print
'<input type="hidden" name="action" value="savefile">';
3860 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3861 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3862 print
'<input type="hidden" name="module" value="'.$module.
'">';
3866 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
3867 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3868 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3873 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3875 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3881 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3884 if ($tab ==
'languages') {
3885 print
'<!-- tab=languages -->'.
"\n";
3886 if ($action !=
'editfile' || empty($file)) {
3887 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3891 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3892 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3893 print
'<input type="hidden" name="action" value="addlanguage">';
3894 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3895 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3896 print
'<input type="hidden" name="module" value="'.$module.
'">';
3897 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
3898 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3904 $modulelowercase = strtolower($module);
3908 $diroflang .=
'/langs';
3909 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3911 if (!preg_match(
'/custom/', $dirread)) {
3913 $diroflang = $dirread;
3914 $diroflang .=
'/langs';
3915 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3918 print
'<table class="none">';
3919 foreach ($langfiles as $langfile) {
3920 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3921 if (!preg_match(
'/custom/', $dirread)) {
3922 $pathtofile =
'langs/'.$langfile[
'relativename'];
3924 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3925 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>';
3926 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>';
3937 $content = file_get_contents($fullpathoffile);
3940 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3941 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3942 print
'<input type="hidden" name="action" value="savefile">';
3943 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3944 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3945 print
'<input type="hidden" name="module" value="'.$module.
'">';
3947 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3948 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3951 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3953 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3960 if ($tab ==
'objects') {
3961 print
'<!-- tab=objects -->'.
"\n";
3966 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3968 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3969 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3970 $head3[$h][2] =
'newobject';
3974 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3976 $firstobjectname =
'';
3977 foreach ($listofobject as $fileobj) {
3978 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3981 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3985 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3986 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3988 $objectname = $reg[1];
3989 if (empty($firstobjectname)) {
3990 $firstobjectname = $objectname;
3992 $pictoname =
'generic';
3993 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3994 $pictoname = $reg[1];
3997 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3998 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3999 $head3[$h][2] = $objectname;
4005 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4006 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4007 $head3[$h][2] =
'deleteobject';
4012 if ($tabobj ==
'newobjectifnoobj') {
4013 if ($firstobjectname) {
4014 $tabobj = $firstobjectname;
4016 $tabobj =
'newobject';
4020 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4023 if ($tabobj ==
'newobject') {
4025 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4026 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4027 print
'<input type="hidden" name="action" value="initobject">';
4028 print
'<input type="hidden" name="tab" value="objects">';
4029 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4031 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4033 print
'<div class="tagtable">';
4035 print
'<div class="tagtr"><div class="tagtd">';
4036 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4037 print
'</div><div class="tagtd">';
4038 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
4039 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4040 print
'</div></div>';
4042 print
'<div class="tagtr"><div class="tagtd">';
4043 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4044 print
'</div><div class="tagtd">';
4045 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4046 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
4047 print
'</div></div>';
4049 print
'<div class="tagtr"><div class="tagtd">';
4050 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4051 print
'</div><div class="tagtd">';
4052 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4053 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4054 print
'</div></div>';
4059 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>';
4060 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4061 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4063 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4079 } elseif ($tabobj ==
'createproperty') {
4080 $attributesUnique = array(
4081 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4082 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4083 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4084 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4085 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4086 'propdefault' => $langs->trans(
"DefaultValue"),
4087 'propindex' => $langs->trans(
"DatabaseIndex"),
4088 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4089 'propposition' => $langs->trans(
"Position"),
4090 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4091 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4092 'propnoteditable' => $langs->trans(
"NotEditable"),
4094 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4095 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4096 'propcss' => $langs->trans(
"CSSClass"),
4097 'propcssview' => $langs->trans(
"CSSViewClass"),
4098 'propcsslist' => $langs->trans(
"CSSListClass"),
4099 'prophelp' => $langs->trans(
"KeyForTooltip"),
4100 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4102 'propcomment' => $langs->trans(
"Comment"),
4104 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4105 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4106 print
'<input type="hidden" name="action" value="addproperty">';
4107 print
'<input type="hidden" name="tab" value="objects">';
4108 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4109 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4111 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4113 foreach ($attributesUnique as $key => $attribute) {
4114 if ($counter % 2 === 0) {
4117 if ($key ==
'propname' || $key ==
'proplabel') {
4118 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>';
4119 } elseif ($key ==
'proptype') {
4120 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4121 print
'<input class="maxwidth200" id="'.$key.
'" list="datalist'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4123 print
'<datalist id="datalist'.$key.
'">';
4124 print
'<option>varchar(128)</option>';
4125 print
'<option>email</option>';
4126 print
'<option>phone</option>';
4127 print
'<option>ip</option>';
4128 print
'<option>url</option>';
4129 print
'<option>password</option>';
4130 print
'<option>text</option>';
4131 print
'<option>html</option>';
4132 print
'<option>date</option>';
4133 print
'<option>datetime</option>';
4134 print
'<option>integer</option>';
4135 print
'<option>stars(5)</option>';
4136 print
'<option>double(28,4)</option>';
4137 print
'<option>real</option>';
4138 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4147 print
'</datalist>';
4151 } elseif ($key ==
'propvisible') {
4152 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>';
4153 } elseif ($key ==
'propenabled') {
4156 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>';
4157 } elseif ($key ==
'proparrayofkeyval') {
4158 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>';
4160 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>';
4163 if ($counter % 2 === 0) {
4167 if ($counter % 2 !== 0) {
4168 while ($counter % 2 !== 0) {
4174 print
'</table><br>'.
"\n";
4175 print
'<div class="center">';
4176 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4177 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4183 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4184 window.location.href = url;
4186 $(document).ready(function() {
4187 $("#proplabel").on("keyup", function() {
4188 console.log("key up on label");
4189 s = cleanString($("#proplabel").val());
4190 $("#propname").val(s);
4193 function cleanString( stringtoclean )
4195 // allow "a-z", "A-Z", "0-9" and "_"
4196 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4197 stringtoclean = stringtoclean.toLowerCase();
4198 if (!isNaN(stringtoclean)) {
4201 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4202 stringtoclean = stringtoclean.substr(1)
4204 if (stringtoclean.length > 28) {
4205 stringtoclean = stringtoclean.substring(0, 27);
4207 return stringtoclean;
4212 } elseif ($tabobj ==
'deleteobject') {
4214 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4216 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4217 print
'<input type="hidden" name="tab" value="objects">';
4218 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4219 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4221 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4223 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4224 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4228 if ($action ==
'deleteproperty') {
4229 $formconfirm = $form->formconfirm(
4230 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4231 $langs->trans(
'Delete'),
4232 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4233 'confirm_deleteproperty',
4242 if ($action !=
'editfile' || empty($file)) {
4246 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4247 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4248 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4249 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4250 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4251 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4252 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4253 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4254 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4257 clearstatcache(
true);
4258 if (function_exists(
'opcache_invalidate')) {
4259 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4262 if (empty($forceddirread) && empty($dirread)) {
4264 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4266 $result = include_once $dirread.
'/'.$pathtoclass;
4267 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4270 if (class_exists($tabobj)) {
4272 $tmpobject = @
new $tabobj($db);
4274 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4277 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4281 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4284 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4287 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4290 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4293 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4294 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4297 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4300 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4303 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4306 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4308 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4310 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4311 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4313 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4314 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4316 $tmpobject = $tmpobject ??
null;
4317 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4318 $pathtopicto = $tmpobject->picto;
4319 $realpathtopicto =
'';
4321 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4322 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4327 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4328 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4329 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4330 $realpathtocard = $dirread.
'/'.$pathtocard;
4331 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4332 $realpathtolist = $dirread.
'/'.$pathtolist;
4333 $realpathtonote = $dirread.
'/'.$pathtonote;
4334 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4335 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4336 $realpathtosql = $dirread.
'/'.$pathtosql;
4337 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4338 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4339 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4340 $realpathtolib = $dirread.
'/'.$pathtolib;
4341 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4343 if (empty($realpathtoapi)) {
4344 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4345 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4353 print
'<!-- section for object -->';
4354 print
'<div class="fichehalfleft smallxxx">';
4356 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>';
4357 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>';
4360 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4361 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.(
dol_is_file($realpathtopicto) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtopicto).(
dol_is_file($realpathtopicto) ?
'' :
'</strike>').
'</strong>';
4364 } elseif (!empty($tmpobject)) {
4365 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4371 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>';
4373 $file = file_get_contents($realpathtoapi);
4374 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4375 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>';
4377 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>';
4378 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4381 if ($modulelowercase !==
null && !isModEnabled($modulelowercase)) {
4382 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4384 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4387 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>';
4390 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>';
4394 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>';
4396 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>';
4398 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>';
4400 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>';
4406 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>';
4407 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>';
4409 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>';
4410 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>';
4414 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>';
4415 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>';
4416 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>';
4419 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>';
4420 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>';
4423 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>';
4425 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>';
4427 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>';
4429 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>';
4431 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>';
4435 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>';
4437 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>';
4439 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>';
4441 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>';
4446 print
'<div class="fichehalfleft smallxxxx">';
4447 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>';
4448 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>';
4450 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>';
4451 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>';
4454 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>';
4455 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>';
4458 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>';
4460 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>';
4464 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>';
4465 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>';
4468 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>';
4470 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>';
4474 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>';
4475 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>';
4478 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>';
4480 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>';
4484 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>';
4485 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>';
4488 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>';
4490 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>';
4497 print
'<br><br><br>';
4499 if (!empty($tmpobject)) {
4500 $reflector =
new ReflectionClass($tabobj);
4501 $reflectorproperties = $reflector->getProperties();
4502 $reflectorpropdefault = $reflector->getDefaultProperties();
4506 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4507 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4508 print
'<input type="hidden" name="action" value="addproperty">';
4509 print
'<input type="hidden" name="tab" value="objects">';
4510 print
'<input type="hidden" name="page_y" value="">';
4511 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4512 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4514 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4515 print
'<br><br class="clearboth">';
4516 print
'<br class="clearboth">';
4518 $mod = strtolower($module);
4519 $obj = strtolower($tabobj);
4520 $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));
4521 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4523 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
4526 print
'<!-- Table with properties of object -->'.
"\n";
4527 print
'<div class="div-table-responsive">';
4528 print
'<table class="noborder small">';
4529 print
'<tr class="liste_titre">';
4530 print
'<th class="tdsticky tdstickygray">';
4531 $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>';
4532 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4535 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4537 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4538 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4539 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4540 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4541 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4542 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4543 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4544 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4545 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4546 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4548 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4549 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4550 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4551 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4552 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4553 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4554 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4556 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4557 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4558 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4564 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4565 if (!empty($properties)) {
4567 foreach ($properties as $propkey => $propval) {
4582 $propname = $propkey;
4583 $proplabel = $propval[
'label'];
4584 $proptype = $propval[
'type'];
4585 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4586 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4587 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4588 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4589 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4590 $propposition = $propval[
'position'];
4591 $propenabled = $propval[
'enabled'];
4592 $propvisible = $propval[
'visible'];
4593 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4595 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4596 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4597 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4598 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4599 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4600 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4601 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4603 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4604 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4606 print
'<!-- line for object property -->'.
"\n";
4607 print
'<tr class="oddeven">';
4609 print
'<td class="tdsticky tdstickygray">';
4612 if ($action ==
'editproperty' && $propname == $propertykey) {
4614 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4615 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4617 print
'<td class="tdoverflowmax150">';
4618 print
'<input name="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'"></input>';
4620 print
'<td class="tdoverflowmax200">';
4621 print
'<textarea name="proparrayofkeyval">';
4622 if (isset($proparrayofkeyval)) {
4623 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4627 print
'</textarea>';
4630 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4633 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4635 print
'<td class="center">';
4636 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4639 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4642 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4645 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4648 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4651 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4657 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4660 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4663 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4666 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4669 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4672 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4675 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4678 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4681 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4683 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4684 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4685 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4688 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4691 print
'<td class="tdoverflowmax200">';
4694 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4695 $pictoType =
'varchar';
4696 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4697 $pictoType =
'link';
4698 } elseif (strpos($proptype,
'integer') === 0) {
4699 $pictoType = substr($proptype, 0, 3);
4700 } elseif (strpos($proptype,
'timestamp') === 0) {
4701 $pictoType =
'datetime';
4702 } elseif (strpos($proptype,
'real') === 0) {
4703 $pictoType =
'double';
4704 } elseif (strpos($proptype,
'stars') === 0) {
4705 $pictoType =
'stars';
4709 print
'<td class="tdoverflowmax200">';
4710 if ($proparrayofkeyval) {
4711 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4716 print
'<td class="center">';
4722 print
'<td class="center">';
4723 print $propindex ?
'1' :
'';
4725 print
'<td class="center">';
4728 print
'<td class="right">';
4731 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4735 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4739 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4745 print
'<td class="center">';
4746 print $propsearchall ?
'1' :
'';
4748 print
'<td class="center">';
4751 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4754 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4757 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4761 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4764 print
'<td class="center">';
4770 print
'<td class="center">';
4773 print
'<td class="tdoverflowmax200">';
4774 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4778 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4779 if ($propname !=
'rowid') {
4780 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>';
4781 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>';
4788 if ($tab ==
'specifications') {
4789 if ($action !=
'editfile' || empty($file)) {
4790 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4795 foreach ($specs as $spec) {
4796 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4797 $format =
'asciidoc';
4798 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4799 $format =
'markdown';
4801 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4802 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>';
4812 $content = file_get_contents($fullpathoffile);
4815 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4816 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4817 print
'<input type="hidden" name="action" value="savefile">';
4818 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4819 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4820 print
'<input type="hidden" name="module" value="'.$module.
'">';
4822 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4823 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4826 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4828 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4834 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>';
4841 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4845 print $e->getMessage();
4849 if (empty($forceddirread)) {
4852 $fullpathoffile = $dirread.
'/'.$file;
4855 $content = file_get_contents($fullpathoffile);
4858 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4859 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4860 print
'<input type="hidden" name="action" value="savefile">';
4861 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4862 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4863 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4864 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4866 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4867 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4870 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4872 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4882 if ($tab ==
'dictionaries') {
4883 print
'<!-- tab=dictionaries -->'.
"\n";
4884 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4888 if ($action ==
'deletedict') {
4889 $formconfirm = $form->formconfirm(
4890 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
4891 $langs->trans(
'Delete'),
4892 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
4893 'confirm_deletedictionary',
4901 if ($action !=
'editfile' || empty($file)) {
4902 print
'<span class="opacitymedium">';
4903 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4904 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4905 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4909 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4910 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>';
4912 if (is_array($dicts) && !empty($dicts)) {
4913 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4914 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
4925 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
4926 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4927 $head3[$h][2] =
'newdictionary';
4968 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).
'&tabdic=newdictionary');
4969 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
4971 if ($tabdic !=
'newdictionary') {
4972 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4973 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4974 print
'<input type="hidden" name="action" value="addDictionary">';
4975 print
'<input type="hidden" name="tab" value="dictionaries">';
4976 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4977 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
4979 print
'<div class="div-table-responsive">';
4980 print
'<table class="noborder">';
4982 print
'<tr class="liste_titre">';
4983 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
4996 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
4998 $maxi = count($dicts[
'tabname']);
4999 while ($i < $maxi) {
5000 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5001 print
'<tr class="oddeven">';
5002 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5003 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5004 print
'<input type="hidden" name="tab" value="dictionaries">';
5005 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5006 print
'<input type="hidden" name="action" value="updatedictionary">';
5007 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5009 print
'<td class="tdsticky tdstickygray">';
5014 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5018 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5022 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5026 print
'<select name="tabsqlsort">';
5027 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5031 print
'<td><select name="tabfield" >';
5032 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5033 print
'</select></td>';
5035 print
'<td><select name="tabfieldvalue" >';
5036 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5037 print
'</select></td>';
5039 print
'<td><select name="tabfieldinsert" >';
5040 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5041 print
'</select></td>';
5044 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5048 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5051 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5052 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5054 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5060 print
'<tr class="oddeven">';
5062 print
'<td class="tdsticky tdstickygray">';
5067 print $dicts[
'tabname'][$i];
5071 print $dicts[
'tablib'][$i];
5075 print $dicts[
'tabsql'][$i];
5079 print $dicts[
'tabsqlsort'][$i];
5083 print $dicts[
'tabfield'][$i];
5087 print $dicts[
'tabfieldvalue'][$i];
5091 print $dicts[
'tabfieldinsert'][$i];
5095 print $dicts[
'tabrowid'][$i];
5099 print $dicts[
'tabcond'][$i];
5102 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5103 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>';
5104 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>';
5112 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5121 if ($tabdic ==
'newdictionary') {
5123 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5124 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5125 print
'<input type="hidden" name="action" value="initdic">';
5126 print
'<input type="hidden" name="tab" value="dictionaries">';
5127 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5129 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5131 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5134 print
'<table class="border centpercent">';
5136 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>';
5137 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>';
5138 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>';
5139 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>';
5140 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5141 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5142 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5143 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5145 print
'</tbody></table>';
5146 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5147 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5151 $(document).ready(function() {
5152 $("input[name=\'dicname\']").on("blur", function() {
5153 if ($(this).val().length > 0) {
5154 $("input[name=\'label\']").val($(this).val());
5155 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5156 $("input[name=\'sqlsort\']").val("label ASC");
5157 $("input[name=\'field\']").val("code,label");
5158 $("input[name=\'fieldvalue\']").val("code,label");
5159 $("input[name=\'fieldinsert\']").val("code,label");
5160 $("input[name=\'rowid\']").val("rowid");
5162 $("input[name=\'label\']").val("");
5163 $("input[name=\'sql\']").val("");
5164 $("input[name=\'sqlsort\']").val("");
5165 $("input[name=\'field\']").val("");
5166 $("input[name=\'fieldvalue\']").val("");
5167 $("input[name=\'fieldinsert\']").val("");
5168 $("input[name=\'rowid\']").val("");
5171 $("input[id=\'cancel\']").click(function() {
5172 window.history.back();
5189 } elseif ($tabdic ==
'deletedictionary') {
5191 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5192 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5193 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5194 print
'<input type="hidden" name="tab" value="dictionaries">';
5195 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5197 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5199 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5200 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5208 $content = file_get_contents($fullpathoffile);
5211 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5212 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5213 print
'<input type="hidden" name="action" value="savefile">';
5214 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5215 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5216 print
'<input type="hidden" name="module" value="'.$module.
'">';
5218 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5219 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5220 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5223 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5225 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5232 if ($tab ==
'menus') {
5233 print
'<!-- tab=menus -->'.
"\n";
5234 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5235 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
5236 $destdir = $dirins.
'/'.strtolower($module);
5237 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5240 $leftmenus = array();
5245 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5248 $groupedRights = array();
5249 foreach ($permissions as $right) {
5251 if (!isset($groupedRights[$key])) {
5252 $groupedRights[$key] = array();
5254 $groupedRights[$key][] = $right;
5256 $groupedRights_json = json_encode($groupedRights);
5258 if ($action ==
'deletemenu') {
5259 $formconfirms = $form->formconfirm(
5260 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5261 $langs->trans(
'Delete'),
5262 ($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'))),
5263 'confirm_deletemenu',
5268 print $formconfirms;
5270 if ($action !=
'editfile' || empty($file)) {
5271 print
'<span class="opacitymedium">';
5272 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5273 $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);
5274 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5279 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5280 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>';
5284 $listODifferentUrlsInMenu = array();
5285 foreach ($menus as $obj) {
5286 if (preg_match(
'/^\/'.preg_quote(strtolower($module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5287 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5290 $pathtofile = $obj[
'url'];
5291 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5292 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5293 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>';
5302 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5303 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5304 print
'<input type="hidden" name="action" value="addmenu">';
5305 print
'<input type="hidden" name="tab" value="menus">';
5306 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5307 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5309 print
'<div class="div-table-responsive">';
5310 print
'<table class="noborder small">';
5312 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5313 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5314 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5315 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(strtolower($module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5316 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5317 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5318 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(strtolower($module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5320 print
'<tr class="liste_titre">';
5321 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5324 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5327 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5329 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5330 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5331 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5332 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5333 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5334 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5337 $r = count($menus) + 1;
5340 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5341 print
'<td class="center">';
5342 print
'<select class="maxwidth50" name="type">';
5343 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5344 print
'</select></td>';
5345 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5346 print
'<td class="left">';
5347 print
'<select name="fk_menu">';
5348 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5349 foreach ($menus as $obj) {
5350 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5351 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5356 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>';
5357 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5359 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5360 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5362 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5364 print
'<td class="center">';
5365 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.$module.
'\')').
'">';
5374 print
'<td class="left">';
5375 print
'<select class="maxwidth" name="objects" id="objects">';
5376 print
'<option value=""></option>';
5377 if (is_array($objects)) {
5378 foreach ($objects as $value) {
5379 print
'<option value="'.strtolower($value).
'">'.
dol_escape_htmltag(strtolower($value)).
'</option>';
5383 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5386 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5387 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>';
5389 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5390 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5398 if (count($menus)) {
5400 foreach ($menus as $menu) {
5404 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
5406 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5407 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5408 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5409 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5410 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5411 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5412 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5413 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5414 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5416 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5417 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5421 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5423 print
'<tr class="oddeven">';
5424 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5425 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5426 print
'<input type="hidden" name="action" value="update_menu">';
5427 print
'<input type="hidden" name="tab" value="menus">';
5428 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5429 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5431 print
'<td class="tdsticky tdstickygray">';
5435 print
'<td class="center">
5436 <select class="center maxwidth50" name="type">
5437 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5440 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5441 if ($menu[
'type'] ==
'left') {
5446 print
'</option></select></td>';
5448 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5459 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5461 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5462 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5464 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5465 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5467 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5469 print
'<td class="nowraponall">';
5470 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag($module).
"')").
'">';
5471 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5472 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5473 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5474 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag($module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5475 print $form->textwithpicto('', $htmltext);
5477 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5478 print '<option value=
"1">1 (always enabled)</option>
';
5479 print '<option value=
"0">0 (always
disabled)</option>
';
5480 print '<option value=
"isModEnabled(\''.dol_escape_htmltag($module).'\')" >isModEnabled(\
''.
dol_escape_htmltag($module).
'\')</option>
';
5485 print '<td
class=
"nowraponall">
';
5486 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5488 if (!empty($objPerms)) {
5489 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5490 print '<select
class=
"center maxwidth50" name=
"perms">
';
5491 if (!empty($valPerms)) {
5492 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5493 foreach ($crud as $key => $val) {
5494 if ($valPerms != $key) {
5495 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5501 print '<select
class=
"center maxwidth50" name=
"objects">
';
5502 print '<option></option>
';
5503 foreach ($objects as $obj) {
5504 print '<option value=
"'.dol_escape_htmltag(strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5507 print '<select
class=
"center maxwidth50" name=
"perms">
';
5508 foreach ($crud as $key => $val) {
5509 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5515 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5516 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>
';
5517 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5518 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5519 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5524 print '<tr
class=
"oddeven">
';
5526 print '<td
class=
"tdsticky tdstickygray">
';
5530 print '<td
class=
"center">
';
5531 print dol_escape_htmltag($menu['type']);
5536 print dol_escape_htmltag($menu['titre
']);
5540 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5541 print dol_escape_htmltag($menu['fk_menu
']);
5545 print dol_escape_htmltag($menu['mainmenu
']);
5549 print dol_escape_htmltag($menu['leftmenu
']);
5552 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5553 print dol_escape_htmltag($menu['url
']);
5557 print dol_escape_htmltag($menu['langs
']);
5561 print '<td
class=
"center">
';
5562 print dol_escape_htmltag((string) $menu['position']);
5566 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5567 print dol_escape_htmltag($menu['enabled
']);
5571 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5572 print dol_escape_htmltag($langs->trans($menu['perms
']));
5576 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5577 print dol_escape_htmltag($menu['target
']);
5580 print '<td
class=
"center">
';
5581 if ($menu['user'] == 2) {
5582 print $langs->trans("AllMenus");
5583 } elseif ($menu['user'] == 0) {
5584 print $langs->trans('Internal
');
5585 } elseif ($menu['user'] == 1) {
5586 print $langs->trans('External
');
5588 print $menu['user']; // should not happen
5591 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
5592 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
5593 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>
';
5594 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>
';
5601 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
5610 $(document).ready(
function() {
5612 $(
"#leftmenu").on(
"input",
function() {
5613 var inputLeftMenu = $(
"#leftmenu").val();
5614 if (inputLeftMenu !== \
'\') {
5615 var url = \
''.dol_escape_js(strtolower($module)).
'\' + inputLeftMenu + \
'.php\';
5622 var groupedRights = ' . $groupedRights_json .
';
5623 var objectsSelect = $("select[id=\'objects\']");
5624 var permsSelect = $("select[id=\'perms\']");
5626 objectsSelect.change(function() {
5627 var selectedObject = $(this).val();
5629 permsSelect.empty();
5631 var rights = groupedRights[selectedObject];
5634 for (var i = 0; i < rights.length; i++) {
5635 var right = rights[i];
5636 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
5637 permsSelect.append(option);
5640 var option = $("<option></option>").attr("value", "read").text("read");
5641 permsSelect.append(option);
5644 if (selectedObject !== "" && selectedObject !== null && rights) {
5649 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
5660 $content = file_get_contents($fullpathoffile);
5663 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5664 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5665 print
'<input type="hidden" name="action" value="savefile">';
5666 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5667 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5668 print
'<input type="hidden" name="module" value="'.$module.
'">';
5670 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5671 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5672 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5675 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5677 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5684 if ($tab ==
'permissions') {
5685 print
'<!-- tab=permissions -->'.
"\n";
5686 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5691 $dir = $dirread.
'/'.$modulelowercase.
'/class';
5692 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
5693 $objects = array(
'myobject');
5695 foreach ($listofobject as $fileobj) {
5696 $tmpcontent = file_get_contents($fileobj[
'fullname']);
5697 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
5698 $objects[$fileobj[
'fullname']] = $reg[1];
5703 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5704 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
5706 $action =
GETPOST(
'action',
'alpha');
5708 if ($action ==
'deleteright') {
5709 $formconfirm = $form->formconfirm(
5710 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)),
5711 $langs->trans(
'Delete'),
5712 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
5713 'confirm_deleteright',
5721 if ($action !=
'editfile' || empty($file)) {
5722 print
'<!-- Tab to manage permissions -->'.
"\n";
5723 print
'<span class="opacitymedium">';
5724 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
5725 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
5726 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5730 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5731 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>';
5737 print
'<!-- form to add permissions -->'.
"\n";
5738 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5739 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5740 print
'<input type="hidden" name="action" value="addright">';
5741 print
'<input type="hidden" name="tab" value="permissions">';
5742 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5743 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5745 print
'<div class="div-table-responsive">';
5746 print
'<table class="noborder">';
5748 print
'<tr class="liste_titre">';
5750 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
5757 print
'<tr class="small">';
5758 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
5760 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
5761 print
'<option value=""></option>';
5762 foreach ($objects as $obj) {
5763 if ($obj !=
'myobject') {
5764 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
5767 print
'</select></td>';
5769 print
'<td><select class="maxwidth75" name="crud" id="crud">';
5770 print
'<option value=""></option>';
5771 foreach ($crud as $key => $val) {
5772 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
5777 print
'<input type="text" name="label" id="label" class="minwidth200">';
5780 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5781 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5785 if (count($perms)) {
5787 foreach ($perms as $perm) {
5791 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
5792 print
'<tr class="oddeven">';
5793 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
5794 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5795 print
'<input type="hidden" name="tab" value="permissions">';
5796 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5797 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5798 print
'<input type="hidden" name="action" value="update_right">';
5799 print
'<input type="hidden" name="counter" value="'.$i.
'">';
5801 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
5803 print
'<td class="tdsticky tdstickygray">';
5804 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
5808 print
'<select name="crud">';
5809 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
5810 foreach ($crud as $i => $x) {
5811 if ($perm[5] != $i) {
5812 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
5818 print
'<td><select name="permissionObj" >';
5819 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
5820 print
'</select></td>';
5823 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
5826 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5827 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
5829 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5836 print
'<tr class="oddeven">';
5843 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5851 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5852 print ucfirst($langs->trans($perm[5]));
5854 print ucfirst($langs->trans($perm[4]));
5859 print $langs->trans($perm[1]);
5862 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5863 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>';
5864 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>';
5872 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5880 function updateInputField() {
5881 value1 = $("#crud").val();
5882 value2 = $("#permissionObj").val();
5884 // Vérifie si les deux sélections sont faites
5885 if (value1 && value2) {
5886 switch(value1.toLowerCase()){
5888 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
5891 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
5894 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
5902 $("#crud, #permissionObj").change(function(){
5903 console.log("We change selection");
5911 $content = file_get_contents($fullpathoffile);
5914 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5915 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5916 print
'<input type="hidden" name="action" value="savefile">';
5917 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5918 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5919 print
'<input type="hidden" name="module" value="'.$module.
'">';
5921 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5922 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5923 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5926 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5928 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5935 if ($tab ==
'hooks') {
5936 print
'<!-- tab=hooks -->'.
"\n";
5937 if ($action !=
'editfile' || empty($file)) {
5938 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
5943 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5945 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5947 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>';
5951 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
5952 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
5954 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5956 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> ';
5957 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>';
5959 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5960 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>';
5967 $content = file_get_contents($fullpathoffile);
5970 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5971 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5972 print
'<input type="hidden" name="action" value="savefile">';
5973 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5974 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5975 print
'<input type="hidden" name="module" value="'.$module.
'">';
5977 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5978 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5979 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5982 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5984 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5991 if ($tab ==
'triggers') {
5992 print
'<!-- tab=triggers -->'.
"\n";
5993 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
5996 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
5998 if ($action !=
'editfile' || empty($file)) {
5999 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6004 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6006 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6008 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>';
6011 if (!empty($triggers)) {
6012 foreach ($triggers as $trigger) {
6013 $pathtofile = $trigger[
'relpath'];
6016 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6017 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>';
6018 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>';
6023 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6024 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6025 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>';
6034 $content = file_get_contents($fullpathoffile);
6037 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6038 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6039 print
'<input type="hidden" name="action" value="savefile">';
6040 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6041 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6042 print
'<input type="hidden" name="module" value="'.$module.
'">';
6044 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6045 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6046 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6049 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6051 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6058 if ($tab ==
'css') {
6059 print
'<!-- tab=css -->'.
"\n";
6060 if ($action !=
'editfile' || empty($file)) {
6061 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6067 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
6068 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6070 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6071 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>';
6072 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>';
6074 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6075 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>';
6081 $content = file_get_contents($fullpathoffile);
6084 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6085 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6086 print
'<input type="hidden" name="action" value="savefile">';
6087 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6088 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6089 print
'<input type="hidden" name="module" value="'.$module.
'">';
6091 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6092 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6095 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6097 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6105 print
'<!-- tab=js -->'.
"\n";
6106 if ($action !=
'editfile' || empty($file)) {
6107 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6113 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
6114 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6116 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6117 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>';
6118 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>';
6120 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6121 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>';
6127 $content = file_get_contents($fullpathoffile);
6130 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6131 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6132 print
'<input type="hidden" name="action" value="savefile">';
6133 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6134 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6135 print
'<input type="hidden" name="module" value="'.$module.
'">';
6137 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6138 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6141 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6143 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6150 if ($tab ==
'widgets') {
6151 print
'<!-- tab=widgets -->'.
"\n";
6152 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6156 if ($action !=
'editfile' || empty($file)) {
6157 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6161 if (!empty($widgets)) {
6162 foreach ($widgets as $widget) {
6163 $pathtofile = $widget[
'relpath'];
6165 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6166 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>';
6167 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>';
6171 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6172 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>';
6179 $content = file_get_contents($fullpathoffile);
6182 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6183 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6184 print
'<input type="hidden" name="action" value="savefile">';
6185 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6186 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6187 print
'<input type="hidden" name="module" value="'.$module.
'">';
6189 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6190 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6193 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6195 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6202 if ($tab ==
'emailings') {
6203 print
'<!-- tab=emailings -->'.
"\n";
6204 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6208 if ($action !=
'editfile' || empty($file)) {
6209 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6213 if (!empty($emailingselectors)) {
6214 foreach ($emailingselectors as $emailingselector) {
6215 $pathtofile = $emailingselector[
'relpath'];
6217 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6218 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>';
6219 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>';
6223 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6224 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>';
6231 $content = file_get_contents($fullpathoffile);
6234 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6235 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6236 print
'<input type="hidden" name="action" value="savefile">';
6237 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6238 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6239 print
'<input type="hidden" name="module" value="'.$module.
'">';
6241 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6242 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6245 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6247 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6254 if ($tab ==
'exportimport') {
6255 print
'<!-- tab=exportimport -->'.
"\n";
6256 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6261 if ($action !=
'editfile' || empty($file)) {
6262 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6265 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6266 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>';
6268 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6269 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>';
6274 $content = file_get_contents($fullpathoffile);
6277 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6278 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6279 print
'<input type="hidden" name="action" value="savefile">';
6280 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6281 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6282 print
'<input type="hidden" name="module" value="'.$module.
'">';
6284 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6285 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6286 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6289 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6291 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6298 if ($tab ==
'cli') {
6299 print
'<!-- tab=cli -->'.
"\n";
6300 $clifiles = array();
6303 $dircli = array(
'/'.strtolower($module).
'/scripts');
6305 foreach ($dircli as $reldir) {
6310 if (!is_dir($newdir)) {
6314 $handle = opendir($newdir);
6316 if (is_resource($handle)) {
6317 while (($tmpfile = readdir($handle)) !==
false) {
6318 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6319 if (preg_match(
'/\.back$/', $tmpfile)) {
6323 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6332 if ($action !=
'editfile' || empty($file)) {
6333 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6337 if (!empty($clifiles)) {
6338 foreach ($clifiles as $clifile) {
6339 $pathtofile = $clifile[
'relpath'];
6341 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6342 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>';
6343 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>';
6347 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6348 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>';
6355 $content = file_get_contents($fullpathoffile);
6358 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6359 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6360 print
'<input type="hidden" name="action" value="savefile">';
6361 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6362 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6363 print
'<input type="hidden" name="module" value="'.$module.
'">';
6365 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6366 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6369 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6371 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6378 if ($tab ==
'cron') {
6379 print
'<!-- tab=cron -->'.
"\n";
6380 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6384 if ($action !=
'editfile' || empty($file)) {
6385 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>';
6388 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6389 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>';
6395 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6396 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6397 print
'<input type="hidden" name="action" value="addproperty">';
6398 print
'<input type="hidden" name="tab" value="objects">';
6399 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6400 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6402 print
'<div class="div-table-responsive">';
6403 print
'<table class="noborder">';
6405 print
'<tr class="liste_titre">';
6413 if (count($cronjobs)) {
6414 foreach ($cronjobs as $cron) {
6415 print
'<tr class="oddeven">';
6418 print $cron[
'label'];
6423 if ($cron[
'jobtype'] ==
'method') {
6424 $text = $langs->trans(
"CronClass");
6425 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
6426 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6427 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6428 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6429 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6430 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6431 } elseif ($cron[
'jobtype'] ==
'command') {
6432 $text = $langs->trans(
'CronCommand');
6433 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6434 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6435 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6437 print $form->textwithpicto($text, $texttoshow, 1);
6441 if ($cron[
'unitfrequency'] ==
"60") {
6442 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6444 if ($cron[
'unitfrequency'] ==
"3600") {
6445 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6447 if ($cron[
'unitfrequency'] ==
"86400") {
6448 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6450 if ($cron[
'unitfrequency'] ==
"604800") {
6451 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6456 print $cron[
'status'];
6460 if (!empty($cron[
'comment'])) {
6461 print $cron[
'comment'];
6468 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6478 $content = file_get_contents($fullpathoffile);
6481 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6482 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6483 print
'<input type="hidden" name="action" value="savefile">';
6484 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6485 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6486 print
'<input type="hidden" name="module" value="'.$module.
'">';
6488 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6489 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6490 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6493 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6495 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6502 if ($tab ==
'specifications') {
6503 print
'<!-- tab=specifications -->'.
"\n";
6506 if ($action !=
'editfile' || empty($file)) {
6507 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6511 if (is_array($specs) && !empty($specs)) {
6512 foreach ($specs as $spec) {
6513 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6514 $format =
'asciidoc';
6515 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6516 $format =
'markdown';
6519 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6520 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>';
6521 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>';
6526 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6527 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>';
6538 $content = file_get_contents($fullpathoffile);
6541 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6542 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6543 print
'<input type="hidden" name="action" value="savefile">';
6544 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6545 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6546 print
'<input type="hidden" name="module" value="'.$module.
'">';
6548 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6549 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6552 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6554 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6560 print
'<br><br><br>';
6562 $FILENAMEDOC = $modulelowercase.
'.html';
6563 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6564 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6565 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6566 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6567 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6568 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6569 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6572 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6574 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6577 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6578 print $outputfiledoc;
6581 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6582 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>';
6584 print
'</strong><br>';
6587 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
6589 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6592 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
6593 print $outputfiledocpdf;
6596 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
6597 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>';
6599 print
'</strong><br>';
6603 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
6604 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6605 print
'<input type="hidden" name="action" value="generatedoc">';
6606 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6607 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6608 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
6609 if (!is_array($specs) || empty($specs)) {
6610 print
' disabled="disabled"';
6616 if ($tab ==
'buildpackage') {
6617 print
'<!-- tab=buildpackage -->'.
"\n";
6618 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
6621 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
6622 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
6626 $modulelowercase = strtolower($module);
6632 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6634 $class =
'mod'.$module;
6636 if (class_exists($class)) {
6639 '@phan-var-force DolibarrModules $moduleobj';
6648 $langs->load(
"errors");
6649 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
6653 $arrayversion = explode(
'.',
$moduleobj->version, 3);
6654 if (count($arrayversion)) {
6655 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
6656 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
6661 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
6663 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6665 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
6666 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
6667 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
6668 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>';
6676 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
6677 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6678 print
'<input type="hidden" name="action" value="generatepackage">';
6679 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6680 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6681 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
6685 if ($tab ==
'tabs') {
6686 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6690 if ($action !=
'editfile' || empty($file)) {
6691 print
'<span class="opacitymedium">';
6692 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
6693 $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);
6694 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6698 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
6699 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>';
6705 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6706 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6707 print
'<input type="hidden" name="action" value="addproperty">';
6708 print
'<input type="hidden" name="tab" value="objects">';
6709 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6710 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6712 print
'<div class="div-table-responsive">';
6713 print
'<table class="noborder small">';
6715 print
'<tr class="liste_titre">';
6725 foreach ($tabs as $tab) {
6726 $parts = explode(
':', $tab[
'data']);
6728 $objectType = $parts[0];
6729 $tabName = $parts[1];
6730 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
6731 $langFile = isset($parts[3]) ? $parts[3] :
'';
6732 $condition = isset($parts[4]) ? $parts[4] :
'';
6733 $path = isset($parts[5]) ? $parts[5] :
'';
6737 if ($tabName[0] ===
'-') {
6739 $condition = isset($parts[2]) ? $parts[2] :
'';
6742 print
'<tr class="oddeven">';
6749 if ($tabName[0] ===
"+") {
6750 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6752 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6775 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6785 $content = file_get_contents($fullpathoffile);
6788 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6789 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6790 print
'<input type="hidden" name="action" value="savefile">';
6791 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6792 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6793 print
'<input type="hidden" name="module" value="'.$module.
'">';
6795 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6796 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6797 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6800 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6802 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6809 if ($tab !=
'description') {
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_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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
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'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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:/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.