-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.php
172 lines (150 loc) · 5.9 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
163
164
165
166
167
168
169
170
171
172
<?php
/**
* -------------------------------------------------------------------------
* YAGP plugin for GLPI
* Copyright (C) 2019-2024 by the TICgal Team.
* https://tic.gal/en/project/yagp-yet-another-glpi-plugin/
* -------------------------------------------------------------------------
* LICENSE
* This file is part of the YAGP plugin.
* YAGP 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 3 of the License, or
* (at your option) any later version.
* YAGP 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 YAGP. If not, see <http://www.gnu.org/licenses/>.
* --------------------------------------------------------------------------
* @package YAGP
* @author the TICgal team
* @copyright Copyright (c) 2019-2024 TICgal team
* @license AGPL License 3.0 or (at your option) any later version
* http://www.gnu.org/licenses/agpl-3.0-standalone.html
* @link https://tic.gal/en/project/yagp-yet-another-glpi-plugin/
* @since 2019
* ----------------------------------------------------------------------
*/
use Glpi\Plugin\Hooks;
define('PLUGIN_YAGP_VERSION', '2.4.1');
// Minimal GLPI version, inclusive
define("PLUGIN_YAGP_MIN_GLPI", "10.0");
// Maximum GLPI version, exclusive
define("PLUGIN_YAGP_MAX_GLPI", "11.0");
/**
* plugin_version_yagp
*
* @return array
*/
function plugin_version_yagp(): array
{
return [
'name' => 'YAGP',
'version' => PLUGIN_YAGP_VERSION,
'author' => '<a href="https://tic.gal">TICgal</a>',
'homepage' => 'https://tic.gal/yagp',
'license' => 'GPLv3+',
'minGlpiVersion' => PLUGIN_YAGP_MIN_GLPI,
'requirements' => [
'glpi' => [
'min' => PLUGIN_YAGP_MIN_GLPI,
'max' => PLUGIN_YAGP_MAX_GLPI,
]
]
];
}
/**
* plugin_init_yagp
*
* @return void
*/
function plugin_init_yagp(): void
{
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS[Hooks::CSRF_COMPLIANT]['yagp'] = true;
if (Session::haveRightsOr("config", [READ, UPDATE])) {
Plugin::registerClass('PluginYagpConfig', ['addtabon' => 'Config']);
$PLUGIN_HOOKS['config_page']['yagp'] = 'front/config.form.php';
}
$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['yagp'] = [
PluginYagpConfig::class => 'plugin_yagp_updateitem'
];
$plugin = new Plugin();
if ($plugin->isActivated('yagp')) {
Plugin::registerClass(PluginYagpTransfer::class);
Plugin::registerClass('PluginYagpProfile', ['addtabon' => 'Profile']);
$config = PluginYagpConfig::getInstance();
/**** Deprecated
* if ($config->fields['fixedmenu']) {
* $PLUGIN_HOOKS['add_css']['yagp']='fixedmenu.css';
}****/
if ($config->fields['gototicket']) {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['yagp'][] = 'js/gototicket.js';
}
if ($config->fields['blockdate']) {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['yagp'][] = 'js/blockdate.js';
}
if ($config->fields['findrequest']) {
if (
!is_null($config->fields['requestlabel'])
&& $config->fields['requestlabel'] != ""
) {
$PLUGIN_HOOKS[Hooks::PRE_ITEM_ADD]['yagp'] = [
Ticket::class => [
PluginYagpTicket::class, 'preAddTicket'
]
];
}
}
$PLUGIN_HOOKS[Hooks::PRE_SHOW_TAB]['yagp'] = 'plugin_yagp_pre_show_tab';
$PLUGIN_HOOKS[Hooks::POST_SHOW_TAB]['yagp'] = 'plugin_yagp_post_show_tab';
if ($config->fields['recategorization'] || $config->fields['autoclose_rejected_tickets']) {
$PLUGIN_HOOKS[Hooks::ITEM_UPDATE]['yagp'] = [
Ticket::class => [
PluginYagpTicket::class, 'pluginYagpItemUpdate'
],
];
$PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['yagp'] = [
PluginYagpTicket::class, 'plugin_yagp_postItemForm'
];
}
if ($config->fields['hide_historical']) {
$PLUGIN_HOOKS[Hooks::PRE_SHOW_ITEM]['yagp'] = [
PluginYagpTicket::class, 'plugin_yagp_preShowItem'
];
}
if ($config->fields['private_view'] || $config->fields['quick_transfer']) {
$PLUGIN_HOOKS[Hooks::POST_SHOW_ITEM]['yagp'] = [
PluginYagpPostshowitem::class, 'pluginYagpPostShowItem'
];
}
if ($config->fields['autoclose_rejected_tickets']) {
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['yagp'][ITILFollowup::class] = [
PluginYagpTicket::class, 'pluginYagpItemAdd'
];
}
if (!empty($config->fields['solutiontypes'])) {
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['yagp'][ITILSolution::class] = [
PluginYagpTicket::class, 'pluginYagpItemAdd'
];
}
$PLUGIN_HOOKS[Hooks::ITEM_CAN]['yagp'][Ticket::class] = [
PluginYagpProfile::class, 'checkAllocatorAccess'
];
$PLUGIN_HOOKS['add_default_join']['yagp'] = "Plugin_Yagp_addDefaultJoin";
$PLUGIN_HOOKS['add_default_where']['yagp'] = "Plugin_Yagp_addDefaultWhere";
Crontask::Register(
'PluginYagpTicket',
'pluginyagpticketsatisfaction',
DAY_TIMESTAMP,
[
'state' => 0,
'mode' => CronTask::MODE_EXTERNAL,
'hourmin' => 0,
'horumax' => 24
]
);
}
}