modVariants.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \defgroup produit Module product variants
  22. * \brief Module to manage product combinations based on product attributes
  23. * \file htdocs/core/modules/modVariants.class.php
  24. * \ingroup produit
  25. * \brief Description and activation file for the module product variants
  26. */
  27. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  28. /**
  29. * Description and activation class for module Product variants
  30. */
  31. class modVariants extends DolibarrModules
  32. {
  33. /**
  34. * Constructor. Define names, constants, directories, boxes, permissions
  35. *
  36. * @param DoliDB $db Database handler
  37. */
  38. public function __construct($db)
  39. {
  40. global $langs, $conf;
  41. $this->db = $db;
  42. // Id for module (must be unique).
  43. // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
  44. $this->numero = 610;
  45. // Key text used to identify module (for permissions, menus, etc...)
  46. $this->rights_class = 'variants';
  47. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  48. // It is used to group modules in module setup page
  49. $this->family = "products";
  50. // Module position in the family on 2 digits ('01', '10', '20', ...)
  51. $this->module_position = '50';
  52. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  53. $this->name = preg_replace('/^mod/i', '', get_class($this));
  54. // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  55. $this->description = 'Allows creating products variant based on new attributes';
  56. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  57. $this->version = 'dolibarr';
  58. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  59. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  60. // Name of image file used for this module.
  61. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
  62. // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
  63. $this->picto = 'product';
  64. // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
  65. $this->module_parts = array();
  66. // Data directories to create when module is enabled.
  67. // Example: this->dirs = array("/variants/temp");
  68. $this->dirs = array();
  69. // Config pages. Put here list of php page, stored into variants/admin directory, to use to setup module.
  70. $this->config_page_url = array('admin.php@variants');
  71. // Dependencies
  72. $this->hidden = false; // A condition to hide module
  73. $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled
  74. $this->requiredby = array(); // List of module ids to disable if this one is disabled
  75. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  76. $this->phpmin = array(7, 0); // Minimum version of PHP required by module
  77. $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
  78. $this->langfiles = array("products");
  79. // Constants
  80. $this->const = array();
  81. // Array to add new pages in new tabs
  82. $this->tabs = array(
  83. // 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
  84. );
  85. // Dictionaries
  86. if (!isset($conf->variants->enabled)) {
  87. $conf->variants = new stdClass();
  88. $conf->variants->enabled = 0;
  89. }
  90. $this->dictionaries = array();
  91. // Boxes
  92. // Add here list of php file(s) stored in core/boxes that contains class to show a box.
  93. $this->boxes = array(); // List of boxes
  94. // Permissions
  95. $this->rights = array(); // Permission array used by this module
  96. $r = 0;
  97. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  98. $this->rights[$r][1] = 'Read attributes of variants'; // Permission label
  99. $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  100. $r++;
  101. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  102. $this->rights[$r][1] = 'Create/Update attributes of variants'; // Permission label
  103. $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  104. $r++;
  105. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  106. $this->rights[$r][1] = 'Delete attributes of variants'; // Permission label
  107. $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  108. $r++;
  109. }
  110. }