modModuleBuilder.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourcefore.net>
  3. * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \defgroup modulebuilder Module ModuleBuilder
  20. * \brief Add a log into a block chain for some actions.
  21. * \file htdocs/core/modules/modBlockedLog.class.php
  22. * \ingroup blockedlog
  23. * \brief Description and activation file for the module ModuleBuilder
  24. */
  25. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Class to describe a ModuleBuilder module
  28. */
  29. class modModuleBuilder extends DolibarrModules
  30. {
  31. /**
  32. * Constructor. Define names, constants, directories, boxes, permissions
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. public function __construct($db)
  37. {
  38. global $langs, $conf;
  39. $this->db = $db;
  40. $this->numero = 3300;
  41. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  42. // It is used to group modules in module setup page
  43. $this->family = "technic";
  44. $this->module_position = '90';
  45. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  46. $this->name = preg_replace('/^mod/i', '', get_class($this));
  47. $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module.";
  48. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  49. $this->version = 'dolibarr';
  50. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  51. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  52. // Name of image file used for this module.
  53. $this->picto = 'bug';
  54. // Data directories to create when module is enabled
  55. $this->dirs = array();
  56. // Config pages
  57. //-------------
  58. $this->config_page_url = array('setup.php@modulebuilder');
  59. // Dependencies
  60. //-------------
  61. $this->hidden = false; // A condition to disable module
  62. $this->depends = array(); // List of modules id that must be enabled if this module is enabled
  63. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  64. $this->conflictwith = array(); // List of modules id this module is in conflict with
  65. $this->langfiles = array();
  66. // Constants
  67. //-----------
  68. // New pages on tabs
  69. // -----------------
  70. $this->tabs = array();
  71. // Boxes
  72. //------
  73. $this->boxes = array();
  74. // Permissions
  75. //------------
  76. $this->rights = array(); // Permission array used by this module
  77. $this->rights_class = 'modulebuilder';
  78. $r = 0;
  79. $r++;
  80. $this->rights[$r][0] = 3301;
  81. $this->rights[$r][1] = 'Generate new modules';
  82. $this->rights[$r][2] = 'a';
  83. $this->rights[$r][3] = 0;
  84. $this->rights[$r][4] = 'run';
  85. // Main menu entries
  86. //------------------
  87. $this->menu = array();
  88. $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',
  89. 'type'=>'left',
  90. 'titre'=>'ModuleBuilder',
  91. 'mainmenu'=>'home',
  92. 'leftmenu'=>'admintools_modulebuilder',
  93. 'url'=>'/modulebuilder/index.php?mainmenu=home&amp;leftmenu=admintools',
  94. 'langs'=>'modulebuilder',
  95. 'position'=>100,
  96. 'perms'=>'1',
  97. 'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)',
  98. 'target'=>'_modulebuilder',
  99. 'user'=>0);
  100. }
  101. }