modDebugBar.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /* Copyright (C) 2019-2020 AXeL-dev <contact.axel.dev@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \defgroup debugbar Module Debug bar
  19. * \brief debugbar module descriptor.
  20. *
  21. * \file htdocs/core/modules/modDebugBar.class.php
  22. * \ingroup debugbar
  23. * \brief Description and activation file for the module debugbar
  24. */
  25. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Class to describe and enable module
  28. */
  29. class modDebugBar 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. $this->db = $db;
  39. $this->numero = 43;
  40. $this->rights_class = 'debugbar';
  41. $this->family = "base";
  42. $this->module_position = '75';
  43. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  44. $this->name = preg_replace('/^mod/i', '', get_class($this));
  45. $this->description = "A tool for developper adding a debug bar in your browser.";
  46. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  47. $this->version = 'dolibarr';
  48. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  49. $this->picto = 'bug';
  50. $this->module_parts = array('moduleforexternal' => 0);
  51. // Data directories to create when module is enabled
  52. $this->dirs = array();
  53. // Dependencies
  54. $this->depends = array(); // May be used for product or service or third party module
  55. $this->requiredby = array();
  56. // Config pages
  57. $this->config_page_url = array("debugbar.php");
  58. // Constants
  59. // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
  60. // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
  61. $this->const = array();
  62. // Boxes
  63. $this->boxes = array();
  64. // Permissions
  65. $this->rights = array();
  66. $this->rights[1][0] = 431; // id de la permission
  67. $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission
  68. $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour)
  69. $this->rights[1][3] = 1; // La permission est-elle une permission par defaut
  70. $this->rights[1][4] = 'read';
  71. }
  72. /**
  73. * Function called when module is enabled.
  74. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  75. * It also creates data directories.
  76. *
  77. * @param string $options Options when enabling module ('', 'noboxes')
  78. * @return int 1 if OK, 0 if KO
  79. */
  80. public function init($options = '')
  81. {
  82. // Permissions
  83. $this->remove($options);
  84. $sql = array(
  85. );
  86. return $this->_init($sql, $options);
  87. }
  88. }