modPrinting.class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* Copyright (C) 2014-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2014 Frederic France <frederic.france@free.fr>
  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. /** \defgroup printing Module printing
  19. * \brief Module for activation of printing icon to make direct printing
  20. */
  21. /**
  22. * \file htdocs/core/modules/modPrinting.class.php
  23. * \ingroup printing
  24. * \brief Description and activation file for the module Direct Printing
  25. */
  26. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  27. /**
  28. * Class to describe and activate module Direct Printing
  29. */
  30. class modPrinting extends DolibarrModules
  31. {
  32. /**
  33. * Constructor
  34. *
  35. * @param DoliDB $db Database handler
  36. */
  37. public function __construct($db)
  38. {
  39. $this->db = $db;
  40. $this->numero = 64000;
  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 = "interface";
  44. $this->module_position = '52';
  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. // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  48. $this->description = "Enable Direct Printing System.";
  49. $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
  50. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  51. // Name of image file used for this module.
  52. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
  53. // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
  54. $this->picto = 'printer';
  55. // Data directories to create when module is enabled.
  56. $this->dirs = array();
  57. // Config pages
  58. $this->config_page_url = array("printing.php@printing");
  59. // Dependencies
  60. $this->hidden = false; // A condition to hide module
  61. $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
  62. $this->requiredby = array(); // List of module ids to disable if this one is disabled
  63. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  64. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  65. $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module
  66. $this->conflictwith = array();
  67. $this->langfiles = array("printing");
  68. // Constants
  69. $this->const = array();
  70. // Boxes
  71. $this->boxes = array();
  72. // Permissions
  73. $this->rights = array();
  74. $this->rights_class = 'printing';
  75. $r = 0;
  76. // $this->rights[$r][0] Id permission (unique tous modules confondus)
  77. // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
  78. // $this->rights[$r][2] Non utilise
  79. // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut
  80. // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
  81. // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
  82. $r++;
  83. $this->rights[$r][0] = 64001;
  84. $this->rights[$r][1] = 'DirectPrint';
  85. $this->rights[$r][2] = 'r';
  86. $this->rights[$r][3] = 0;
  87. $this->rights[$r][4] = 'read';
  88. // Main menu entries
  89. $this->menus = array(); // List of menus to add
  90. $r = 0;
  91. // This is to declare the Top Menu entry:
  92. $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu
  93. 'type'=>'left', // This is a Top menu entry
  94. 'titre'=>'MenuDirectPrinting',
  95. 'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools',
  96. 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  97. 'position'=>300,
  98. 'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)',
  99. 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules
  100. 'target'=>'',
  101. 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
  102. $r++;
  103. }
  104. }