forked from pluginsGLPI/order
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.php
More file actions
228 lines (192 loc) · 7.4 KB
/
setup.php
File metadata and controls
228 lines (192 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
/*
-------------------------------------------------------------------------
{NAME} plugin for GLPI
Copyright (C) 2011-2017 by the Order Development Team.
https://github.com/pluginsGLPI/order
-------------------------------------------------------------------------
LICENSE
This file is part of the order plugin.
Order plugin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Order plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Order. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
@package order
@author the order plugin team
@copyright Copyright (c) 2010-2015 Order plugin team
@license GPLv2+
http://www.gnu.org/licenses/gpl.txt
@link https://forge.indepnet.net/projects/order
@link http://www.glpi-project.org/
@since 2009
---------------------------------------------------------------------- */
define('PLUGIN_ORDER_VERSION', '2.0.0');
if (!defined('PLUGIN_ORDER_TEMPLATE_DIR')) {
define("PLUGIN_ORDER_TEMPLATE_DIR", GLPI_PLUGIN_DOC_DIR."/order/templates/");
}
if (!defined('PLUGIN_ORDER_SIGNATURE_DIR')) {
define("PLUGIN_ORDER_SIGNATURE_DIR", GLPI_PLUGIN_DOC_DIR."/order/signatures/");
}
if (!defined('PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR')) {
define("PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR", GLPI_PLUGIN_DOC_DIR."/order/generate/");
}
if (!defined('PLUGIN_ORDER_TEMPLATE_LOGO_DIR')) {
define("PLUGIN_ORDER_TEMPLATE_LOGO_DIR", GLPI_PLUGIN_DOC_DIR."/order/logo/");
}
if (!defined('PLUGIN_ORDER_TEMPLATE_EXTENSION')) {
define("PLUGIN_ORDER_TEMPLATE_EXTENSION", "odt");
}
if (!defined('PLUGIN_ORDER_SIGNATURE_EXTENSION')) {
define("PLUGIN_ORDER_SIGNATURE_EXTENSION", "png");
}
global $CFG_GLPI;
if (!defined('PLUGIN_ORDER_NUMBER_STEP')) {
define("PLUGIN_ORDER_NUMBER_STEP", 1 / pow(10, $CFG_GLPI["decimal_number"]));
}
// Autoload
if (!defined('PCLZIP_TEMPORARY_DIR')) {
define('PCLZIP_TEMPORARY_DIR', GLPI_DOC_DIR . '/_tmp/pclzip');
}
include_once GLPI_ROOT . "/plugins/order/vendor/autoload.php";
/**
* Init hooks of the plugin.
* REQUIRED
*
* @return void
*/
function plugin_init_order() {
global $PLUGIN_HOOKS, $CFG_GLPI, $ORDER_TYPES;
Plugin::registerClass('PluginOrderProfile');
$PLUGIN_HOOKS['csrf_compliant']['order'] = true;
/* Init current profile */
$PLUGIN_HOOKS['change_profile']['order'] = ['PluginOrderProfile', 'initProfile'];
$plugin = new Plugin();
if ($plugin->isActivated('order')) {
$PLUGIN_HOOKS['migratetypes']['order'] = 'plugin_order_migratetypes';
$PLUGIN_HOOKS['assign_to_ticket']['order'] = true;
//Itemtypes in use for an order
$ORDER_TYPES = [
'Computer',
'Monitor',
'NetworkEquipment',
'Peripheral',
'Printer',
'Phone',
'ConsumableItem',
'CartridgeItem',
'Contract',
'PluginOrderOther',
'SoftwareLicense',
'Certificate'
];
$CFG_GLPI['plugin_order_types'] = $ORDER_TYPES;
$PLUGIN_HOOKS['pre_item_purge']['order'] = [
'Profile' => ['PluginOrderProfile', 'purgeProfiles'],
'DocumentCategory' => ['PluginOrderDocumentCategory', 'purgeItem'],
];
$PLUGIN_HOOKS['pre_item_update']['order'] = [
'Infocom' => ['PluginOrderOrder_Item', 'updateItem'],
'Contract' => ['PluginOrderOrder_Item', 'updateItem'],
];
$PLUGIN_HOOKS['item_add']['order'] = [
'Document' => ['PluginOrderOrder', 'addDocumentCategory']
];
include_once(GLPI_ROOT . "/plugins/order/inc/order_item.class.php");
foreach (PluginOrderOrder_Item::getClasses(true) as $type) {
$PLUGIN_HOOKS['item_purge']['order'][$type] = 'plugin_item_purge_order';
}
Plugin::registerClass('PluginOrderOrder', [
'document_types' => true,
'unicity_types' => true,
'notificationtemplates_types' => true,
'helpdesk_visible_types' => true,
'ticket_types' => true,
'contract_types' => true,
'linkuser_types' => true,
'addtabon' => ['Budget']
]);
Plugin::registerClass('PluginOrderReference', ['document_types' => true]);
Plugin::registerClass('PluginOrderProfile', ['addtabon' => ['Profile']]);
$values['notificationtemplates_types'] = true;
//If the new infocom display hook (introduced in 9.1) is available, use it !
if (method_exists('Infocom', 'addPluginInfos')) {
$PLUGIN_HOOKS['infocom']['order'] = ['PluginOrderOrder_Item', 'showForInfocom'];
} else {
$values['addtabon'] = PluginOrderOrder_Item::getClasses(true);
}
Plugin::registerClass('PluginOrderOrder_Item', $values);
if (PluginOrderOrder::canView()) {
Plugin::registerClass('PluginOrderDocumentCategory', ['addtabon' => ['DocumentCategory']]);
Plugin::registerClass('PluginOrderOrder_Supplier', ['addtabon' => ['Supplier']]);
Plugin::registerClass('PluginOrderPreference', ['addtabon' => ['Preference']]);
}
/*if glpi is loaded */
if (Session::getLoginUserID()) {
$PLUGIN_HOOKS['add_css']['order'][] = 'order.css';
/* link to the config page in plugins menu */
if (Session::haveRight("config", UPDATE)) {
$PLUGIN_HOOKS['config_page']['order'] = 'front/config.form.php';
}
if (PluginOrderOrder::canView()
|| PluginOrderReference::canView()
|| PluginOrderBill::canView()) {
$PLUGIN_HOOKS['menu_toadd']['order']['management'] = 'PluginOrderMenu';
}
$PLUGIN_HOOKS['assign_to_ticket']['order'] = true;
$PLUGIN_HOOKS['use_massive_action']['order'] = 1;
$PLUGIN_HOOKS['plugin_datainjection_populate']['order'] = "plugin_datainjection_populate_order";
}
}
}
/**
* Get the name and the version of the plugin
* REQUIRED
*
* @return array
*/
function plugin_version_order() {
return ['name' => __("Orders management", "order"),
'version' => PLUGIN_ORDER_VERSION,
'author' => 'The plugin order team',
'homepage' => 'https://github.com/pluginsGLPI/order',
'minGlpiVersion' => '0.85',
'license' => 'GPLv2+',
'requirements' => [
'glpi' => [
'min' => '9.2',
'dev' => true
]
]
];
}
/**
* Check pre-requisites before install
* OPTIONNAL, but recommanded
*
* @return boolean
*/
function plugin_order_check_prerequisites() {
$version = rtrim(GLPI_VERSION, '-dev');
if (version_compare($version, '9.2', 'lt')) {
echo "This plugin requires GLPI 9.2";
return false;
}
return true;
}
/**
* Check configuration process
*
* @param boolean $verbose Whether to display message on failure. Defaults to false
*
* @return boolean
*/
function plugin_order_check_config() {
return true;
}