Repository navigation
Expand file tree
/
Copy pathsetup.php
More file actions
executable file
路80 lines (69 loc) 路 2.57 KB
/
Copy pathsetup.php
File metadata and controls
executable file
路80 lines (69 loc) 路 2.57 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
<?php
define('PLUGIN_MAILAPROVE_VERSION', '1.0.5');
define('PLUGIN_MAILAPROVE_MIN_GLPI', '11.0.0');
define('PLUGIN_MAILAPROVE_MAX_GLPI', '11.99.99');
use Glpi\Plugin\Hooks;
use GlpiPlugin\Mailaprove\NotificationHandler;
function plugin_version_mailaprove(): array
{
return [
'name' => 'Approval By Mail',
'version' => PLUGIN_MAILAPROVE_VERSION,
'author' => 'Celso Caninde',
'license' => 'GPLv3+',
'homepage' => 'https://github.com/celsocaninde/mailaprove',
'minGlpiVersion' => PLUGIN_MAILAPROVE_MIN_GLPI,
'maxGlpiVersion' => PLUGIN_MAILAPROVE_MAX_GLPI,
'requirements' => [
'glpi' => [
'min' => PLUGIN_MAILAPROVE_MIN_GLPI,
'max' => PLUGIN_MAILAPROVE_MAX_GLPI,
],
],
];
}
function plugin_init_mailaprove(): void
{
global $PLUGIN_HOOKS;
// CSRF compliance (required in GLPI 11)
$PLUGIN_HOOKS[Hooks::CSRF_COMPLIANT]['mailaprove'] = true;
// Register notification data hook - injects custom tags
$PLUGIN_HOOKS[Hooks::ITEM_GET_DATA]['mailaprove'] = [
'NotificationTargetTicket' => [NotificationHandler::class, 'handleNotificationData'],
];
// Public mail links must be reachable without an authenticated GLPI session.
// In GLPI 11, stateless plugin paths bypass session, firewall and CSRF checks.
if (
class_exists(\Glpi\Http\SessionManager::class)
&& method_exists(\Glpi\Http\SessionManager::class, 'registerPluginStatelessPath')
) {
\Glpi\Http\SessionManager::registerPluginStatelessPath(
'mailaprove',
'#^/front/(approve|reject|solution_approve|solution_reject|satisfaction)\.php$#'
);
}
// Admin menu for configuration
if (Plugin::isPluginActive('mailaprove')) {
$PLUGIN_HOOKS['config_page']['mailaprove'] = 'front/config.form.php';
if (Session::haveRight('config', UPDATE)) {
$PLUGIN_HOOKS['menu_toadd']['mailaprove'] = [
'config' => 'GlpiPlugin\\Mailaprove\\Config',
];
}
}
}
function plugin_mailaprove_check_prerequisites(): bool
{
if (!method_exists('Plugin', 'checkGlpiVersion')) {
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
if (version_compare($version, PLUGIN_MAILAPROVE_MIN_GLPI, '<')) {
echo 'This plugin requires GLPI >= ' . PLUGIN_MAILAPROVE_MIN_GLPI;
return false;
}
}
return true;
}
function plugin_mailaprove_check_config($verbose = false): bool
{
return true;
}