-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsetup.php
More file actions
213 lines (189 loc) · 9.71 KB
/
Copy pathsetup.php
File metadata and controls
213 lines (189 loc) · 9.71 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/**
* -------------------------------------------------------------------------
* mydashboard plugin for GLPI
* Copyright (C) 2016-2026 by the mydashboard Development Team.
*
* https://github.com/InfotelGLPI/mydashboard
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of mydashboard.
*
* mydashboard 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.
*
* mydashboard 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 mydashboard. If not, see <http://www.gnu.org/licenses/>.
* --------------------------------------------------------------------------
*/
define('PLUGIN_MYDASHBOARD_VERSION', '2.3.9');
global $CFG_GLPI;
use Glpi\Plugin\Hooks;
use GlpiPlugin\Mydashboard\Alert;
use GlpiPlugin\Mydashboard\Config;
use GlpiPlugin\Mydashboard\Customswidget;
use GlpiPlugin\Mydashboard\HTMLEditor;
use GlpiPlugin\Mydashboard\Menu;
use GlpiPlugin\Mydashboard\Preference;
use GlpiPlugin\Mydashboard\Profile;
use GlpiPlugin\Mydashboard\Reports\MyCustomGraph;
use GlpiPlugin\Mydashboard\Servicecatalog;
if (!defined("PLUGIN_MYDASHBOARD_DIR")) {
define("PLUGIN_MYDASHBOARD_DIR", Plugin::getPhpDir("mydashboard"));
$root = $CFG_GLPI['root_doc'] . '/plugins/mydashboard';
define("PLUGIN_MYDASHBOARD_WEBDIR", $root);
}
// Init the hooks of the plugins -Needed
function plugin_init_mydashboard()
{
global $PLUGIN_HOOKS;
// Classes de widgets custom — chargées via le hook natif de Widgetlist::getList()
$PLUGIN_HOOKS['mydashboard']['custom'] = [
MyCustomGraph::class,
];
// Lorsque cette liste change, incrémenter $custom_version pour forcer
// le réenregistrement en DB et l'invalidation du cache session de widgets.
$custom_version = 'v1';
if (Plugin::isPluginActive('mydashboard')
&& Session::getLoginUserID()
&& ($_SESSION['glpi_plugin_mydashboard_custom_v'] ?? '') !== $custom_version) {
Menu::installWidgets();
unset($_SESSION['glpi_plugin_mydashboard_widget_list']);
$_SESSION['glpi_plugin_mydashboard_custom_v'] = $custom_version;
}
$PLUGIN_HOOKS[Hooks::DISPLAY_LOGIN]['mydashboard'] = "plugin_mydashboard_display_login";
$PLUGIN_HOOKS[Hooks::ADD_CSS]['mydashboard'] = [
"css/mydashboard.css",
"css/jquery.newsTicker.css",
];
if (Session::getCurrentInterface() == 'central') {
// ECharts is deliberately absent here. The charts are only ever drawn by
// Menu::loadDashboard(), which loads the engine of the core and the theme the
// user actually picked; registering a bundle on every page of the central
// interface instead put a second copy of ECharts on top of the one of the core,
// and pinned every profile to the single theme named on this line.
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'lib/fuse.js';
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'lib/diacritics.js';
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'lib/md-fuzzysearch.js';
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'lib/jquery-fullscreen-plugin/jquery.fullscreen-min.js';
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'scripts/mydashboard.js';
}
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'lib/jquery-advanced-news-ticker/jquery.newsTicker.min.js';
$PLUGIN_HOOKS[Hooks::CHANGE_PROFILE]['mydashboard'] = [Profile::class, 'initProfile'];
if (Session::getLoginUserID()) {
Plugin::registerClass(Profile::class, ['addtabon' => 'Profile']);
if (Plugin::isPluginActive("mydashboard")) {
//If user has right to see configuration
if (Session::haveRightsOr("plugin_mydashboard_config", [CREATE, UPDATE])) {
$PLUGIN_HOOKS[Hooks::CONFIG_PAGE]['mydashboard'] = 'front/config.form.php';
// $PLUGIN_HOOKS['menu_toadd']['mydashboard']['links']['config'] = 'front/config.form.php';
}
if (Plugin::isPluginActive('servicecatalog')) {
$PLUGIN_HOOKS['servicecatalog']['mydashboard'] = [Servicecatalog::class];
}
if (Session::haveRightsOr("plugin_mydashboard", [CREATE, READ])) {
$PLUGIN_HOOKS[Hooks::MENU_TOADD]['mydashboard'] = ['tools' => Menu::class];
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY]['mydashboard'] = PLUGIN_MYDASHBOARD_WEBDIR . '/front/menu.php';
$PLUGIN_HOOKS[Hooks::HELPDESK_MENU_ENTRY_ICON]['mydashboard'] = Menu::getIcon();
if (Plugin::isPluginActive('servicecatalog')
&& Session::haveRight("plugin_servicecatalog", READ)) {
unset($PLUGIN_HOOKS['helpdesk_menu_entry']['mydashboard']);
}
if (isset($_SERVER['HTTP_REFERER'])
&& strpos($_SERVER['HTTP_REFERER'], 'redirect') !== false
&& strpos($_SERVER['REQUEST_URI'], 'apirest.php') === false) {
$_SESSION["glpi_plugin_mydashboard_loaded"] = 1;
}
if (isset($_SESSION["glpi_plugin_mydashboard_loaded"])
&& $_SESSION["glpi_plugin_mydashboard_loaded"] == 0) {
if (strpos($_SERVER['REQUEST_URI'], 'central.php?redirect') === false
&& strpos($_SERVER['REQUEST_URI'], 'apirest.php') === false) {
if (Session::getCurrentInterface() == 'central') {
if (!$_SESSION['glpiactiveprofile']['create_ticket_on_login']) {
$_SESSION["glpi_plugin_mydashboard_loaded"] = 1;
// Html::redirect(PLUGIN_MYDASHBOARD_WEBDIR . "/front/menu.php");
$dest = PLUGIN_MYDASHBOARD_WEBDIR . "/front/menu.php";
$toadd = '';
$dest = addslashes($dest);
echo "<script type='text/javascript'>
NomNav = navigator.appName;
if (NomNav=='Konqueror') {
window.location='" . $dest . $toadd . "';
} else {
window.location='" . $dest . "';
}
</script>";
exit();
} elseif (!Plugin::isPluginActive("servicecatalog")
|| Session::haveRight("plugin_servicecatalog", 1)) {
$_SESSION["glpi_plugin_mydashboard_loaded"] = 1;
// Html::redirect(PLUGIN_MYDASHBOARD_WEBDIR . "/front/menu.php");
$dest = PLUGIN_MYDASHBOARD_WEBDIR . "/front/menu.php";
$toadd = '';
$dest = addslashes($dest);
echo "<script type='text/javascript'>
NomNav = navigator.appName;
if (NomNav=='Konqueror') {
window.location='" . $dest . $toadd . "';
} else {
window.location='" . $dest . "';
}
</script>";
}
}
}
}
if (Session::getCurrentInterface() == 'central') {
if (Preference::getReplaceCentral()
&& Session::haveRightsOr("plugin_mydashboard", [CREATE, READ])) {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'scripts/replace_central.js';
} elseif (Config::getReplaceCentralConf()
&& Preference::getReplaceCentral()
&& Session::haveRightsOr("plugin_mydashboard", [CREATE, READ])) {
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['mydashboard'][] = 'scripts/replace_central.js';
}
}
Plugin::registerClass(
Preference::class,
['addtabon' => 'Preference'],
);
Plugin::registerClass(
Alert::class,
['addtabon' => ['Reminder', 'Problem', 'Change']],
);
Plugin::registerClass(HTMLEditor::class, ['addtabon' => Customswidget::class]);
}
$PLUGIN_HOOKS[Hooks::PRE_ITEM_PURGE]['mydashboard'] = ['Reminder' => [Alert::class,
'purgeAlerts']];
}
}
}
// Get the name and the version of the plugin - Needed
/**
* @return array
*/
function plugin_version_mydashboard()
{
return [
'name' => __('My Dashboard', 'mydashboard'),
'version' => PLUGIN_MYDASHBOARD_VERSION,
'author' => "<a href='https://blogglpi.infotel.com'>Infotel</a>, Xavier CAILLAUD",
'license' => 'GPLv3+',
'homepage' => 'https://github.com/InfotelGLPI/mydashboard',
'requirements' => [
'glpi' => [
'min' => '11.0',
'max' => '12.0',
'dev' => false,
],
]];
}