-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.php
327 lines (211 loc) · 7.61 KB
/
hook.php
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
/*
* @version $Id$
-------------------------------------------------------------------------
FusionInventory
Copyright (C) 2003-2010 by the INDEPNET Development Team.
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
-------------------------------------------------------------------------
LICENSE
This file is part of FusionInventory plugins.
FusionInventory 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.
FusionInventory 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 FusionInventory; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: DURIEUX David
// Purpose of file:
// ----------------------------------------------------------------------
function plugin_fusinvinventory_getAddSearchOptions($itemtype) {
global $LANG;
$sopt = array();
if ($itemtype == 'Computer') {
$sopt[1071]['table'] = 'glpi_plugin_fusinvinventory_antivirus';
$sopt[1071]['field'] = 'name';
$sopt[1071]['linkfield'] = '';
$sopt[1071]['name'] = 'Antivirus name';
$sopt[1071]['datatype'] = 'text';
$sopt[1072]['table'] = 'glpi_plugin_fusinvinventory_antivirus';
$sopt[1072]['field'] = 'version';
$sopt[1072]['linkfield'] = '';
$sopt[1072]['name'] = 'Antivirus version';
$sopt[1072]['datatype'] = 'text';
$sopt[1073]['table'] = 'glpi_plugin_fusinvinventory_antivirus';
$sopt[1073]['field'] = 'is_active';
$sopt[1073]['linkfield'] = '';
$sopt[1073]['name'] = 'Antivirus activé';
$sopt[1073]['datatype'] = 'bool';
$sopt[1074]['table'] = 'glpi_plugin_fusinvinventory_antivirus';
$sopt[1074]['field'] = 'uptodate';
$sopt[1074]['linkfield'] = '';
$sopt[1074]['name'] = 'Antivirus à jour';
$sopt[1074]['datatype'] = 'bool';
}
return $sopt;
}
function plugin_fusinvinventory_giveItem($type,$id,$data,$num) {
return "";
}
// Define Dropdown tables to be manage in GLPI :
function plugin_fusinvinventory_getDropdown() {
return array ();
}
/* Cron */
function cron_plugin_fusinvinventory() {
return 1;
}
function plugin_fusinvinventory_install() {
global $DB, $LANG, $CFG_GLPI;
include (GLPI_ROOT . "/plugins/fusinvinventory/install/install.php");
pluginFusinvinventoryInstall();
return true;
}
// Uninstall process for plugin : need to return true if succeeded
function plugin_fusinvinventory_uninstall() {
include (GLPI_ROOT . "/plugins/fusinvinventory/install/install.php");
pluginFusinvinventoryUninstall();
}
/**
* Check if Fusinvinventory need to be updated
*
* @param
*
* @return 0 (no need update) OR 1 (need update)
**/
function plugin_fusinvinventory_needUpdate() {
$version = "2.3.0";
include (GLPI_ROOT . "/plugins/fusinvinventory/install/update.php");
$version_detected = pluginFusinvinventoryGetCurrentVersion($version);
if ((isset($version_detected)) AND ($version_detected != $version)) {
return 1;
} else {
return 0;
}
}
// Define headings added by the plugin //
function plugin_get_headings_fusinvinventory($item,$withtemplate) {
global $LANG;
switch (get_class($item)) {
case 'Computer' :
$array = array ();
if ($_GET['id'] > 0) {
$array[1] = $LANG['plugin_fusioninventory']['title'][1]." ".$LANG['plugin_fusioninventory']['xml'][0];
$array[2] = $LANG['plugin_fusinvinventory']['antivirus'][0];
}
return $array;
break;
}
}
// Define headings actions added by the plugin
function plugin_headings_actions_fusinvinventory($item) {
switch (get_class($item)) {
case 'Computer' :
$array = array ();
$array[1] = "plugin_headings_fusinvinventory_xml";
$array[2] = "plugin_headings_fusinvinventory_antivirus";
return $array;
break;
}
}
function plugin_headings_fusinvinventory_xml($item) {
global $LANG;
$id = $item->getField('id');
$folder = substr($id,0,-1);
if (empty($folder)) {
$folder = '0';
}
if (file_exists(GLPI_PLUGIN_DOC_DIR."/fusinvinventory/".$folder."/".$id)) {
$xml = file_get_contents(GLPI_PLUGIN_DOC_DIR."/fusinvinventory/".$folder."/".$id);
$xml = str_replace("<", "<", $xml);
$xml = str_replace(">", ">", $xml);
$xml = str_replace("\n", "<br/>", $xml);
echo "<table class='tab_cadre_fixe' cellpadding='1'>";
echo "<tr>";
echo "<th>".$LANG['plugin_fusioninventory']['title'][1]." ".$LANG['plugin_fusioninventory']['xml'][0];
echo " (".$LANG['common'][26]." : " . convDateTime(date("Y-m-d H:i:s", filemtime(GLPI_PLUGIN_DOC_DIR."/fusinvinventory/".$folder."/".$id))).")";
echo "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td width='130'>";
echo "<pre width='130'>".$xml."</pre>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
}
function plugin_headings_fusinvinventory_antivirus($item) {
global $LANG;
$items_id = $item->getField('id');
$PluginFusinvinventoryAntivirus = new PluginFusinvinventoryAntivirus();
$PluginFusinvinventoryAntivirus->showForm($items_id);
}
function plugin_headings_fusinvinventory($type,$id,$withtemplate=0) {
global $CFG_GLPI;
}
function plugin_fusinvinventory_MassiveActions($type) {
global $LANG;
}
function plugin_fusinvinventory_MassiveActionsDisplay($type, $action) {
global $LANG, $CFG_GLPI, $DB;
}
function plugin_fusinvinventory_MassiveActionsProcess($data) {
global $LANG;
}
// Massive Action functions
function plugin_fusinvinventory_MassiveActionsFieldsDisplay($type,$table,$field,$linkfield) {
global $LINK_ID_TABLE,$LANG;
}
function plugin_fusinvinventory_addSelect($type,$id,$num) {
return "";
}
function plugin_fusinvinventory_forceGroupBy($type) {
return false;
}
function plugin_fusinvinventory_addLeftJoin($itemtype,$ref_table,$new_table,$linkfield,&$already_link_tables) {
if ($itemtype == 'Computer') {
return " LEFT JOIN `$new_table` ON (`$ref_table`.`id` = `$new_table`.`computers_id`) ";
}
return "";
}
function plugin_fusinvinventory_addOrderBy($type,$id,$order,$key=0) {
return "";
}
function plugin_fusinvinventory_addWhere($link,$nott,$type,$id,$val) {
return "";
}
function plugin_pre_item_purge_fusinvinventory($item) {
switch (get_class($item)) {
case 'Computer' :
$PluginFusinvinventoryLib = new PluginFusinvinventoryLib();
$PluginFusinvinventoryLib->removeExternalid($item->getField('id'));
break;
}
}
function plugin_pre_item_delete_fusinvinventory($parm) {
return $parm;
}
/**
* Hook after updates
*
* @param $parm
* @return nothing
*
**/
function plugin_item_update_fusinvinventory($parm) {
}
function plugin_item_add_fusinvinventory($parm) {
}
function plugin_fusinvinventory_registerMethods() {
global $WEBSERVICES_METHOD;
$WEBSERVICES_METHOD['fusioninventory.test'] = array('PluginfusioninventoryWebservice','methodTest');
}
?>