-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsetup.php
162 lines (130 loc) · 4.96 KB
/
setup.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
<?php
/*
Copyright (C) 2016 Teclib'
Copyright (C) 2010-2016 by the FusionInventory Development Team.
This file is part of Armadito Plugin for GLPI.
Armadito Plugin for GLPI is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Armadito 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Armadito Plugin for GLPI. If not, see <http://www.gnu.org/licenses/>.
**/
include_once("inc/toolbox.class.php");
define("PLUGIN_ARMADITO_VERSION", "0.10.1");
// Minimal GLPI version, inclusive
define("PLUGIN_ARMADITO_MIN_GLPI", "9.3");
// Maximum GLPI version, exclusive
define("PLUGIN_ARMADITO_MAX_GLPI", "9.4");
function plugin_init_armadito()
{
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['armadito'] = TRUE;
$debug_mode = getDebugmode();
$Plugin = new Plugin();
if ($Plugin->isActivated('armadito'))
{
registerPluginArmaditoClasses();
setPluginArmaditoHooks($debug_mode);
}
}
function getDebugmode()
{
if (!isset($_SESSION['glpi_use_mode'])) {
return ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE);
}
return false;
}
function registerPluginArmaditoClasses()
{
$types = array(
'Central',
'Preference',
'Profile'
);
Plugin::registerClass('PluginArmaditoAgent', array(
'addtabon' => $types,
'link_types' => true
));
Plugin::registerClass('PluginArmaditoState');
Plugin::registerClass('PluginArmaditoStateUpdateDetail');
}
function setPluginArmaditoHooks( $debug_mode )
{
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['use_massive_action']['armadito'] = 1;
$PLUGIN_HOOKS['add_javascript']['armadito'] = array();
$PLUGIN_HOOKS['add_css']['armadito'] = array();
if (scriptEndsWith("menu.php") || scriptEndsWith("board.php") || scriptEndsWith("config.form.php"))
{
$PLUGIN_HOOKS['add_javascript']['armadito'][] = "js/stats" . ($debug_mode ? "" : ".min") . ".js";
array_push($PLUGIN_HOOKS['add_javascript']['armadito'],
"vendor/mbostock/d3/d3" . ($debug_mode ? "" : ".min") . ".js",
"vendor/novus/nvd3/build/nv.d3" . ($debug_mode ? "" : ".min") . ".js");
}
if (Session::haveRight('plugin_armadito_configuration', READ) || Session::haveRight('profile', UPDATE)) {
$PLUGIN_HOOKS['config_page']['armadito'] = 'front/config.form.php' . '?itemtype=pluginarmaditoconfig&glpi_tab=1';
}
$_SESSION["glpi_plugin_armadito_profile"]['armadito'] = 'w';
if (isset($_SESSION["glpi_plugin_armadito_profile"])) {
$PLUGIN_HOOKS['menu_toadd']['armadito']['plugins'] = 'PluginArmaditoMenu';
}
$PLUGIN_HOOKS['fusioninventory_inventory']['armadito']
= array('PluginArmaditoAgentAssociation', 'fusionInventoryHook');
$PLUGIN_HOOKS['item_purge']['armadito'] = array('PluginArmaditoAgent' => array('PluginArmaditoAgent', 'purgeHook'));
}
function scriptEndsWith($scriptname)
{
return substr($_SERVER['SCRIPT_FILENAME'], -strlen($scriptname)) === $scriptname;
}
function plugin_version_armadito()
{
return [
'name' => 'Armadito',
'shortname' => 'armadito',
'version' => PLUGIN_ARMADITO_VERSION,
'author' => '<a href="mailto:[email protected]">Teclib\'</a>',
'license' => 'AGPLv3+',
'homepage' => 'http://armadito-glpi.readthedocs.io/en/dev/index.html',
'requirements' => [
'glpi' => [
'min' => PLUGIN_ARMADITO_MIN_GLPI,
'max' => PLUGIN_ARMADITO_MAX_GLPI,
]
]
];
}
function plugin_armadito_check_prerequisites()
{
//Version check is not done by core in GLPI < 9.2 but has to be delegated to core in GLPI >= 9.2.
if (!method_exists('Plugin', 'checkGlpiVersion')) {
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
$matchMinGlpiReq = version_compare($version, PLUGIN_ARMADITO_MIN_GLPI, '>=');
$matchMaxGlpiReq = version_compare($version, PLUGIN_ARMADITO_MAX_GLPI, '<');
if (!$matchMinGlpiReq || !$matchMaxGlpiReq) {
echo vsprintf(
__('This plugin requires GLPI >= %1$s and < %2$s.', 'armadito'),
[
PLUGIN_ARMADITO_MIN_GLPI,
PLUGIN_ARMADITO_MAX_GLPI,
]
);
return false;
}
}
return true;
}
function plugin_armadito_check_config($verbose = false)
{
return true;
}
// center all columns of plugin
function plugin_armadito_displayConfigItem($itemtype, $ID, $data, $num)
{
return "align='center'";
}
?>