dolibarr 21.0.0-alpha
modVariants.class.php
Go to the documentation of this file.
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
29include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30
31
36{
42 public function __construct($db)
43 {
44 global $langs, $conf;
45
46 $this->db = $db;
47
48 // Id for module (must be unique).
49 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
50 $this->numero = 610;
51 // Key text used to identify module (for permissions, menus, etc...)
52 $this->rights_class = 'variants';
53
54 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
55 // It is used to group modules in module setup page
56 $this->family = "products";
57 // Module position in the family on 2 digits ('01', '10', '20', ...)
58 $this->module_position = '50';
59 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
60 $this->name = preg_replace('/^mod/i', '', get_class($this));
61 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
62 $this->description = 'Allows creating products variant based on new attributes';
63 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
64 $this->version = 'dolibarr';
65 // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
66 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
67 // Name of image file used for this module.
68 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
69 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
70 $this->picto = 'product';
71
72 // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
73 $this->module_parts = array();
74
75 // Data directories to create when module is enabled.
76 // Example: this->dirs = array("/variants/temp");
77 $this->dirs = array();
78
79 // Config pages. Put here list of php page, stored into variants/admin directory, to use to setup module.
80 $this->config_page_url = array('admin.php@variants');
81
82 // Dependencies
83 $this->hidden = false; // A condition to hide module
84 $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled
85 $this->requiredby = array(); // List of module ids to disable if this one is disabled
86 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
87 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
88 $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
89 $this->langfiles = array("products");
90
91 // Constants
92 $this->const = array();
93
94 // Array to add new pages in new tabs
95 $this->tabs = array(
96 // 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
97 );
98
99 // Dictionaries
100 if (!isset($conf->variants->enabled)) {
101 $conf->variants = new stdClass();
102 $conf->variants->enabled = 0;
103 }
104 $this->dictionaries = array();
105
106 // Boxes
107 // Add here list of php file(s) stored in core/boxes that contains class to show a box.
108 $this->boxes = array(); // List of boxes
109
110 // Permissions
111 $this->rights = array(); // Permission array used by this module
112 $r = 0;
113
114 $this->rights[$r][0] = $this->numero + 1; // Permission id (must not be already used)
115 $this->rights[$r][1] = 'Read attributes of variants'; // Permission label
116 $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
117 $r++;
118 $this->rights[$r][0] = $this->numero + 2; // Permission id (must not be already used)
119 $this->rights[$r][1] = 'Create/Update attributes of variants'; // Permission label
120 $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
121 $r++;
122 $this->rights[$r][0] = $this->numero + 3; // Permission id (must not be already used)
123 $this->rights[$r][1] = 'Delete attributes of variants'; // Permission label
124 $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
125 $r++;
126 }
127
136 public function init($options = '')
137 {
138 $result = $this->_load_tables('/install/mysql/', 'variants');
139 if ($result < 0) {
140 // Do not activate module if error 'not allowed' returned when loading module SQL queries
141 // (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
142 return -1;
143 }
144
145 // Permissions
146 $this->remove($options);
147
148 $sql = array();
149
150 return $this->_init($sql, $options);
151 }
152}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module Product variants.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140