forked from mateusznitka/protocolsmanager
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetup.php
More file actions
74 lines (65 loc) · 2.4 KB
/
setup.php
File metadata and controls
74 lines (65 loc) · 2.4 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
<?php
// Plugin version info
function plugin_version_protocolsmanager(): array
{
return [
'name' => __('Protocols manager', 'protocolsmanager'),
'version' => '1.5.7.6',
'author' => 'Mikail',
'license' => 'GPLv3+',
'homepage' => 'https://github.com/CanMik/protocolsmanager',
'requirements' => [
'glpi' => [
'min' => '10.0.0',
'max' => '11.0.0'
],
'php' => [
'min' => '7.4'
]
]
];
}
// Config check
function plugin_protocolsmanager_check_config(): bool
{
return true;
}
// Prerequisites check
function plugin_protocolsmanager_check_prerequisites(): bool
{
if (version_compare(GLPI_VERSION, '10.0.0', '<') || version_compare(GLPI_VERSION, '11.0.0', '>')) {
if (method_exists('Plugin', 'messageIncompatible')) {
Plugin::messageIncompatible('core', '10.0.0', '11.0.0');
} else {
echo __('This plugin requires GLPI >= 10.0.0 and < 11.0.0', 'protocolsmanager');
}
return false;
}
return true;
}
// Init plugin hooks
function plugin_init_protocolsmanager(): void
{
global $PLUGIN_HOOKS, $DB;
$PLUGIN_HOOKS['csrf_compliant']['protocolsmanager'] = true;
$PLUGIN_HOOKS['add_css']['protocolsmanager'] = 'css/styles.css';
// Register tabs for supported item types
$tabTargets = [
'User', 'Printer', 'Peripheral', 'Computer',
'Phone', 'Line', 'Monitor'
];
foreach ($tabTargets as $target) {
Plugin::registerClass('PluginProtocolsmanagerGenerate', ['addtabon' => [$target]]);
}
Plugin::registerClass('PluginProtocolsmanagerProfile', ['addtabon' => ['Profile']]);
Plugin::registerClass('PluginProtocolsmanagerConfig', ['addtabon' => ['Config']]);
// --- SÉCURITÉ : ne pas appeler la table avant qu’elle n’existe ---
if ($DB->tableExists('glpi_plugin_protocolsmanager_profiles')) {
if (class_exists('PluginProtocolsmanagerProfile')
&& method_exists('PluginProtocolsmanagerProfile', 'currentUserHasRight')
&& PluginProtocolsmanagerProfile::currentUserHasRight('plugin_conf')) {
$PLUGIN_HOOKS['menu_toadd']['protocolsmanager'] = ['config' => 'PluginProtocolsmanagerMenu'];
$PLUGIN_HOOKS['config_page']['protocolsmanager'] = 'front/config.form.php';
}
}
}