-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.php
More file actions
113 lines (92 loc) · 4.04 KB
/
setup.php
File metadata and controls
113 lines (92 loc) · 4.04 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
<?php
/*
* @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $
-------------------------------------------------------------------------
vip plugin for GLPI
Copyright (C) 2016-2022 by the vip Development Team.
https://github.com/InfotelGLPI/vip
-------------------------------------------------------------------------
LICENSE
This file is part of vip.
vip 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.
vip 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 vip. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
use Glpi\Plugin\Hooks;
use GlpiPlugin\Vip\Dashboard;
use GlpiPlugin\Vip\Profile;
use GlpiPlugin\Vip\RuleVipCollection;
use GlpiPlugin\Vip\Ticket;
use GlpiPlugin\Vip\Vip;
use GlpiPlugin\Vip\Group;
global $CFG_GLPI;
define('PLUGIN_VIP_VERSION', '1.9.2');
if (!defined("PLUGIN_VIP_DIR")) {
define("PLUGIN_VIP_DIR", Plugin::getPhpDir("vip"));
$root = $CFG_GLPI['root_doc'] . '/plugins/vip';
define("PLUGIN_VIP_WEBDIR", $root);
}
// Init the hooks of the plugins -Needed
function plugin_init_vip()
{
global $PLUGIN_HOOKS;
Plugin::registerClass(Profile::class, ['addtabon' => ['Profile']]);
$PLUGIN_HOOKS[Hooks::CHANGE_PROFILE]['vip'] = [Profile::class, 'changeProfile'];
if (Session::haveRight('plugin_vip', UPDATE)) {
Plugin::registerClass(Group::class, ['addtabon' => ['Group']]);
$PLUGIN_HOOKS[Hooks::USE_MASSIVE_ACTION]['vip'] = 1;
Plugin::registerClass(Ticket::class);
}
if (class_exists('PluginMydashboardMenu')) {
$PLUGIN_HOOKS['mydashboard']['vip'] = [Dashboard::class];
}
if (Session::haveRight('plugin_vip', READ)
&& isset($_SESSION["glpiactiveprofile"]["interface"])
&& $_SESSION["glpiactiveprofile"]["interface"] != "helpdesk") {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['vip'][] = 'js/vip.js.php';
// $PLUGIN_HOOKS["javascript"]['vip'] = [PLUGIN_VIP_NOTFULL_DIR."/js/vip.js.php"];
if (class_exists(Ticket::class)) {
foreach (Ticket::$types as $item) {
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], strtolower($item) . ".form.php") !== false) {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['vip'][] = 'js/vip_load_scripts.js.php';
}
}
}
}
if (isset($_SESSION["glpiactiveprofile"]["interface"])
&& $_SESSION["glpiactiveprofile"]["interface"] != "helpdesk") {
$PLUGIN_HOOKS['pre_show_item']['vip'] = [Ticket::class, 'showVIPInfos'];
}
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['vip'] = ['User' => [Vip::class, 'afterAdd']];
$PLUGIN_HOOKS[Hooks::ITEM_UPDATE]['vip'] = ['User' => [Vip::class, 'afterUpdate']];
Plugin::registerClass(RuleVipCollection::class, [
'rulecollections_types' => true
]);
// Cannot be placed inside any permission check as the plugin is initialized before the API router authenticates the user
//TODO activate in GLPI 11 version
// $PLUGIN_HOOKS[Hooks::REDEFINE_API_SCHEMAS]['vip'] = 'plugin_vip_redefine_api_schemas';
}
function plugin_version_vip()
{
return ['name' => "VIP",
'version' => PLUGIN_VIP_VERSION,
'author' => '<a href="http://www.probesys.com">Probesys</a> & <a href="https//blogglpi.infotel.com">Infotel</a>, Xavier CAILLAUD',
'license' => 'AGPLv3+',
'homepage' => 'https://github.com/pluginsGLPI/vip',
'requirements' => [
'glpi' => [
'min' => '11.0',
'max' => '12.0',
'dev' => false
]
]
];
}