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';
1321 if (isset($obj->Picto)) {
1322 $picto = $obj->Picto;
1324 if ($obj->Field ==
'fk_soc') {
1327 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1332 $stringforproperties .=
"'".$obj->Field.
"' => array('type' => '".$type.
"', 'label' => '".$label.
"',";
1333 if ($default !=
'') {
1334 $stringforproperties .=
" 'default' => ".$default.
",";
1336 $stringforproperties .=
" 'enabled' => ".$enabled.
",";
1337 $stringforproperties .=
" 'visible' => ".$visible;
1339 $stringforproperties .=
", 'notnull' => ".$notnull;
1341 if ($alwayseditable) {
1342 $stringforproperties .=
", 'alwayseditable' => 1";
1344 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1345 $stringforproperties .=
", 'showoncombobox' => 1";
1347 $stringforproperties .=
", 'position' => ".$position;
1349 $stringforproperties .=
", 'index' => ".$index;
1352 $stringforproperties .=
", 'picto' => '".$picto.
"'";
1355 $stringforproperties .=
", 'css' => '".$css.
"'";
1358 $stringforproperties .=
", 'cssview' => '".$cssview.
"'";
1361 $stringforproperties .=
", 'csslist' => '".$csslist.
"'";
1363 $stringforproperties .=
"),\n";
1366 $stringforproperties .=
');'.
"\n";
1367 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1371 $filetogenerate = array();
1374 $filetogenerate = array(
1375 'myobject_card.php' => strtolower($objectname).
'_card.php',
1376 'myobject_note.php' => strtolower($objectname).
'_note.php',
1377 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1378 'myobject_document.php' => strtolower($objectname).
'_document.php',
1379 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1380 'myobject_list.php' => strtolower($objectname).
'_list.php',
1381 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1382 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1384 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1385 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1386 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1387 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1389 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1391 'ajax/myobject.php' =>
'ajax/'.strtolower($objectname).
'.php',
1394 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1395 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1397 $filetogenerate += array(
1398 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1399 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1400 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1403 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1404 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1405 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1407 $filetogenerate += array(
1408 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1409 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1412 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1413 $firstobjectname =
'myobject';
1414 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1416 $class =
'mod'.$module;
1418 if (class_exists($class)) {
1421 '@phan-var-force DolibarrModules $moduleobj';
1433 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1435 if ($checkComment < 0) {
1436 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1438 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1439 if ($generatePerms < 0) {
1440 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1446 foreach ($filetogenerate as $srcfile => $destfile) {
1447 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1451 $langs->load(
"errors");
1452 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1455 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1458 $arrayreplacement = array(
1459 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1460 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1463 dolReplaceInFile($destdir.
'/'.$destfile, $arrayreplacement,
'',
'0', 0, 1);
1468 if (!$error && $stringforproperties) {
1470 $arrayreplacement = array(
1471 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1474 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1478 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1480 $arrayreplacement = array(
1481 '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' =>
"'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'"
1485 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1487 $arrayreplacement = array(
1488 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1490 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1494 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1496 $arrayreplacement = array(
1497 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1499 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1500 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'',
'0', 0, 1);
1502 $arrayreplacement = array(
1503 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1506 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'',
'0', 0, 1);
1513 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1515 $firstobjectname =
'';
1517 foreach ($listofobject as $fileobj) {
1518 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1521 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1525 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1527 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1528 $objectnameloop = $reg[1];
1529 if (empty($firstobjectname)) {
1530 $firstobjectname = $objectnameloop;
1536 \$this->menu[\$r++] = array(
1537 'fk_menu' => 'fk_mainmenu=mymodule',
1539 'titre' => 'MyObject',
1540 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1541 'mainmenu' => 'mymodule',
1542 'leftmenu' => 'myobject',
1543 'url' => '/mymodule/myobject_list.php',
1544 'langs' => 'mymodule@mymodule',
1545 'position' => 1000 + \$r,
1546 'enabled' => 'isModEnabled(\"mymodule\")',
1547 'perms' => '".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1550 'object' => 'MyObject'
1552 \$this->menu[\$r++] = array(
1553 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1555 'titre' => 'List MyObject',
1556 'mainmenu' => 'mymodule',
1557 'leftmenu' => 'mymodule_myobject_list',
1558 'url' => '/mymodule/myobject_list.php',
1559 'langs' => 'mymodule@mymodule',
1560 'position' => 1000 + \$r,
1561 'enabled' => 'isModEnabled(\"mymodule\")',
1562 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1565 'object' => 'MyObject'
1567 \$this->menu[\$r++] = array(
1568 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1570 'titre' => 'New MyObject',
1571 'mainmenu' => 'mymodule',
1572 'leftmenu' => 'mymodule_myobject_new',
1573 'url' => '/mymodule/myobject_card.php?action=create',
1574 'langs' => 'mymodule@mymodule',
1575 'position' => 1000 + \$r,
1576 'enabled' => 'isModEnabled(\"mymodule\")',
1577 'perms' => '".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1580 'object' => 'MyObject'
1582 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1583 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1584 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1586 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1592 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1594 $class =
'mod'.$module;
1596 if (class_exists($class)) {
1599 '@phan-var-force DolibarrModules $moduleobj';
1612 foreach ($menus as $menu) {
1613 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1619 if ($checkComment < 0) {
1621 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1623 $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 */');
1628 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1633 foreach ($filetogenerate as $destfile) {
1634 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1637 $arrayreplacement = array(
1638 'mymodule' => strtolower($module),
1639 'MyModule' => $module,
1640 'MYMODULE' => strtoupper($module),
1641 'My module' => $module,
1642 'my module' => $module,
1643 'mon module' => $module,
1644 'Mon module' => $module,
1645 'htdocs/modulebuilder/template/' => strtolower($modulename),
1646 'myobject' => strtolower($objectname),
1647 'MyObject' => $objectname,
1649 '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now)
1653 $arrayreplacement[
'---Replace with your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1659 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1668 if (is_numeric($object) && $object <= 0) {
1669 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1670 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1674 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1675 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1677 if (file_exists($destfile)) {
1683 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1692 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1693 $tabobj = $objectname;
1695 $tabobj =
'newobject';
1699 if (isModEnabled(strtolower($module))) {
1705 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1706 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1712if ($dirins && $action ==
'initdic' && $module && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
1713 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1714 $destdir = $dirins.
'/'.strtolower($module);
1715 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1719 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1723 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1726 $newdicname = $dicname;
1727 if (!preg_match(
'/^c_/', $newdicname)) {
1728 $newdicname =
'c_'.$dicname;
1731 $class =
'mod'.$module;
1733 if (class_exists($class)) {
1736 '@phan-var-force DolibarrModules $moduleobj';
1744 $langs->load(
"errors");
1745 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1750 if ($checkComment < 0) {
1751 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1754 if (function_exists(
'opcache_invalidate')) {
1757 clearstatcache(
true);
1758 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1765if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj) && $user->hasRight(
"modulebuilder",
"run")) {
1766 $objectname = $tabobj;
1768 $arrayoftables = array();
1769 if ($action ==
'droptable') {
1770 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1772 if ($action ==
'droptableextrafields') {
1773 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1776 foreach ($arrayoftables as $tabletodrop) {
1778 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1779 $resql = $db->query($sql);
1781 $obj = $db->fetch_object($resql);
1786 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1787 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1793 $resql = $db->DDLDropTable($tabletodrop);
1795 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1796 } elseif ($nb > 0) {
1797 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1802if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj'))) && $user->hasRight(
"modulebuilder",
"run")) {
1807 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1808 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1810 $srcdir = $dirread.
'/'.strtolower($module);
1811 $destdir = $dirins.
'/'.strtolower($module);
1815 if (!in_array($objectname, array_values($objects))) {
1817 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1820 $addfieldentry = array();
1823 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1824 if (!
GETPOST(
'propname',
'aZ09')) {
1826 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1828 if (!
GETPOST(
'proplabel',
'alpha')) {
1830 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1832 if (!
GETPOST(
'proptype',
'alpha')) {
1834 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1838 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1839 $addfieldentry = array(
1840 'name' =>
GETPOST(
'propname',
'aZ09'),
1841 'label' =>
GETPOST(
'proplabel',
'alpha'),
1842 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1843 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'alphawithlgt'),
1844 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1845 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1849 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1851 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1852 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1853 'help' =>
GETPOST(
'prophelp',
'alpha'),
1854 'css' =>
GETPOST(
'propcss',
'alpha'),
1855 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1856 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1857 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1858 'noteditable' =>
GETPOSTINT(
'propnoteditable'),
1863 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1864 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1866 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1869 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1881 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1887 if (is_numeric($object) && $object <= 0) {
1888 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1889 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1896 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1899 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1905 clearstatcache(
true);
1907 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1912 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1917if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey && $user->hasRight(
"modulebuilder",
"run")) {
1918 $objectname = $tabobj;
1920 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1921 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1923 $srcdir = $dirread.
'/'.strtolower($module);
1924 $destdir = $dirins.
'/'.strtolower($module);
1931 if (is_numeric($object) && $object <= 0) {
1932 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1933 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1940 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1943 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1949 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1951 clearstatcache(
true);
1954 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1959if ($dirins && $action ==
'confirm_deletemodule' && $user->hasRight(
"modulebuilder",
"run")) {
1960 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1962 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1966 $modulelowercase = strtolower($module);
1969 $dir = $dirins.
'/'.$modulelowercase;
1971 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1981 $class =
'mod'.$module;
1985 if (class_exists($class)) {
1988 '@phan-var-force DolibarrModules $moduleobj';
1996 $langs->load(
"errors");
1997 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
2009 clearstatcache(
true);
2010 if (function_exists(
'opcache_invalidate')) {
2014 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
2022 $module =
'deletemodule';
2025if ($dirins && $action ==
'confirm_deleteobject' && $objectname && $user->hasRight(
"modulebuilder",
"run")) {
2026 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
2028 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2032 $modulelowercase = strtolower($module);
2033 $objectlowercase = strtolower($objectname);
2036 $dir = $dirins.
'/'.$modulelowercase;
2039 $filetodelete = array(
2040 'myobject_card.php' => strtolower($objectname).
'_card.php',
2041 'myobject_note.php' => strtolower($objectname).
'_note.php',
2042 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
2043 'myobject_document.php' => strtolower($objectname).
'_document.php',
2044 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
2045 'myobject_list.php' => strtolower($objectname).
'_list.php',
2046 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
2047 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
2048 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
2049 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
2050 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
2051 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
2052 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
2053 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
2054 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
2055 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
2056 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
2057 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
2058 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2059 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2060 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2065 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2067 $class =
'mod'.$module;
2069 if (class_exists($class)) {
2072 '@phan-var-force DolibarrModules $moduleobj';
2080 $langs->load(
"errors");
2081 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2084 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2090 if ($rewriteMenu < 0) {
2091 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2093 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2099 if ($rewritePerms < 0) {
2100 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2104 if ($rewritePerms && $rewriteMenu) {
2106 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2109 clearstatcache(
true);
2110 if (function_exists(
'opcache_invalidate')) {
2114 foreach ($filetodelete as $tmpfiletodelete) {
2116 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2122 if ($resultko == 0) {
2125 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2132 $tabobj =
'newobject';
2134 $tabobj =
'deleteobject';
2138 if (isModEnabled(strtolower($module))) {
2144 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2145 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2150if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey')) && $user->hasRight(
"modulebuilder",
"run")) {
2151 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2152 $destdir = $dirins.
'/'.strtolower($module);
2153 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2155 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2157 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2160 if (!empty($dicname)) {
2161 $newdicname = $dicname;
2162 if (!preg_match(
'/^c_/', $newdicname)) {
2163 $newdicname =
'c_'.strtolower($dicname);
2170 $class =
'mod'.$module;
2172 if (class_exists($class)) {
2175 '@phan-var-force DolibarrModules $moduleobj';
2183 $langs->load(
"errors");
2184 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2190 if ($checkComment < 0) {
2192 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2195 if (!empty(
GETPOST(
'dictionnarykey'))) {
2196 $newdicname = $dicts[
'tabname'][
GETPOSTINT(
'dictionnarykey') - 1];
2200 $checkTable =
false;
2201 if ($newdicname !==
null) {
2202 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2205 if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) {
2210 $keyToDelete =
null;
2211 foreach ($dicts[
'tabname'] as $key => $table) {
2213 if (strtolower($table) === $newdicname) {
2214 $keyToDelete = $key;
2219 if ($keyToDelete !==
null) {
2220 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2221 foreach ($keysToDelete as $key) {
2222 unset($dicts[$key][$keyToDelete]);
2226 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2228 if (!$error && $newdicname !==
null) {
2230 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2231 if ($_results < 0) {
2233 $langs->load(
"errors");
2234 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2239 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2241 if (function_exists(
'opcache_invalidate')) {
2244 clearstatcache(
true);
2245 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2249if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey') && $user->hasRight(
"modulebuilder",
"run")) {
2250 $keydict =
GETPOSTINT(
'dictionnarykey') - 1 ;
2252 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2253 $destdir = $dirins.
'/'.strtolower($module);
2254 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2256 $class =
'mod'.$module;
2258 if (class_exists($class)) {
2261 '@phan-var-force DolibarrModules $moduleobj';
2269 $langs->load(
"errors");
2270 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2275 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2276 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2278 if ($checkComment < 0) {
2279 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2282 if ($updateDict > 0) {
2285 if (function_exists(
'opcache_invalidate')) {
2288 clearstatcache(
true);
2289 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2295if ($dirins && $action ==
'generatedoc' && $user->hasRight(
"modulebuilder",
"run")) {
2296 $modulelowercase = strtolower($module);
2301 $FILENAMEDOC = strtolower($module).
'.html';
2303 $util =
new Utils($db);
2304 $result = $util->generateDoc($module);
2307 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2313if ($dirins && $action ==
'generatepackage' && $user->hasRight(
"modulebuilder",
"run")) {
2314 $modulelowercase = strtolower($module);
2316 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2326 $class =
'mod'.$module;
2328 if (class_exists($class)) {
2331 '@phan-var-force DolibarrModules $moduleobj';
2339 $langs->load(
"errors");
2340 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2344 $arrayversion = explode(
'.',
$moduleobj->version, 3);
2345 if (count($arrayversion)) {
2346 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2349 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2355 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2361 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2364 $langs->load(
"errors");
2365 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2369 $langs->load(
"errors");
2370 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2375if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2379 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2381 $class =
'mod'.$module;
2383 if (class_exists($class)) {
2386 '@phan-var-force DolibarrModules $moduleobj';
2395 if (!
GETPOST(
'label',
'alpha')) {
2397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2399 if (!
GETPOST(
'permissionObj',
'alpha')) {
2401 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2405 $label =
GETPOST(
'label',
'alpha');
2406 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2407 $crud =
GETPOST(
'crud',
'alpha');
2411 $permsForObject = array();
2415 $permissions = array();
2417 $allObject = array();
2419 $countPerms = count($permissions);
2421 for ($i = 0; $i < $countPerms; $i++) {
2422 if ($permissions[$i][4] == $objectForPerms) {
2424 if (count($permsForObject) < 3) {
2425 $permsForObject[] = $permissions[$i];
2428 $allObject[] = $permissions[$i][4];
2432 $countPermsObj = count($permsForObject);
2433 for ($j = 0; $j < $countPermsObj; $j++) {
2434 if (in_array($crud, $permsForObject[$j])) {
2436 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2440 $rightToAdd = array();
2442 $key = $countPerms + 1;
2444 $rightToAdd = array(
2447 4 => $objectForPerms,
2451 if (isModEnabled(strtolower($module))) {
2457 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2460 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2464 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2469 clearstatcache(
true);
2470 if (function_exists(
'opcache_invalidate')) {
2473 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2480if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2483 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2485 $class =
'mod'.$module;
2487 if (class_exists($class)) {
2490 '@phan-var-force DolibarrModules $moduleobj';
2498 if (!
GETPOST(
'label',
'alpha')) {
2500 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2502 if (!
GETPOST(
'permissionObj',
'alpha')) {
2504 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2507 $label =
GETPOST(
'label',
'alpha');
2508 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2509 $crud =
GETPOST(
'crud',
'alpha');
2512 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2516 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2520 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2532 if (array_key_exists($key, $permissions)) {
2533 $x1 = $permissions[$key][1];
2534 $x2 = $permissions[$key][4];
2535 $x3 = $permissions[$key][5];
2543 $permsForObject = array();
2547 $allObject = array();
2549 $countPerms = count($permissions);
2550 for ($i = 0; $i < $countPerms; $i++) {
2551 if ($permissions[$i][4] == $objectForPerms) {
2553 if (count($permsForObject) < 3) {
2554 $permsForObject[] = $permissions[$i];
2557 $allObject[] = $permissions[$i][4];
2560 if ($label != $x1 && $crud != $x3) {
2561 $countPermsObj = count($permsForObject);
2562 for ($j = 0; $j < $countPermsObj; $j++) {
2563 if (in_array($label, $permsForObject[$j])) {
2565 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2571 if (isModEnabled(strtolower($module))) {
2577 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2580 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2584 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2586 $rightUpdated =
null;
2589 clearstatcache(
true);
2590 if (function_exists(
'opcache_invalidate')) {
2593 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2599if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey') && $user->hasRight(
"modulebuilder",
"run")) {
2602 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2604 $class =
'mod'.$module;
2606 if (class_exists($class)) {
2609 '@phan-var-force DolibarrModules $moduleobj';
2622 if (isModEnabled(strtolower($module))) {
2628 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2629 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2634 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2637 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2642 clearstatcache(
true);
2643 if (function_exists(
'opcache_invalidate')) {
2647 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2653if ($action ==
'savefile' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2654 $relofcustom = basename($dirins);
2658 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2659 $file = $relofcustom.
'/'.$file;
2667 dol_copy($pathoffile, $pathoffilebackup,
'0', 1);
2670 $check =
'restricthtml';
2672 if ($srclang ==
'md') {
2673 $check =
'restricthtml';
2675 if ($srclang ==
'lang') {
2676 $check =
'restricthtml';
2678 if ($srclang ==
'php') {
2682 $content =
GETPOST(
'editfilecontent', $check);
2687 $result = file_put_contents($pathoffile, $content);
2704if ($action ==
'set' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2707 $param .=
'&module='.urlencode($module);
2710 $param .=
'&tab='.urlencode($tab);
2713 $param .=
'&tabobj='.urlencode($tabobj);
2716 $value =
GETPOST(
'value',
'alpha');
2718 if (!empty($resarray[
'errors'])) {
2722 if ($resarray[
'nbperms'] > 0) {
2723 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2724 $resqltmp = $db->query($tmpsql);
2726 $obj = $db->fetch_object($resqltmp);
2728 if ($obj && $obj->nb > 1) {
2729 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2737 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2742if ($action ==
'reset' && $user->admin && $user->hasRight(
"modulebuilder",
"run")) {
2745 $param .=
'&module='.urlencode($module);
2748 $param .=
'&tab='.urlencode($tab);
2751 $param .=
'&tabobj='.urlencode($tabobj);
2754 $value =
GETPOST(
'value',
'alpha');
2759 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2764if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey') && $user->hasRight(
"modulebuilder",
"run")) {
2766 if (isModEnabled(strtolower($module))) {
2772 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2773 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2777 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2779 $class =
'mod'.$module;
2781 if (class_exists($class)) {
2784 '@phan-var-force DolibarrModules $moduleobj';
2792 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2793 $destdir = $dir.
'/'.strtolower($module);
2795 $result = array_map(
'strtolower', $objects);
2799 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2802 if ($checkcomment < 0) {
2803 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2805 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2806 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2807 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2815 clearstatcache(
true);
2816 if (function_exists(
'opcache_invalidate')) {
2821 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2827if ($dirins && $action ==
'addmenu' && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
2829 if (isModEnabled(strtolower($module))) {
2835 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2836 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2842 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2844 $class =
'mod'.$module;
2846 if (class_exists($class)) {
2849 '@phan-var-force DolibarrModules $moduleobj';
2860 if (!
GETPOST(
'type',
'alpha')) {
2862 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2864 if (!
GETPOST(
'titre',
'alpha')) {
2866 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2868 if (!
GETPOST(
'user',
'alpha')) {
2870 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2872 if (!
GETPOST(
'url',
'alpha')) {
2874 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2876 if (!empty(
GETPOST(
'target'))) {
2877 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2878 if (!in_array(
GETPOST(
'target'), $targets)) {
2880 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2887 foreach ($menus as $menu) {
2890 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2893 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2895 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2900 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2901 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2903 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2906 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2907 $destdir = $dirins.
'/'.strtolower($module);
2910 if (
GETPOST(
'type',
'alpha') ==
'left') {
2911 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2913 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2916 if (
GETPOST(
'type',
'alpha') ==
'top') {
2918 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2921 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2925 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2926 'type' =>
GETPOST(
'type',
'alpha'),
2927 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2929 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2930 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2931 'url' =>
GETPOST(
'url',
'alpha'),
2932 'langs' => strtolower($module).
"@".strtolower($module),
2934 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2935 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2936 'target' =>
GETPOST(
'target',
'alpha'),
2940 if (
GETPOST(
'type') ==
'left') {
2941 unset($menuToAdd[
'prefix']);
2942 if (empty(
GETPOST(
'fk_menu'))) {
2943 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2945 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2948 if (
GETPOST(
'enabled') ==
'1') {
2949 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2951 $menuToAdd[
'enabled'] =
"0";
2953 if (empty(
GETPOST(
'objects'))) {
2954 $menuToAdd[
'perms'] =
'1';
2958 if ($checkcomment < 0) {
2959 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2962 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2964 clearstatcache(
true);
2965 if (function_exists(
'opcache_invalidate')) {
2974 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2982if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj') && $user->hasRight(
"modulebuilder",
"run")) {
2983 $objectname =
GETPOST(
'tabobj');
2984 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2985 $destdir = $dirins.
'/'.strtolower($module);
2988 if (empty($cancel)) {
2989 if (isModEnabled(strtolower($module))) {
2995 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2996 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3001 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3003 $class =
'mod'.$module;
3005 if (class_exists($class)) {
3008 '@phan-var-force DolibarrModules $moduleobj';
3018 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3020 $menuModify = array(
3021 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
3022 'type' =>
GETPOST(
'type',
'alpha'),
3023 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
3025 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
3026 'leftmenu' => $menus[$key][
'leftmenu'],
3027 'url' =>
GETPOST(
'url',
'alpha'),
3028 'langs' => strtolower($module).
"@".strtolower($module),
3030 'enabled' =>
GETPOST(
'enabled',
'alpha'),
3031 'perms' =>
GETPOST(
'perms',
'alpha'),
3032 'target' =>
GETPOST(
'target',
'alpha'),
3035 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
3036 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
3037 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
3038 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
3040 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
3042 if ($menuModify[
'enabled'] ===
'') {
3043 $menuModify[
'enabled'] =
'1';
3045 if ($menuModify[
'perms'] ===
'') {
3046 $menuModify[
'perms'] =
'1';
3049 if (
GETPOST(
'type',
'alpha') ==
'top') {
3051 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
3058 if ($checkComment < 0) {
3059 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
3062 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
3064 clearstatcache(
true);
3065 if (function_exists(
'opcache_invalidate')) {
3072 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));
3077 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3082 $_POST[
'type'] =
'';
3083 $_POST[
'titre'] =
'';
3084 $_POST[
'fk_menu'] =
'';
3085 $_POST[
'leftmenu'] =
'';
3091if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel) && $user->hasRight(
"modulebuilder",
"run")) {
3092 if (isModEnabled(strtolower($module))) {
3098 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
3099 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
3102 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3103 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
3104 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
3108 $class =
'mod'.$module;
3110 if (class_exists($class)) {
3113 '@phan-var-force DolibarrModules $moduleobj';
3121 $keydescription =
GETPOST(
'keydescription',
'alpha');
3122 switch ($keydescription) {
3124 $propertyToUpdate =
'description';
3131 $propertyToUpdate = $keydescription;
3134 $error =
GETPOST(
'keydescription');
3138 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3139 $newValue =
GETPOST(
'propsmodule');
3140 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3141 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3144 if ($propertyToUpdate ===
'version') {
3148 $fileLines = file($moduledescriptorfile);
3149 foreach ($fileLines as &$line) {
3150 if (strpos($line, $lineToReplace) === 0) {
3156 clearstatcache(
true);
3157 if (function_exists(
'opcache_invalidate')) {
3160 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3161 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3171$form =
new Form($db);
3182 '/includes/ace/src/ace.js',
3183 '/includes/ace/src/ext-statusbar.js',
3184 '/includes/ace/src/ext-language_tools.js',
3189llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3192$text = $langs->trans(
"ModuleBuilder");
3196print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
3197print
'<br class="hideonsmartphone">';
3206 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3211 $langs->load(
"errors");
3212 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3216 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3225$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3229$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3230$allowonlineinstall =
true;
3231if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3232 $allowonlineinstall =
false;
3234if (empty($allowonlineinstall)) {
3237 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3240 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0,
'1',
'warning');
3255if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3256 $modulelowercase = strtolower($module);
3257 $loadclasserrormessage =
'';
3261 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3266 $class =
'mod'.$module;
3267 }
catch (Throwable $e) {
3268 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3269 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3270 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3274 if (class_exists($class)) {
3277 '@phan-var-force DolibarrModules $moduleobj';
3281 print $e->getMessage();
3284 if (empty($forceddirread)) {
3287 $langs->load(
"errors");
3288 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3289 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3290 print $loadclasserrormessage;
3301$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3302$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3303$head[$h][2] =
'initmodule';
3306$linktoenabledisable =
'';
3308if (is_array($listofmodules) && count($listofmodules) > 0) {
3310 $modulelowercase = strtolower($module);
3314 $param .=
'&tab='.urlencode($tab);
3317 $param .=
'&module='.urlencode($module);
3320 $param .=
'&tabobj='.urlencode($tabobj);
3323 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3326 if (isModEnabled($modulelowercase)) {
3327 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3328 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'', 0, 0, 0,
'',
'', 1);
3329 $linktoenabledisable .=
'</a>';
3331 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3334 $backtourlparam =
'';
3335 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3337 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3339 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3342 if (is_array($objMod->config_page_url)) {
3344 foreach ($objMod->config_page_url as $page) {
3347 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3350 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3351 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3352 $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>';
3356 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3357 $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>';
3361 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3362 $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>';
3366 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3367 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"', 0, 0, 0,
'',
'classfortooltip', 1);
3368 $linktoenabledisable .=
"</a>\n";
3373 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3374 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3375 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3376 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3378 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3379 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3386$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3387$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3388$head[$h][2] =
'deletemodule';
3394if ($module ==
'initmodule') {
3396 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3397 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3398 print
'<input type="hidden" name="action" value="initmodule">';
3399 print
'<input type="hidden" name="module" value="initmodule">';
3404 print
'<div class="tagtable">';
3406 print
'<div class="tagtr"><div class="tagtd paddingright">';
3407 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3408 print
'</div><div class="tagtd">';
3409 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
3410 print
'<span class="opacitymedium">';
3412 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3414 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3417 print
'</div></div>';
3419 print
'<div class="tagtr"><div class="tagtd paddingright">';
3420 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3421 print
'</div><div class="tagtd">';
3422 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3423 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3424 print
'</div></div>';
3426 print
'<div class="tagtr"><div class="tagtd paddingright">';
3427 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3428 print
'</div><div class="tagtd">';
3429 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3430 print
'</div></div>';
3432 print
'<div class="tagtr"><div class="tagtd paddingright">';
3433 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3434 print
'</div><div class="tagtd">';
3435 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")).
'">';
3436 print
'</div></div>';
3438 print
'<div class="tagtr"><div class="tagtd paddingright">';
3439 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3440 print
'</div><div class="tagtd">';
3441 print
'<select name="family" id="family" class="minwidth400">';
3442 $arrayoffamilies = array(
3443 'hr' =>
"ModuleFamilyHr",
3444 'crm' =>
"ModuleFamilyCrm",
3445 'srm' =>
"ModuleFamilySrm",
3446 'financial' =>
'ModuleFamilyFinancial',
3447 'products' =>
'ModuleFamilyProducts',
3448 'projects' =>
'ModuleFamilyProjects',
3449 'ecm' =>
'ModuleFamilyECM',
3450 'technic' =>
'ModuleFamilyTechnic',
3451 'portal' =>
'ModuleFamilyPortal',
3452 'interface' =>
'ModuleFamilyInterface',
3453 'base' =>
'ModuleFamilyBase',
3454 'other' =>
'ModuleFamilyOther'
3456 foreach ($arrayoffamilies as $key => $value) {
3457 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>';
3461 print
'</div></div>';
3463 print
'<div class="tagtr"><div class="tagtd paddingright">';
3464 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3465 print
'</div><div class="tagtd">';
3466 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3467 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3468 print
'</div></div>';
3470 print
'<div class="tagtr"><div class="tagtd paddingright">';
3471 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3472 print
'</div><div class="tagtd">';
3473 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>';
3474 print
'</div></div>';
3476 print
'<div class="tagtr"><div class="tagtd paddingright">';
3477 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3478 print
'</div><div class="tagtd">';
3479 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>';
3480 print
'</div></div>';
3482 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3484} elseif ($module ==
'deletemodule') {
3485 print
'<!-- Form to init a module -->'.
"\n";
3486 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3487 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3488 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3489 print
'<input type="hidden" name="module" value="deletemodule">';
3491 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3493 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3494 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3496} elseif (!empty($module) && isset($modulelowercase)) {
3499 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3500 $destdir = $dirread.
'/'.strtolower($module);
3504 $countDictionaries = (!empty(
$moduleobj->dictionaries) ? count(
$moduleobj->dictionaries[
'tabname']) : 0);
3518 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3519 $head2[$h][1] = $langs->trans(
"Description");
3520 $head2[$h][2] =
'description';
3523 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3524 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3525 $head2[$h][2] =
'objects';
3528 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3529 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3530 $head2[$h][2] =
'languages';
3533 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3534 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3535 $head2[$h][2] =
'dictionaries';
3538 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3539 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3540 $head2[$h][2] =
'permissions';
3543 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3544 $head2[$h][1] = $langs->trans(
"Tabs");
3545 $head2[$h][2] =
'tabs';
3548 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3549 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3550 $head2[$h][2] =
'menus';
3553 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3554 $head2[$h][1] = $langs->trans(
"Hooks");
3555 $head2[$h][2] =
'hooks';
3558 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3559 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3560 $head2[$h][2] =
'triggers';
3563 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3564 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3565 $head2[$h][2] =
'widgets';
3568 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3569 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3570 $head2[$h][2] =
'emailings';
3573 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3574 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3575 $head2[$h][2] =
'exportimport';
3578 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3579 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3580 $head2[$h][2] =
'css';
3583 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3584 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3585 $head2[$h][2] =
'js';
3588 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3589 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3590 $head2[$h][2] =
'cli';
3593 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3594 $head2[$h][1] = $langs->trans(
"CronList");
3595 $head2[$h][2] =
'cron';
3598 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3599 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="paddingleft badge">'.$hasDoc.
"</span>");
3600 $head2[$h][2] =
'specifications';
3603 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3604 $head2[$h][1] = $langs->trans(
"BuildPackage");
3605 $head2[$h][2] =
'buildpackage';
3608 $MAXTABFOROBJECT = 15;
3610 print
'<!-- Section for a given module -->';
3614 if ($tab ==
'description') {
3615 print
'<!-- tab=description -->'.
"\n";
3616 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3617 $pathtofilereadme = $modulelowercase.
'/README.md';
3618 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3620 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3622 if ($action !=
'editfile' || empty($file)) {
3623 $morehtmlright =
'';
3624 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3625 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3628 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3630 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3636 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3637 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>';
3641 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3642 foreach ($listofsetuppages as $setuppage) {
3645 print
'<span class="fa fa-file"></span> ';
3646 if ($setuppage[
'relativename'] ==
'about.php') {
3647 print $langs->trans(
"AboutFile");
3649 print $langs->trans(
"SetupFile");
3652 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3653 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>';
3657 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3658 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>';
3661 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3662 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>';
3668 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3671 print
'<div class="underbanner clearboth"></div>';
3672 print
'<div class="fichecenter">';
3673 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3674 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3675 print
'<input type="hidden" name="action" value="update_props_module">';
3676 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3677 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3678 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3679 print
'<table class="border centpercent">';
3680 print
'<tr class="liste_titre"><td class="titlefield">';
3681 print $langs->trans(
"Parameter");
3683 print $langs->trans(
"Value");
3687 print $langs->trans(
"IdModule");
3690 print
'<span class="opacitymedium">';
3692 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3693 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3698 print $langs->trans(
"ModuleName");
3704 print $langs->trans(
"Description");
3706 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3707 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->description).
'">';
3708 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3709 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3712 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>';
3714 $moduledescritpionautotrans =
$moduleobj->getDesc();
3715 if ($moduledescritpionautotrans !=
"Module".
$moduleobj->name.
"Desc") {
3717 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3718 } elseif ($moduledescritpionautotrans !=
"Module".
$moduleobj->numero.
"Desc") {
3720 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3726 print $langs->trans(
"Version");
3728 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3729 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->getVersion()).
'">';
3730 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3731 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3734 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>';
3739 print $langs->trans(
"Family");
3742 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3743 print
'<select name="propsmodule" id="family" class="minwidth400">';
3744 $arrayoffamilies = array(
3745 'hr' =>
"ModuleFamilyHr",
3746 'crm' =>
"ModuleFamilyCrm",
3747 'srm' =>
"ModuleFamilySrm",
3748 'financial' =>
'ModuleFamilyFinancial',
3749 'products' =>
'ModuleFamilyProducts',
3750 'projects' =>
'ModuleFamilyProjects',
3751 'ecm' =>
'ModuleFamilyECM',
3752 'technic' =>
'ModuleFamilyTechnic',
3753 'portal' =>
'ModuleFamilyPortal',
3754 'interface' =>
'ModuleFamilyInterface',
3755 'base' =>
'ModuleFamilyBase',
3756 'other' =>
'ModuleFamilyOther'
3758 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>';
3759 foreach ($arrayoffamilies as $key => $value) {
3761 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3765 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3766 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3769 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>';
3774 print $langs->trans(
"Picto");
3776 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3777 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->picto).
'">';
3778 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3779 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3782 print
' '.img_picto(
'',
$moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3783 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>';
3788 print $langs->trans(
"EditorName");
3790 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3791 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_name).
'">';
3792 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3793 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3796 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>';
3801 print $langs->trans(
"EditorUrl");
3803 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3804 print
'<input name="propsmodule" value="'.dol_escape_htmltag(
$moduleobj->editor_url).
'">';
3805 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3806 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3809 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.
$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3811 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>';
3818 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3825 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3827 print
'<!-- readme file -->';
3828 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3829 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3831 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3837 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3839 print
'<!-- changelog file -->';
3841 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3843 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3851 if ($fullpathoffile) {
3852 $content = file_get_contents($fullpathoffile);
3856 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3857 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3858 print
'<input type="hidden" name="action" value="savefile">';
3859 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3860 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3861 print
'<input type="hidden" name="module" value="'.$module.
'">';
3865 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
3866 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3867 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3872 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3874 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3880 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3883 if ($tab ==
'languages') {
3884 print
'<!-- tab=languages -->'.
"\n";
3885 if ($action !=
'editfile' || empty($file)) {
3886 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3890 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3891 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3892 print
'<input type="hidden" name="action" value="addlanguage">';
3893 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3894 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3895 print
'<input type="hidden" name="module" value="'.$module.
'">';
3896 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, array(), 1, 0, 0,
'minwidth300', 1);
3897 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3903 $modulelowercase = strtolower($module);
3907 $diroflang .=
'/langs';
3908 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3910 if (!preg_match(
'/custom/', $dirread)) {
3912 $diroflang = $dirread;
3913 $diroflang .=
'/langs';
3914 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3917 print
'<table class="none">';
3918 foreach ($langfiles as $langfile) {
3919 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3920 if (!preg_match(
'/custom/', $dirread)) {
3921 $pathtofile =
'langs/'.$langfile[
'relativename'];
3923 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3924 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>';
3925 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>';
3936 $content = file_get_contents($fullpathoffile);
3939 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3940 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3941 print
'<input type="hidden" name="action" value="savefile">';
3942 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3943 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3944 print
'<input type="hidden" name="module" value="'.$module.
'">';
3946 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3947 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3950 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3952 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3959 if ($tab ==
'objects') {
3960 print
'<!-- tab=objects -->'.
"\n";
3965 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3967 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3968 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3969 $head3[$h][2] =
'newobject';
3973 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3975 $firstobjectname =
'';
3976 foreach ($listofobject as $fileobj) {
3977 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3980 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3984 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3985 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3987 $objectname = $reg[1];
3988 if (empty($firstobjectname)) {
3989 $firstobjectname = $objectname;
3991 $pictoname =
'generic';
3992 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3993 $pictoname = $reg[1];
3996 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3997 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3998 $head3[$h][2] = $objectname;
4004 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
4005 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
4006 $head3[$h][2] =
'deleteobject';
4011 if ($tabobj ==
'newobjectifnoobj') {
4012 if ($firstobjectname) {
4013 $tabobj = $firstobjectname;
4015 $tabobj =
'newobject';
4019 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
4022 if ($tabobj ==
'newobject') {
4024 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4025 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4026 print
'<input type="hidden" name="action" value="initobject">';
4027 print
'<input type="hidden" name="tab" value="objects">';
4028 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4030 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
4032 print
'<div class="tagtable">';
4034 print
'<div class="tagtr"><div class="tagtd">';
4035 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
4036 print
'</div><div class="tagtd">';
4037 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
4038 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
4039 print
'</div></div>';
4041 print
'<div class="tagtr"><div class="tagtd">';
4042 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
4043 print
'</div><div class="tagtd">';
4044 print
'<input type="text" name="idpicto" value="fa-file" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
4045 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
4046 print
'</div></div>';
4048 print
'<div class="tagtr"><div class="tagtd">';
4049 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
4050 print
'</div><div class="tagtd">';
4051 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
4052 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
4053 print
'</div></div>';
4058 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>';
4059 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
4060 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
4062 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4078 } elseif ($tabobj ==
'createproperty') {
4079 $attributesUnique = array(
4080 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
4081 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
4082 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
4083 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
4084 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
4085 'propdefault' => $langs->trans(
"DefaultValue"),
4086 'propindex' => $langs->trans(
"DatabaseIndex"),
4087 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
4088 'propposition' => $langs->trans(
"Position"),
4089 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
4090 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
4091 'propnoteditable' => $langs->trans(
"NotEditable"),
4093 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
4094 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
4095 'propcss' => $langs->trans(
"CSSClass"),
4096 'propcssview' => $langs->trans(
"CSSViewClass"),
4097 'propcsslist' => $langs->trans(
"CSSListClass"),
4098 'prophelp' => $langs->trans(
"KeyForTooltip"),
4099 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
4101 'propcomment' => $langs->trans(
"Comment"),
4103 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
4104 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4105 print
'<input type="hidden" name="action" value="addproperty">';
4106 print
'<input type="hidden" name="tab" value="objects">';
4107 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4108 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
4110 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
4112 foreach ($attributesUnique as $key => $attribute) {
4113 if ($counter % 2 === 0) {
4116 if ($key ==
'propname' || $key ==
'proplabel') {
4117 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>';
4118 } elseif ($key ==
'proptype') {
4119 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
4120 print
'<input class="maxwidth200" id="'.$key.
'" list="datalist'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
4122 print
'<datalist id="datalist'.$key.
'">';
4123 print
'<option>varchar(128)</option>';
4124 print
'<option>email</option>';
4125 print
'<option>phone</option>';
4126 print
'<option>ip</option>';
4127 print
'<option>url</option>';
4128 print
'<option>password</option>';
4129 print
'<option>text</option>';
4130 print
'<option>html</option>';
4131 print
'<option>date</option>';
4132 print
'<option>datetime</option>';
4133 print
'<option>integer</option>';
4134 print
'<option>stars(5)</option>';
4135 print
'<option>double(28,4)</option>';
4136 print
'<option>real</option>';
4137 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4146 print
'</datalist>';
4150 } elseif ($key ==
'propvisible') {
4151 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>';
4152 } elseif ($key ==
'propenabled') {
4155 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>';
4156 } elseif ($key ==
'proparrayofkeyval') {
4157 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>';
4159 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>';
4162 if ($counter % 2 === 0) {
4166 if ($counter % 2 !== 0) {
4167 while ($counter % 2 !== 0) {
4173 print
'</table><br>'.
"\n";
4174 print
'<div class="center">';
4175 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4176 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4182 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4183 window.location.href = url;
4185 $(document).ready(function() {
4186 $("#proplabel").on("keyup", function() {
4187 console.log("key up on label");
4188 s = cleanString($("#proplabel").val());
4189 $("#propname").val(s);
4192 function cleanString( stringtoclean )
4194 // allow "a-z", "A-Z", "0-9" and "_"
4195 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4196 stringtoclean = stringtoclean.toLowerCase();
4197 if (!isNaN(stringtoclean)) {
4200 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4201 stringtoclean = stringtoclean.substr(1)
4203 if (stringtoclean.length > 28) {
4204 stringtoclean = stringtoclean.substring(0, 27);
4206 return stringtoclean;
4211 } elseif ($tabobj ==
'deleteobject') {
4213 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4215 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4216 print
'<input type="hidden" name="tab" value="objects">';
4217 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4218 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4220 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4222 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4223 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4227 if ($action ==
'deleteproperty') {
4228 $formconfirm = $form->formconfirm(
4229 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4230 $langs->trans(
'Delete'),
4231 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4232 'confirm_deleteproperty',
4241 if ($action !=
'editfile' || empty($file)) {
4245 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4246 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4247 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4248 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4249 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4250 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4251 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4252 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4253 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4256 clearstatcache(
true);
4257 if (function_exists(
'opcache_invalidate')) {
4258 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4261 if (empty($forceddirread) && empty($dirread)) {
4263 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4265 $result = include_once $dirread.
'/'.$pathtoclass;
4266 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4269 if (class_exists($tabobj)) {
4271 $tmpobject = @
new $tabobj($db);
4273 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4276 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4280 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4283 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4286 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4289 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4292 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4293 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4296 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4299 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4302 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4305 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4307 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4309 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4310 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4312 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4313 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4315 $tmpobject = $tmpobject ??
null;
4316 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4317 $pathtopicto = $tmpobject->picto;
4318 $realpathtopicto =
'';
4320 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4321 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4326 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4327 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4328 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4329 $realpathtocard = $dirread.
'/'.$pathtocard;
4330 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4331 $realpathtolist = $dirread.
'/'.$pathtolist;
4332 $realpathtonote = $dirread.
'/'.$pathtonote;
4333 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4334 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4335 $realpathtosql = $dirread.
'/'.$pathtosql;
4336 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4337 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4338 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4339 $realpathtolib = $dirread.
'/'.$pathtolib;
4340 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4342 if (empty($realpathtoapi)) {
4343 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4344 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4352 print
'<!-- section for object -->';
4353 print
'<div class="fichehalfleft smallxxx">';
4355 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>';
4356 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>';
4359 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4360 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>';
4363 } elseif (!empty($tmpobject)) {
4364 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4370 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>';
4372 $file = file_get_contents($realpathtoapi);
4373 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4374 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>';
4376 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>';
4377 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4380 if ($modulelowercase !==
null && !isModEnabled($modulelowercase)) {
4381 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4383 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4386 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>';
4389 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>';
4393 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>';
4395 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>';
4397 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>';
4399 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>';
4405 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>';
4406 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>';
4408 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>';
4409 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>';
4413 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>';
4414 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>';
4415 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>';
4418 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>';
4419 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>';
4422 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>';
4424 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>';
4426 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4428 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>';
4430 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>';
4434 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>';
4436 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>';
4438 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>';
4440 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>';
4445 print
'<div class="fichehalfleft smallxxxx">';
4446 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>';
4447 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>';
4449 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>';
4450 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>';
4453 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>';
4454 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>';
4457 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>';
4459 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>';
4463 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>';
4464 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>';
4467 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>';
4469 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>';
4473 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>';
4474 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4477 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>';
4479 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>';
4483 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>';
4484 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>';
4487 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>';
4489 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>';
4496 print
'<br><br><br>';
4498 if (!empty($tmpobject)) {
4499 $reflector =
new ReflectionClass($tabobj);
4500 $reflectorproperties = $reflector->getProperties();
4501 $reflectorpropdefault = $reflector->getDefaultProperties();
4505 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4506 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4507 print
'<input type="hidden" name="action" value="addproperty">';
4508 print
'<input type="hidden" name="tab" value="objects">';
4509 print
'<input type="hidden" name="page_y" value="">';
4510 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4511 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4513 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4514 print
'<br><br class="clearboth">';
4515 print
'<br class="clearboth">';
4517 $mod = strtolower($module);
4518 $obj = strtolower($tabobj);
4519 $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));
4520 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4522 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $nbOfProperties,
'', 0, $newproperty,
'margintoponly', 0, 0, 0, 1);
4525 print
'<!-- Table with properties of object -->'.
"\n";
4526 print
'<div class="div-table-responsive">';
4527 print
'<table class="noborder small">';
4528 print
'<tr class="liste_titre">';
4529 print
'<th class="tdsticky tdstickygray">';
4530 $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>';
4531 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4534 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4536 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4537 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4538 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4539 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4540 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4541 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4542 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4543 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4544 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4545 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4547 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4548 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4549 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4550 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4551 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4552 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4553 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4555 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4556 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4557 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4563 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4564 if (!empty($properties)) {
4566 foreach ($properties as $propkey => $propval) {
4581 $propname = $propkey;
4582 $proplabel = $propval[
'label'];
4583 $proptype = $propval[
'type'];
4584 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4585 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4586 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4587 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4588 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4589 $propposition = $propval[
'position'];
4590 $propenabled = $propval[
'enabled'];
4591 $propvisible = $propval[
'visible'];
4592 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4594 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4595 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4596 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4597 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4598 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4599 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4600 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4602 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4603 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4605 print
'<!-- line for object property -->'.
"\n";
4606 print
'<tr class="oddeven">';
4608 print
'<td class="tdsticky tdstickygray">';
4611 if ($action ==
'editproperty' && $propname == $propertykey) {
4613 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4614 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4616 print
'<td class="tdoverflowmax150">';
4617 print
'<input name="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'"></input>';
4619 print
'<td class="tdoverflowmax200">';
4620 print
'<textarea name="proparrayofkeyval">';
4621 if (isset($proparrayofkeyval)) {
4622 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4626 print
'</textarea>';
4629 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4632 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4634 print
'<td class="center">';
4635 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4638 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4641 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4644 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4647 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4650 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4656 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4659 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4662 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4665 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4668 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4671 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4674 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4677 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4680 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4682 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4683 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4684 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4687 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4690 print
'<td class="tdoverflowmax200">';
4693 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4694 $pictoType =
'varchar';
4695 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4696 $pictoType =
'link';
4697 } elseif (strpos($proptype,
'integer') === 0) {
4698 $pictoType = substr($proptype, 0, 3);
4699 } elseif (strpos($proptype,
'timestamp') === 0) {
4700 $pictoType =
'datetime';
4701 } elseif (strpos($proptype,
'real') === 0) {
4702 $pictoType =
'double';
4703 } elseif (strpos($proptype,
'stars') === 0) {
4704 $pictoType =
'stars';
4708 print
'<td class="tdoverflowmax200">';
4709 if ($proparrayofkeyval) {
4710 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4715 print
'<td class="center">';
4721 print
'<td class="center">';
4722 print $propindex ?
'1' :
'';
4724 print
'<td class="center">';
4727 print
'<td class="right">';
4730 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4734 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4738 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4744 print
'<td class="center">';
4745 print $propsearchall ?
'1' :
'';
4747 print
'<td class="center">';
4750 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4753 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4756 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4760 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4763 print
'<td class="center">';
4769 print
'<td class="center">';
4772 print
'<td class="tdoverflowmax200">';
4773 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4777 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4778 if ($propname !=
'rowid') {
4779 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>';
4780 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>';
4787 if ($tab ==
'specifications') {
4788 if ($action !=
'editfile' || empty($file)) {
4789 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4794 foreach ($specs as $spec) {
4795 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4796 $format =
'asciidoc';
4797 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4798 $format =
'markdown';
4800 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4801 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>';
4811 $content = file_get_contents($fullpathoffile);
4814 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4815 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4816 print
'<input type="hidden" name="action" value="savefile">';
4817 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4818 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4819 print
'<input type="hidden" name="module" value="'.$module.
'">';
4821 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4822 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4825 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4827 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4833 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>';
4840 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4844 print $e->getMessage();
4848 if (empty($forceddirread)) {
4851 $fullpathoffile = $dirread.
'/'.$file;
4854 $content = file_get_contents($fullpathoffile);
4857 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4858 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4859 print
'<input type="hidden" name="action" value="savefile">';
4860 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4861 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4862 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4863 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4865 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4866 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4869 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4871 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4881 if ($tab ==
'dictionaries') {
4882 print
'<!-- tab=dictionaries -->'.
"\n";
4883 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4887 if ($action ==
'deletedict') {
4888 $formconfirm = $form->formconfirm(
4889 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
4890 $langs->trans(
'Delete'),
4891 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
4892 'confirm_deletedictionary',
4900 if ($action !=
'editfile' || empty($file)) {
4901 print
'<span class="opacitymedium">';
4902 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4903 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4904 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4908 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4909 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>';
4911 if (is_array($dicts) && !empty($dicts)) {
4912 print
'<span class="fa fa-file"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4913 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
4924 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
4925 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4926 $head3[$h][2] =
'newdictionary';
4967 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).
'&tabdic=newdictionary');
4968 print_barre_liste($langs->trans(
"ListOfDictionariesEntries"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0,
'',
'', 0, $newdict,
'', 0, 0, 0, 1);
4970 if ($tabdic !=
'newdictionary') {
4971 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4972 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4973 print
'<input type="hidden" name="action" value="addDictionary">';
4974 print
'<input type="hidden" name="tab" value="dictionaries">';
4975 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4976 print
'<input type="hidden" name="tabdic" value="'.dol_escape_htmltag($tabdic).
'">';
4978 print
'<div class="div-table-responsive">';
4979 print
'<table class="noborder">';
4981 print
'<tr class="liste_titre">';
4982 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'thsticky thstickygrey ');
4995 if (!empty($dicts) && is_array($dicts) && !empty($dicts[
'tabname']) && is_array($dicts[
'tabname'])) {
4997 $maxi = count($dicts[
'tabname']);
4998 while ($i < $maxi) {
4999 if ($action ==
'editdict' && $i ==
GETPOSTINT(
'dictionnarykey') - 1) {
5000 print
'<tr class="oddeven">';
5001 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5002 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5003 print
'<input type="hidden" name="tab" value="dictionaries">';
5004 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5005 print
'<input type="hidden" name="action" value="updatedictionary">';
5006 print
'<input type="hidden" name="dictionnarykey" value="'.($i + 1).
'">';
5008 print
'<td class="tdsticky tdstickygray">';
5013 print
'<input type="text" name="tabname" value="'.$dicts[
'tabname'][$i].
'" readonly class="tdstickygray">';
5017 print
'<input type="text" name="tablib" value="'.$dicts[
'tablib'][$i].
'">';
5021 print
'<input type="text" name="tabsql" value="'.$dicts[
'tabsql'][$i].
'" readonly class="tdstickygray">';
5025 print
'<select name="tabsqlsort">';
5026 print
'<option value="'.dol_escape_htmltag($dicts[
'tabsqlsort'][$i]).
'">'.$dicts[
'tabsqlsort'][$i].
'</option>';
5030 print
'<td><select name="tabfield" >';
5031 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfield'][$i]).
'">'.$dicts[
'tabfield'][$i].
'</option>';
5032 print
'</select></td>';
5034 print
'<td><select name="tabfieldvalue" >';
5035 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldvalue'][$i]).
'">'.$dicts[
'tabfieldvalue'][$i].
'</option>';
5036 print
'</select></td>';
5038 print
'<td><select name="tabfieldinsert" >';
5039 print
'<option value="'.dol_escape_htmltag($dicts[
'tabfieldinsert'][$i]).
'">'.$dicts[
'tabfieldinsert'][$i].
'</option>';
5040 print
'</select></td>';
5043 print
'<input type="text" name="tabrowid" value="'.dol_escape_htmltag($dicts[
'tabrowid'][$i]).
'" readonly class="tdstickygray">';
5047 print
'<input type="text" name="tabcond" value="'.dol_escape_htmltag((empty($dicts[
'tabcond'][$i]) ?
'disabled' :
'enabled')).
'" readonly class="tdstickygray">';
5050 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5051 print
'<input id ="updatedict" class="reposition button smallpaddingimp" type="submit" name="updatedict" value="'.$langs->trans(
"Modify").
'"/>';
5053 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5059 print
'<tr class="oddeven">';
5061 print
'<td class="tdsticky tdstickygray">';
5066 print $dicts[
'tabname'][$i];
5070 print $dicts[
'tablib'][$i];
5074 print $dicts[
'tabsql'][$i];
5078 print $dicts[
'tabsqlsort'][$i];
5082 print $dicts[
'tabfield'][$i];
5086 print $dicts[
'tabfieldvalue'][$i];
5090 print $dicts[
'tabfieldinsert'][$i];
5094 print $dicts[
'tabrowid'][$i];
5098 print $dicts[
'tabcond'][$i];
5101 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5102 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>';
5103 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>';
5111 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5120 if ($tabdic ==
'newdictionary') {
5122 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5123 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5124 print
'<input type="hidden" name="action" value="initdic">';
5125 print
'<input type="hidden" name="tab" value="dictionaries">';
5126 print
'<input type="hidden" name="tabdic" value="'.$tabdic.
'">';
5128 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5130 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfDictionaryDesc").
'</span><br><br>';
5133 print
'<table class="border centpercent">';
5135 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>';
5136 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>';
5137 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>';
5138 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>';
5139 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsView").
'</td><td><input type="text" name="field" value="'.
dol_escape_htmltag(
GETPOST(
'field',
'alpha')).
'"></td></tr>';
5140 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsEdit").
'</td><td><input type="text" name="fieldvalue" value="'.
dol_escape_htmltag(
GETPOST(
'fieldvalue',
'alpha')).
'"></td></tr>';
5141 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"FieldsInsert").
'</td><td><input type="text" name="fieldinsert" value="'.
dol_escape_htmltag(
GETPOST(
'fieldinsert',
'alpha')).
'"></td></tr>';
5142 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Rowid").
'</td><td><input type="text" name="rowid" value="'.
dol_escape_htmltag(
GETPOST(
'rowid',
'alpha')).
'"></td></tr>';
5144 print
'</tbody></table>';
5145 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5146 print
'<input id="cancel" type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5150 $(document).ready(function() {
5151 $("input[name=\'dicname\']").on("blur", function() {
5152 if ($(this).val().length > 0) {
5153 $("input[name=\'label\']").val($(this).val());
5154 $("input[name=\'sql\']").val("SELECT f.rowid as rowid, f.code, f.label, f.active FROM llx_c_" + $(this).val() + " as f");
5155 $("input[name=\'sqlsort\']").val("label ASC");
5156 $("input[name=\'field\']").val("code,label");
5157 $("input[name=\'fieldvalue\']").val("code,label");
5158 $("input[name=\'fieldinsert\']").val("code,label");
5159 $("input[name=\'rowid\']").val("rowid");
5161 $("input[name=\'label\']").val("");
5162 $("input[name=\'sql\']").val("");
5163 $("input[name=\'sqlsort\']").val("");
5164 $("input[name=\'field\']").val("");
5165 $("input[name=\'fieldvalue\']").val("");
5166 $("input[name=\'fieldinsert\']").val("");
5167 $("input[name=\'rowid\']").val("");
5170 $("input[id=\'cancel\']").click(function() {
5171 window.history.back();
5188 } elseif ($tabdic ==
'deletedictionary') {
5190 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5191 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5192 print
'<input type="hidden" name="action" value="confirm_deletedictionary">';
5193 print
'<input type="hidden" name="tab" value="dictionaries">';
5194 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5196 print $langs->trans(
"EnterNameOfDictionnaryToDeleteDesc").
'<br><br>';
5198 print
'<input type="text" name="dicname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"DicKey")).
'">';
5199 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
5207 $content = file_get_contents($fullpathoffile);
5210 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5211 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5212 print
'<input type="hidden" name="action" value="savefile">';
5213 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5214 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5215 print
'<input type="hidden" name="module" value="'.$module.
'">';
5217 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5218 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5219 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5222 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5224 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5231 if ($tab ==
'menus') {
5232 print
'<!-- tab=menus -->'.
"\n";
5233 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5234 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
5235 $destdir = $dirins.
'/'.strtolower($module);
5236 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
5239 $leftmenus = array();
5244 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5247 $groupedRights = array();
5248 foreach ($permissions as $right) {
5250 if (!isset($groupedRights[$key])) {
5251 $groupedRights[$key] = array();
5253 $groupedRights[$key][] = $right;
5255 $groupedRights_json = json_encode($groupedRights);
5257 if ($action ==
'deletemenu') {
5258 $formconfirms = $form->formconfirm(
5259 $_SERVER[
"PHP_SELF"].
'?menukey='.urlencode((
string) (
GETPOSTINT(
'menukey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
5260 $langs->trans(
'Delete'),
5261 ($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'))),
5262 'confirm_deletemenu',
5267 print $formconfirms;
5269 if ($action !=
'editfile' || empty($file)) {
5270 print
'<span class="opacitymedium">';
5271 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'{s1}');
5272 $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);
5273 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5278 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5279 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>';
5283 $listODifferentUrlsInMenu = array();
5284 foreach ($menus as $obj) {
5285 if (preg_match(
'/^\/'.preg_quote(strtolower($module),
'/').
'\//', $obj[
'url']) && !empty($pathoffile)) {
5286 if (!empty($listODifferentUrlsInMenu[$pathoffile])) {
5289 $pathtofile = $obj[
'url'];
5290 $listODifferentUrlsInMenu[$pathoffile] = $pathtofile;
5291 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PageLinkedByAMenuEntry").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5292 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>';
5301 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5302 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5303 print
'<input type="hidden" name="action" value="addmenu">';
5304 print
'<input type="hidden" name="tab" value="menus">';
5305 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5306 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5308 print
'<div class="div-table-responsive">';
5309 print
'<table class="noborder small">';
5311 $htmltextenabled =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5312 $htmltextenabled .=
'1 <span class="opacitymedium">(module always enabled)</span><br>';
5313 $htmltextenabled .=
'0 <span class="opacitymedium">(module always disabled)</span><br>';
5314 $htmltextenabled .=
'isModEnabled(\''.dol_escape_htmltag(strtolower($module)).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span>
';
5315 $htmltextperms = '<u>
'.$langs->trans("Examples").':</u><br>
';
5316 $htmltextperms .= '1 <span class=
"opacitymedium">(access always allowed)</span><br>
';
5317 $htmltextperms .= '$user->hasright(\
''.
dol_escape_htmltag(strtolower($module)).
'\', \'myobject\', \'read\') <span class="opacitymedium">(access allowed if user has permission module->object->read)</span>';
5319 print
'<tr class="liste_titre">';
5320 print_liste_field_titre(
"#", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center tdsticky tdstickygray ');
5323 print_liste_field_titre(
"LinkToParentMenu", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'minwidth100 ');
5326 print_liste_field_titre(
"URL", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->transnoentitiesnoconv(
'DetailUrl'));
5328 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'right ');
5329 print_liste_field_titre(
"Enabled", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
'DetailEnabled').
'<br><br>'.$htmltextenabled);
5330 print_liste_field_titre(
"Rights", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailRight').
'<br><br>'.$htmltextperms);
5331 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'', $langs->trans(
'DetailTarget'));
5332 print_liste_field_titre(
"MenuForUsers", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center minwidth100 ', $langs->trans(
'DetailUser'));
5333 print_liste_field_titre(
"", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ', $langs->trans(
''));
5336 $r = count($menus) + 1;
5339 print
'<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
5340 print
'<td class="center">';
5341 print
'<select class="maxwidth50" name="type">';
5342 print
'<option value="">'.$langs->trans(
"........").
'</option><option value="'.
dol_escape_htmltag(
"left").
'">left</option><option value="'.
dol_escape_htmltag(
"top").
'">top</option>';
5343 print
'</select></td>';
5344 print
'<td class="left"><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag(
GETPOST(
'titre',
'alpha')).
'"></td>';
5345 print
'<td class="left">';
5346 print
'<select name="fk_menu">';
5347 print
'<option value="">'.$langs->trans(
"........").
'</option>';
5348 foreach ($menus as $obj) {
5349 if ($obj[
'type'] ==
'left' && !empty($obj[
'leftmenu'])) {
5350 print
"<option value=".strtolower($obj[
'leftmenu']).
">".$obj[
'leftmenu'].
"</option>";
5355 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>';
5356 print
'<td class="center"><input id="leftmenu" type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag(
GETPOST(
'leftmenu',
'alpha')).
'"></td>';
5358 print
'<td class="left"><input id="url" type="text" class="left maxwidth100" name="url" value="'.dol_escape_htmltag(
GETPOST(
'url',
'alpha')).
'"></td>';
5359 print
'<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5361 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).
'" readonly></td>';
5363 print
'<td class="center">';
5364 print
'<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET(
'enabled') ?
GETPOST(
'enabled') :
'isModEnabled(\''.$module.
'\')').
'">';
5373 print
'<td class="left">';
5374 print
'<select class="maxwidth" name="objects" id="objects">';
5375 print
'<option value=""></option>';
5376 if (is_array($objects)) {
5377 foreach ($objects as $value) {
5378 print
'<option value="'.strtolower($value).
'">'.
dol_escape_htmltag(strtolower($value)).
'</option>';
5382 print
'<select class="maxwidth hideobject" name="perms" id="perms">';
5385 print
'<td class="center"><input type="text" class="center maxwidth50" name="target" value="'.dol_escape_htmltag(
GETPOST(
'target',
'alpha')).
'"></td>';
5386 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>';
5388 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5389 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5397 if (count($menus)) {
5399 foreach ($menus as $menu) {
5403 $value = substr($string, strpos($string,
'fk_leftmenu=') + strlen(
'fk_leftmenu='));
5405 $propFk_menu = !empty($menu[
'fk_menu']) ? $menu[
'fk_menu'] :
GETPOST(
'fk_menu');
5406 $propTitre = !empty($menu[
'titre']) ? $menu[
'titre'] :
GETPOST(
'titre');
5407 $propMainmenu = !empty($menu[
'mainmenu']) ? $menu[
'mainmenu'] :
GETPOST(
'mainmenu');
5408 $propLeftmenu = !empty($menu[
'leftmenu']) ? $menu[
'leftmenu'] :
GETPOST(
'leftmenu');
5409 $propUrl = !empty($menu[
'url']) ? $menu[
'url'] :
GETPOST(
'url',
'alpha');
5410 $propPerms = !empty($menu[
'perms']) ? $menu[
'perms'] :
GETPOST(
'perms');
5411 $propUser = !empty($menu[
'user']) ? $menu[
'user'] :
GETPOST(
'user');
5412 $propTarget = !empty($menu[
'target']) ? $menu[
'target'] :
GETPOST(
'target');
5413 $propEnabled = !empty($menu[
'enabled']) ? $menu[
'enabled'] :
GETPOST(
'enabled');
5415 $objPerms = (empty($arguments[1]) ?
'' : trim($arguments[1]));
5416 $valPerms = (empty($arguments[2]) ?
'' : trim($arguments[2]));
5420 if ($action ==
'editmenu' &&
GETPOSTINT(
'menukey') == $i) {
5422 print
'<tr class="oddeven">';
5423 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5424 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5425 print
'<input type="hidden" name="action" value="update_menu">';
5426 print
'<input type="hidden" name="tab" value="menus">';
5427 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5428 print
'<input type="hidden" name="menukey" value="'.$i.
'"/>';
5430 print
'<td class="tdsticky tdstickygray">';
5434 print
'<td class="center">
5435 <select class="center maxwidth50" name="type">
5436 <option value="'.dol_escape_htmltag($menu[
'type']).
'">
5439 print
'<option value="'.($menu[
'type'] ==
'left' ?
'top' :
'left').
'">';
5440 if ($menu[
'type'] ==
'left') {
5445 print
'</option></select></td>';
5447 print
'<td><input type="text" class="left maxwidth100" name="titre" value="'.dol_escape_htmltag($propTitre).
'"></td>';
5458 print
'<input type="text" name="fk_menu" class="maxwidth150" value="'.dol_escape_htmltag($propFk_menu).
'">';
5460 print
'<td><input type="text" class="left maxwidth50" name="mainmenu" value="'.dol_escape_htmltag($propMainmenu).
'" readonly></td>';
5461 print
'<td><input type="text" class="left maxwidth50" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).
'" readonly></td>';
5463 print
'<td><input type="text" class="left maxwidth250" name="url" value="'.dol_escape_htmltag($propUrl).
'"></td>';
5464 print
'<td><input type="text" class="left maxwidth50" name="langs" value="'.strtolower($module).
'@'.strtolower($module).
'" readonly></td>';
5466 print
'<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.($menu[
'position']).
'" readonly></td>';
5468 print
'<td class="nowraponall">';
5469 print
'<input type="text" class="maxwidth125" name="enabled" value="'.dol_escape_htmltag($propEnabled !=
'' ? $propEnabled :
"isModEnabled('".
dol_escape_htmltag($module).
"')").
'">';
5470 $htmltext =
'<u>'.$langs->trans(
"Examples").
':</u><br>';
5471 $htmltext .=
'1 <span class="opacitymedium">(always enabled)</span><br>';
5472 $htmltext .=
'0 <span class="opacitymedium">(always disabled)</span><br>';
5473 $htmltext .=
'isModEnabled(\''.dol_escape_htmltag($module).
'\') <span
class=
"opacitymedium">(enabled when module is enabled)</span><br>
';
5474 print $form->textwithpicto('', $htmltext);
5476 print '<select
class=
"maxwidth50" name=
"enabledselect">
';
5477 print '<option value=
"1">1 (always enabled)</option>
';
5478 print '<option value=
"0">0 (always
disabled)</option>
';
5479 print '<option value=
"isModEnabled(\''.dol_escape_htmltag($module).'\')" >isModEnabled(\
''.
dol_escape_htmltag($module).
'\')</option>
';
5484 print '<td
class=
"nowraponall">
';
5485 print '<input
type=
"text" name=
"perms" value=
"'.dol_escape_htmltag($propPerms).'">
';
5487 if (!empty($objPerms)) {
5488 print '<input
type=
"hidden" name=
"objects" value=
"'.$objPerms.'" />
';
5489 print '<select
class=
"center maxwidth50" name=
"perms">
';
5490 if (!empty($valPerms)) {
5491 print '<option selected value=
"'.dol_escape_htmltag($valPerms).'">
'.dol_escape_htmltag($langs->trans($crud[$valPerms])).'</option>
';
5492 foreach ($crud as $key => $val) {
5493 if ($valPerms != $key) {
5494 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($langs->trans($val)).'</option>
';
5500 print '<select
class=
"center maxwidth50" name=
"objects">
';
5501 print '<option></option>
';
5502 foreach ($objects as $obj) {
5503 print '<option value=
"'.dol_escape_htmltag(strtolower($obj)).'">
'.dol_escape_htmltag($obj).'</option>
';
5506 print '<select
class=
"center maxwidth50" name=
"perms">
';
5507 foreach ($crud as $key => $val) {
5508 print '<option value=
"'.dol_escape_htmltag($key).'">
'.dol_escape_htmltag($key).'</option>
';
5514 print '<td
class=
"center"><input
type=
"text" class=
"center maxwidth50" name=
"target" value=
"'.dol_escape_htmltag($propTarget).'"></td>
';
5515 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>
';
5516 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite maxwidth75">
';
5517 print '<input
class=
"reposition button smallpaddingimp" type=
"submit" name=
"edit" value=
"'.$langs->trans("Modify
").'">
';
5518 print '<input
class=
"reposition button button-cancel smallpaddingimp" type=
"submit" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
5523 print '<tr
class=
"oddeven">
';
5525 print '<td
class=
"tdsticky tdstickygray">
';
5529 print '<td
class=
"center">
';
5530 print dol_escape_htmltag($menu['type']);
5535 print dol_escape_htmltag($menu['titre
']);
5539 print '<td
class=
"tdoverflowmax100" title=
"'.dol_escape_htmltag($menu['fk_menu']).'">
';
5540 print dol_escape_htmltag($menu['fk_menu
']);
5544 print dol_escape_htmltag($menu['mainmenu
']);
5548 print dol_escape_htmltag($menu['leftmenu
']);
5551 print '<td
class=
"tdoverflowmax250" title=
"'.dol_escape_htmltag($menu['url']).'">
';
5552 print dol_escape_htmltag($menu['url
']);
5556 print dol_escape_htmltag($menu['langs
']);
5560 print '<td
class=
"center">
';
5561 print dol_escape_htmltag((string) $menu['position']);
5565 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['enabled']).'">
';
5566 print dol_escape_htmltag($menu['enabled
']);
5570 print '<td
class=
"tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['perms']).'">
';
5571 print dol_escape_htmltag($langs->trans($menu['perms
']));
5575 print '<td
class=
"center tdoverflowmax200" title=
"'.dol_escape_htmltag($menu['target']).'">
';
5576 print dol_escape_htmltag($menu['target
']);
5579 print '<td
class=
"center">
';
5580 if ($menu['user'] == 2) {
5581 print $langs->trans("AllMenus");
5582 } elseif ($menu['user'] == 0) {
5583 print $langs->trans('Internal
');
5584 } elseif ($menu['user'] == 1) {
5585 print $langs->trans('External
');
5587 print $menu['user']; // should not happen
5590 print '<td
class=
"center minwidth75 tdstickyright tdstickyghostwhite">
';
5591 if ($menu['titre
'] != 'Module
'.$module.'Name
') {
5592 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>
';
5593 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>
';
5600 print '<tr><td colspan=
"14"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
5609 $(document).ready(
function() {
5611 $(
"#leftmenu").on(
"input",
function() {
5612 var inputLeftMenu = $(
"#leftmenu").val();
5613 if (inputLeftMenu !== \
'\') {
5614 var url = \
''.dol_escape_js(strtolower($module)).
'\' + inputLeftMenu + \
'.php\';
5621 var groupedRights = ' . $groupedRights_json .
';
5622 var objectsSelect = $("select[id=\'objects\']");
5623 var permsSelect = $("select[id=\'perms\']");
5625 objectsSelect.change(function() {
5626 var selectedObject = $(this).val();
5628 permsSelect.empty();
5630 var rights = groupedRights[selectedObject];
5633 for (var i = 0; i < rights.length; i++) {
5634 var right = rights[i];
5635 var option = $("<option></option>").attr("value", right[5]).text(right[5]);
5636 permsSelect.append(option);
5639 var option = $("<option></option>").attr("value", "read").text("read");
5640 permsSelect.append(option);
5643 if (selectedObject !== "" && selectedObject !== null && rights) {
5648 if (objectsSelect.val() === "" || objectsSelect.val() === null) {
5659 $content = file_get_contents($fullpathoffile);
5662 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5663 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5664 print
'<input type="hidden" name="action" value="savefile">';
5665 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5666 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5667 print
'<input type="hidden" name="module" value="'.$module.
'">';
5669 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5670 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5671 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5674 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5676 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5683 if ($tab ==
'permissions') {
5684 print
'<!-- tab=permissions -->'.
"\n";
5685 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5690 $dir = $dirread.
'/'.$modulelowercase.
'/class';
5691 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
5692 $objects = array(
'myobject');
5694 foreach ($listofobject as $fileobj) {
5695 $tmpcontent = file_get_contents($fileobj[
'fullname']);
5696 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
5697 $objects[$fileobj[
'fullname']] = $reg[1];
5702 $crud = array(
'read' =>
'CRUDRead',
'write' =>
'CRUDCreateWrite',
'delete' =>
'Delete');
5703 $labels = array(
"Read objects of ".$module,
"Create/Update objects of ".$module,
"Delete objects of ".$module);
5705 $action =
GETPOST(
'action',
'alpha');
5707 if ($action ==
'deleteright') {
5708 $formconfirm = $form->formconfirm(
5709 $_SERVER[
"PHP_SELF"].
'?permskey='.urlencode((
string) (
GETPOSTINT(
'permskey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.urlencode((
string) ($tabobj)),
5710 $langs->trans(
'Delete'),
5711 $langs->trans(
'Confirm Delete Right',
GETPOST(
'permskey',
'alpha')),
5712 'confirm_deleteright',
5720 if ($action !=
'editfile' || empty($file)) {
5721 print
'<!-- Tab to manage permissions -->'.
"\n";
5722 print
'<span class="opacitymedium">';
5723 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'{s1}');
5724 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultRights').
'</a>', $htmlhelp);
5725 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
5729 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5730 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>';
5736 print
'<!-- form to add permissions -->'.
"\n";
5737 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5738 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5739 print
'<input type="hidden" name="action" value="addright">';
5740 print
'<input type="hidden" name="tab" value="permissions">';
5741 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5742 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5744 print
'<div class="div-table-responsive">';
5745 print
'<table class="noborder">';
5747 print
'<tr class="liste_titre">';
5749 print_liste_field_titre(
"Object", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
"center");
5756 print
'<tr class="small">';
5757 print
'<td><input type="hidden" readonly name="id" class="width75" value="0"></td>';
5759 print
'<td><select class="minwidth100" name="permissionObj" id="permissionObj">';
5760 print
'<option value=""></option>';
5761 foreach ($objects as $obj) {
5762 if ($obj !=
'myobject') {
5763 print
'<option value="'.$obj.
'">'.$obj.
'</option>';
5766 print
'</select></td>';
5768 print
'<td><select class="maxwidth75" name="crud" id="crud">';
5769 print
'<option value=""></option>';
5770 foreach ($crud as $key => $val) {
5771 print
'<option value="'.$key.
'">'.$langs->trans($val).
'</option>';
5776 print
'<input type="text" name="label" id="label" class="minwidth200">';
5779 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5780 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
5784 if (count($perms)) {
5786 foreach ($perms as $perm) {
5790 if ($action ==
'edit_right' && $perm[0] ==
GETPOSTINT(
'permskey')) {
5791 print
'<tr class="oddeven">';
5792 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="modifPerms">';
5793 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5794 print
'<input type="hidden" name="tab" value="permissions">';
5795 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
5796 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
5797 print
'<input type="hidden" name="action" value="update_right">';
5798 print
'<input type="hidden" name="counter" value="'.$i.
'">';
5800 print
'<input type="hidden" name="permskey" value="'.$perm[0].
'">';
5802 print
'<td class="tdsticky tdstickygray">';
5803 print
'<input class="width75" type="text" readonly value="'.dol_escape_htmltag($perm[0]).
'"/>';
5807 print
'<select name="crud">';
5808 print
'<option value="'.dol_escape_htmltag($perm[5]).
'">'.$langs->trans($perm[5]).
'</option>';
5809 foreach ($crud as $i => $x) {
5810 if ($perm[5] != $i) {
5811 print
'<option value="'.$i.
'">'.$langs->trans(ucfirst($x)).
'</option>';
5817 print
'<td><select name="permissionObj" >';
5818 print
'<option value="'.dol_escape_htmltag($perm[4]).
'">'.ucfirst($perm[4]).
'</option>';
5819 print
'</select></td>';
5822 print
'<input type="text" name="label" value="'.dol_escape_htmltag($perm[1]).
'">';
5825 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5826 print
'<input id ="modifyPerm" class="reposition button smallpaddingimp" type="submit" name="modifyright" value="'.$langs->trans(
"Modify").
'"/>';
5828 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
5835 print
'<tr class="oddeven">';
5842 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5850 if (in_array($perm[5], array(
'lire',
'read',
'creer',
'write',
'effacer',
'delete'))) {
5851 print ucfirst($langs->trans($perm[5]));
5853 print ucfirst($langs->trans($perm[4]));
5858 print $langs->trans($perm[1]);
5861 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5862 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>';
5863 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>';
5871 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
5879 function updateInputField() {
5880 value1 = $("#crud").val();
5881 value2 = $("#permissionObj").val();
5883 // Vérifie si les deux sélections sont faites
5884 if (value1 && value2) {
5885 switch(value1.toLowerCase()){
5887 $("#label").val("Read "+value2+" object of '.ucfirst($module).
'")
5890 $("#label").val("Create/Update "+value2+" object of '.ucfirst($module).
'")
5893 $("#label").val("Delete "+value2+" object of '.ucfirst($module).
'")
5901 $("#crud, #permissionObj").change(function(){
5902 console.log("We change selection");
5910 $content = file_get_contents($fullpathoffile);
5913 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5914 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5915 print
'<input type="hidden" name="action" value="savefile">';
5916 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5917 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5918 print
'<input type="hidden" name="module" value="'.$module.
'">';
5920 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5921 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5922 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5925 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5927 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5934 if ($tab ==
'hooks') {
5935 print
'<!-- tab=hooks -->'.
"\n";
5936 if ($action !=
'editfile' || empty($file)) {
5937 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
5942 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
5944 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
5946 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>';
5950 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
5951 print
'<span class="fa fa-file"></span> '.$langs->trans(
"HooksFile").
' : ';
5953 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
5955 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> ';
5956 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>';
5958 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
5959 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>';
5966 $content = file_get_contents($fullpathoffile);
5969 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5970 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5971 print
'<input type="hidden" name="action" value="savefile">';
5972 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
5973 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
5974 print
'<input type="hidden" name="module" value="'.$module.
'">';
5976 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
5977 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
5978 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
5981 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
5983 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
5990 if ($tab ==
'triggers') {
5991 print
'<!-- tab=triggers -->'.
"\n";
5992 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
5995 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
5997 if ($action !=
'editfile' || empty($file)) {
5998 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
6003 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6005 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6007 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>';
6010 if (!empty($triggers)) {
6011 foreach ($triggers as $trigger) {
6012 $pathtofile = $trigger[
'relpath'];
6015 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6016 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>';
6017 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>';
6022 print
'<span class="fa fa-file"></span> '.$langs->trans(
"TriggersFile");
6023 print
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6024 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>';
6033 $content = file_get_contents($fullpathoffile);
6036 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6037 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6038 print
'<input type="hidden" name="action" value="savefile">';
6039 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6040 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6041 print
'<input type="hidden" name="module" value="'.$module.
'">';
6043 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6044 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6045 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6048 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6050 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6057 if ($tab ==
'css') {
6058 print
'<!-- tab=css -->'.
"\n";
6059 if ($action !=
'editfile' || empty($file)) {
6060 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
6066 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
6067 print
'<span class="fa fa-file"></span> '.$langs->trans(
"CSSFile").
' : ';
6069 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6070 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>';
6071 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>';
6073 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6074 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>';
6080 $content = file_get_contents($fullpathoffile);
6083 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6084 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6085 print
'<input type="hidden" name="action" value="savefile">';
6086 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6087 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6088 print
'<input type="hidden" name="module" value="'.$module.
'">';
6090 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6091 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6094 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6096 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6104 print
'<!-- tab=js -->'.
"\n";
6105 if ($action !=
'editfile' || empty($file)) {
6106 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
6112 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
6113 print
'<span class="fa fa-file"></span> '.$langs->trans(
"JSFile").
' : ';
6115 print
'<strong class="wordbreak">'.$pathtohook.
'</strong>';
6116 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>';
6117 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>';
6119 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6120 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>';
6126 $content = file_get_contents($fullpathoffile);
6129 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6130 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6131 print
'<input type="hidden" name="action" value="savefile">';
6132 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6133 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6134 print
'<input type="hidden" name="module" value="'.$module.
'">';
6136 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6137 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6140 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6142 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6149 if ($tab ==
'widgets') {
6150 print
'<!-- tab=widgets -->'.
"\n";
6151 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
6155 if ($action !=
'editfile' || empty($file)) {
6156 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
6160 if (!empty($widgets)) {
6161 foreach ($widgets as $widget) {
6162 $pathtofile = $widget[
'relpath'];
6164 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6165 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>';
6166 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>';
6170 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"WidgetFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoWidget").
'</span>';
6171 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>';
6178 $content = file_get_contents($fullpathoffile);
6181 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6182 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6183 print
'<input type="hidden" name="action" value="savefile">';
6184 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6185 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6186 print
'<input type="hidden" name="module" value="'.$module.
'">';
6188 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6189 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6192 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6194 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6201 if ($tab ==
'emailings') {
6202 print
'<!-- tab=emailings -->'.
"\n";
6203 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
6207 if ($action !=
'editfile' || empty($file)) {
6208 print
'<span class="opacitymedium">'.$langs->trans(
"EmailingSelectorDesc").
'</span><br>';
6212 if (!empty($emailingselectors)) {
6213 foreach ($emailingselectors as $emailingselector) {
6214 $pathtofile = $emailingselector[
'relpath'];
6216 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6217 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>';
6218 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>';
6222 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"EmailingSelectorFile").
' : <span class="opacitymedium">'.$langs->trans(
"NoEmailingSelector").
'</span>';
6223 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>';
6230 $content = file_get_contents($fullpathoffile);
6233 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6234 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6235 print
'<input type="hidden" name="action" value="savefile">';
6236 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6237 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6238 print
'<input type="hidden" name="module" value="'.$module.
'">';
6240 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6241 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6244 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6246 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6253 if ($tab ==
'exportimport') {
6254 print
'<!-- tab=exportimport -->'.
"\n";
6255 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6260 if ($action !=
'editfile' || empty($file)) {
6261 print
'<span class="opacitymedium">'.$langs->transnoentities(
'ImportExportProfiles').
'</span><br>';
6264 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ExportsArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6265 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>';
6267 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' ('.$langs->trans(
"ImportArea").
') : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6268 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>';
6273 $content = file_get_contents($fullpathoffile);
6276 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6277 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6278 print
'<input type="hidden" name="action" value="savefile">';
6279 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6280 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6281 print
'<input type="hidden" name="module" value="'.$module.
'">';
6283 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6284 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6285 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6288 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6290 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6297 if ($tab ==
'cli') {
6298 print
'<!-- tab=cli -->'.
"\n";
6299 $clifiles = array();
6302 $dircli = array(
'/'.strtolower($module).
'/scripts');
6304 foreach ($dircli as $reldir) {
6309 if (!is_dir($newdir)) {
6313 $handle = opendir($newdir);
6315 if (is_resource($handle)) {
6316 while (($tmpfile = readdir($handle)) !==
false) {
6317 if (is_readable($newdir.
'/'.$tmpfile) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg)) {
6318 if (preg_match(
'/\.back$/', $tmpfile)) {
6322 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
6331 if ($action !=
'editfile' || empty($file)) {
6332 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
6336 if (!empty($clifiles)) {
6337 foreach ($clifiles as $clifile) {
6338 $pathtofile = $clifile[
'relpath'];
6340 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6341 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>';
6342 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>';
6346 print
'<tr><td><span class="fa fa-file"></span> '.$langs->trans(
"CLIFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6347 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>';
6354 $content = file_get_contents($fullpathoffile);
6357 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6358 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6359 print
'<input type="hidden" name="action" value="savefile">';
6360 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6361 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6362 print
'<input type="hidden" name="module" value="'.$module.
'">';
6364 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6365 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6368 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6370 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6377 if ($tab ==
'cron') {
6378 print
'<!-- tab=cron -->'.
"\n";
6379 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6383 if ($action !=
'editfile' || empty($file)) {
6384 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>';
6387 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6388 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>';
6394 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6395 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6396 print
'<input type="hidden" name="action" value="addproperty">';
6397 print
'<input type="hidden" name="tab" value="objects">';
6398 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6399 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6401 print
'<div class="div-table-responsive">';
6402 print
'<table class="noborder">';
6404 print
'<tr class="liste_titre">';
6412 if (count($cronjobs)) {
6413 foreach ($cronjobs as $cron) {
6414 print
'<tr class="oddeven">';
6417 print $cron[
'label'];
6422 if ($cron[
'jobtype'] ==
'method') {
6423 $text = $langs->trans(
"CronClass");
6424 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
6425 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
6426 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
6427 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
6428 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6429 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6430 } elseif ($cron[
'jobtype'] ==
'command') {
6431 $text = $langs->trans(
'CronCommand');
6432 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
6433 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
6434 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
6436 print $form->textwithpicto($text, $texttoshow, 1);
6440 if ($cron[
'unitfrequency'] ==
"60") {
6441 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
6443 if ($cron[
'unitfrequency'] ==
"3600") {
6444 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
6446 if ($cron[
'unitfrequency'] ==
"86400") {
6447 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
6449 if ($cron[
'unitfrequency'] ==
"604800") {
6450 print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
6455 print $cron[
'status'];
6459 if (!empty($cron[
'comment'])) {
6460 print $cron[
'comment'];
6467 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6477 $content = file_get_contents($fullpathoffile);
6480 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6481 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6482 print
'<input type="hidden" name="action" value="savefile">';
6483 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6484 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6485 print
'<input type="hidden" name="module" value="'.$module.
'">';
6487 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6488 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6489 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6492 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6494 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6501 if ($tab ==
'specifications') {
6502 print
'<!-- tab=specifications -->'.
"\n";
6505 if ($action !=
'editfile' || empty($file)) {
6506 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
6510 if (is_array($specs) && !empty($specs)) {
6511 foreach ($specs as $spec) {
6512 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
6513 $format =
'asciidoc';
6514 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
6515 $format =
'markdown';
6518 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
6519 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>';
6520 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>';
6525 print
'<span class="fa fa-file"></span> '.$langs->trans(
"SpecificationFile").
' : <span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6526 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>';
6537 $content = file_get_contents($fullpathoffile);
6540 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6541 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6542 print
'<input type="hidden" name="action" value="savefile">';
6543 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6544 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6545 print
'<input type="hidden" name="module" value="'.$module.
'">';
6547 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%');
6548 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6551 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6553 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6559 print
'<br><br><br>';
6561 $FILENAMEDOC = $modulelowercase.
'.html';
6562 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
6563 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
6564 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
6565 $outputfiledocrel = $modulelowercase.
'/doc/'.$FILENAMEDOC;
6566 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
6567 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
6568 $outputfiledocrelpdf = $modulelowercase.
'/doc/'.$FILENAMEDOCPDF;
6571 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
6573 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6576 print
'<a href="'.$outputfiledocurl.
'" target="_blank" rel="noopener noreferrer">';
6577 print $outputfiledoc;
6580 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledoc),
'dayhour').
')</span>';
6581 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>';
6583 print
'</strong><br>';
6586 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
6588 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6591 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank" rel="noopener noreferrer">';
6592 print $outputfiledocpdf;
6595 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfiledocpdf),
'dayhour').
')</span>';
6596 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>';
6598 print
'</strong><br>';
6602 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
6603 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6604 print
'<input type="hidden" name="action" value="generatedoc">';
6605 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6606 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6607 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
6608 if (!is_array($specs) || empty($specs)) {
6609 print
' disabled="disabled"';
6615 if ($tab ==
'buildpackage') {
6616 print
'<!-- tab=buildpackage -->'.
"\n";
6617 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
6620 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP')) {
6621 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
6625 $modulelowercase = strtolower($module);
6631 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6633 $class =
'mod'.$module;
6635 if (class_exists($class)) {
6638 '@phan-var-force DolibarrModules $moduleobj';
6647 $langs->load(
"errors");
6648 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
6652 $arrayversion = explode(
'.',
$moduleobj->version, 3);
6653 if (count($arrayversion)) {
6654 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
".".$arrayversion[2]).
".zip";
6655 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
6660 print
'<span class="fa fa-file"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
6662 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
6664 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
6665 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
6666 print
' <span class="opacitymedium">('.$langs->trans(
"GeneratedOn").
' '.
dol_print_date(
dol_filemtime($outputfilezip),
'dayhour').
')</span>';
6667 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>';
6675 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
6676 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6677 print
'<input type="hidden" name="action" value="generatepackage">';
6678 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
6679 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6680 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
6684 if ($tab ==
'tabs') {
6685 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
6689 if ($action !=
'editfile' || empty($file)) {
6690 print
'<span class="opacitymedium">';
6691 $htmlhelp = $langs->trans(
"TabsDefDescTooltip",
'{s1}');
6692 $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);
6693 print $form->textwithpicto($langs->trans(
"TabsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
6697 print
'<span class="fa fa-file"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
6698 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>';
6704 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6705 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6706 print
'<input type="hidden" name="action" value="addproperty">';
6707 print
'<input type="hidden" name="tab" value="objects">';
6708 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
6709 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
6711 print
'<div class="div-table-responsive">';
6712 print
'<table class="noborder small">';
6714 print
'<tr class="liste_titre">';
6724 foreach ($tabs as $tab) {
6725 $parts = explode(
':', $tab[
'data']);
6727 $objectType = $parts[0];
6728 $tabName = $parts[1];
6729 $tabTitle = isset($parts[2]) ? $parts[2] :
'';
6730 $langFile = isset($parts[3]) ? $parts[3] :
'';
6731 $condition = isset($parts[4]) ? $parts[4] :
'';
6732 $path = isset($parts[5]) ? $parts[5] :
'';
6736 if ($tabName[0] ===
'-') {
6738 $condition = isset($parts[2]) ? $parts[2] :
'';
6741 print
'<tr class="oddeven">';
6748 if ($tabName[0] ===
"+") {
6749 print
'<span class="badge badge-status4 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6751 print
'<span class="badge badge-status8 badge-status">' .
dol_escape_htmltag($tabName) .
'</span>';
6774 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
6784 $content = file_get_contents($fullpathoffile);
6787 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
6788 print
'<input type="hidden" name="token" value="'.newToken().
'">';
6789 print
'<input type="hidden" name="action" value="savefile">';
6790 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
6791 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
6792 print
'<input type="hidden" name="module" value="'.$module.
'">';
6794 $posCursor = (empty($find)) ? array() : array(
'find' => $find);
6795 $doleditor =
new DolEditor(
'editfilecontent', $content,
'', 300,
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
6796 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
6799 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
6801 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
6808 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_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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
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.