-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook.php
More file actions
111 lines (98 loc) · 3.65 KB
/
Copy pathhook.php
File metadata and controls
111 lines (98 loc) · 3.65 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
<?php
/**
* -------------------------------------------------------------------------
* i-Vertix Monitoring plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of i-Vertix Monitoring plugin for GLPI.
*
* "i-Vertix Monitoring plugin for GLPI" 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 3 of the License, or
* (at your option) any later version.
*
* "i-Vertix Monitoring plugin for GLPI" 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 "i-Vertix Monitoring plugin for GLPI". If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2025 by i-Vertix/PGUM.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/i-Vertix/glpi-i-vertix-monitoring
* -------------------------------------------------------------------------
*/
use GlpiPlugin\Ivertixmonitoring\Host;
/**
* Plugin install process
*
* @return boolean
*/
function plugin_ivertixmonitoring_install($version)
{
/** @var DBmysql $DB */
global $DB;
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$table = Host::getTable();
if (!$DB->tableExists($table)) {
$query = "CREATE TABLE `$table` (
`id` int unsigned primary key not null auto_increment,
`itemtype` varchar(100) not null,
`item_id` int UNSIGNED not null,
`monitoring_id` int UNSIGNED not null,
`monitoring_type` varchar(100) default 'host'
) ENGINE=InnoDB
DEFAULT CHARSET={$default_charset}
COLLATE={$default_collation}";
$DB->doQuery($query);
$DB->doQuery("CREATE INDEX {$table}_index1 ON `$table` (itemtype, item_id);");
$DB->doQuery("CREATE INDEX {$table}_index2 ON `$table` (monitoring_type, monitoring_id);");
}
return true;
}
/**
* Plugin uninstall process
*
* @return boolean
*/
function plugin_ivertixmonitoring_uninstall()
{
/** @var DBmysql $DB */
global $DB;
$tables = [Host::getTable(), ];
foreach ($tables as $table) {
$migration = new Migration(PLUGIN_IVERTIXMONITORING_VERSION);
$migration->displayMessage("Uninstalling $table");
$migration->dropTable($table);
$DB->error();
}
$config = new Config();
$config->deleteByCriteria(['context' => 'plugin:ivertixmonitoring']);
return true;
}
function plugin_ivertixmonitoring_getAddSearchOptionsNew($itemtype)
{
$sopt = [];
if ($itemtype === 'Computer') {
$sopt[] = [
'id' => 6942,
'table' => Host::getTable(),
'field' => 'id',
'name' => __('i-Vertix Monitoring Host Status', 'ivertixmonitoring'),
'additionalfields' => ['monitoring_id'],
'datatype' => 'specific',
'nosearch' => true,
'nosort' => true,
'massiveaction' => false,
'joinparams' => [
'jointype' => 'itemtype_item',
],
];
}
return $sopt;
}