Repository navigation
Expand file tree
/
Copy pathsetup.php
More file actions
executable file
·167 lines (149 loc) · 6.27 KB
/
Copy pathsetup.php
File metadata and controls
executable file
·167 lines (149 loc) · 6.27 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
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
<?php
/**
* -------------------------------------------------------------------------
* TimelineTicket
* Copyright (C) 2013-2026 by the TimelineTicket Development Team.
*
* https://github.com/pluginsGLPI/timelineticket
* ------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of TimelineTicket project.
*
* TimelineTicket plugin 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.
*
* TimelineTicket 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with TimelineTicket plugin. If not, see <http://www.gnu.org/licenses/>.
*
* ------------------------------------------------------------------------
*
* @copyright Copyright (C) 2013-2025 TimelineTicket team
* @license AGPL License 3.0 or (at your option) any later version
* @link https://github.com/pluginsGLPI/timelineticket
* @package TimelineTicket plugin
* @since 2013
* http://www.gnu.org/licenses/agpl-3.0-standalone.html
* --------------------------------------------------------------------------
*/
global $CFG_GLPI;
use Glpi\Plugin\Hooks;
use GlpiPlugin\Timelineticket\AssignGroup;
use GlpiPlugin\Timelineticket\AssignUser;
use GlpiPlugin\Timelineticket\Dashboard;
use GlpiPlugin\Timelineticket\Display;
use GlpiPlugin\Timelineticket\Profile;
define("PLUGIN_TIMELINETICKET_VERSION", "12.0.0");
if (!defined("PLUGIN_TIMELINETICKET_DIR")) {
define("PLUGIN_TIMELINETICKET_DIR", Plugin::getPhpDir("timelineticket"));
$root = $CFG_GLPI['root_doc'] . '/plugins/timelineticket';
define("PLUGIN_TIMELINETICKET_WEBDIR", $root);
}
function plugin_version_timelineticket()
{
return ['name' => _n("Timeline of ticket", "Timeline of tickets", 2, "timelineticket"),
'version' => PLUGIN_TIMELINETICKET_VERSION,
'homepage' => 'https://github.com/pluginsGLPI/timelineticket',
'license' => 'AGPLv3+',
'author' => 'Nelly Mahu-Lasson && David Durieux && Xavier Caillaud',
'requirements' => [
'glpi' => [
'min' => '11.0.99',
'max' => '12.0.99',
'dev' => false,
],
],
];
}
function plugin_init_timelineticket()
{
global $PLUGIN_HOOKS;
plugin_timelineticket_register_autoload();
if (Plugin::isPluginActive('timelineticket')) { // check if plugin is active
$PLUGIN_HOOKS[Hooks::CHANGE_PROFILE]['timelineticket'] = [Profile::class, 'initProfile'];
// The Google Charts bootstrap is only needed where a chart is actually drawn:
// Display::showTimelineGraph() injects it next to the chart markup. Registering it
// here would load it on every page of the central interface instead.
// Swimlane arrow renderer, loaded as an ES module (no inline <script>).
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_MODULE]['timelineticket'][] = 'js/swimlane.js';
$PLUGIN_HOOKS[Hooks::ADD_CSS]['timelineticket'][] = 'css/timelineticket.css';
Plugin::registerClass(Profile::class, ['addtabon' => 'Profile']);
if (Session::haveRightsOr(Display::$rightname, [READ, UPDATE])) {
// Same right gate as the Display tab: don't expose the stats hook
// to users who lack the plugin right.
$PLUGIN_HOOKS[Hooks::SHOW_ITEM_STATS]['timelineticket'] = [
'Ticket' => 'plugin_timelineticket_item_stats',
];
Plugin::registerClass(
Display::class,
['addtabon' => ['Ticket']],
);
}
$PLUGIN_HOOKS[Hooks::ITEM_PURGE]['timelineticket'] = [
'Ticket' => 'plugin_timelineticket_ticket_purge',
'Group_Ticket' => [AssignGroup::class, 'deleteGroupTicket'],
'Ticket_User' => [AssignUser::class, 'deleteUserTicket'],
];
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['timelineticket'] = [
'Ticket' => 'plugin_timelineticket_ticket_add',
'Group_Ticket' => [AssignGroup::class, 'addGroupTicket'],
'Ticket_User' => [AssignUser::class, 'addUserTicket'],
];
$PLUGIN_HOOKS[Hooks::ITEM_UPDATE]['timelineticket'] = [
'Ticket' => 'plugin_timelineticket_ticket_update',
];
if (Session::haveRight(\Config::$rightname, UPDATE)
|| Session::haveRight(Display::$rightname, UPDATE)) {// Config page
$PLUGIN_HOOKS[Hooks::CONFIG_PAGE]['timelineticket'] = 'front/config.form.php';
}
if (Plugin::isPluginActive('mydashboard')) {
$PLUGIN_HOOKS['mydashboard']['timelineticket'] = [Dashboard::class];
}
}
}
/**
* Register the autoloading of the plugin's only runtime dependency, sportlog/google-charts.
*
* vendor/autoload.php is deliberately not included: the vendor directory also holds the dev
* dependencies (glpi-project/tools for the shared translation workflows, which pulls
* symfony/console 6.x). Loaded on every request, they shadowed the core's own Symfony 7
* classes and broke bin/console (plugin:deactivate exited 255 on GLPI 12).
*/
function plugin_timelineticket_register_autoload(): void
{
static $registered = false;
if ($registered) {
return;
}
$registered = true;
spl_autoload_register(static function (string $class): void {
$prefix = 'Sportlog\\GoogleCharts\\';
if (!str_starts_with($class, $prefix)) {
return;
}
$file = __DIR__ . '/vendor/sportlog/google-charts/src/'
. str_replace('\\', '/', substr($class, strlen($prefix))) . '.php';
if (is_file($file)) {
require $file;
}
});
}
/**
* @return bool
*/
function plugin_timelineticket_check_prerequisites()
{
if (!is_dir(__DIR__ . '/vendor/sportlog/google-charts/src')) {
echo "Run composer install --no-dev in the plugin directory<br>";
return false;
}
return true;
}