forked from ticgal/actualtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
69 lines (62 loc) · 2.29 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
<?php
define ('PLUGIN_ACTUALTIME_VERSION', '1.1.0');
// Minimal GLPI version, inclusive
define("PLUGIN_ACTUALTIME_MIN_GLPI", "9.3.0");
// Maximum GLPI version, exclusive
define("PLUGIN_ACTUALTIME_MAX_GLPI", "9.5");
function plugin_version_actualtime() {
return ['name' => 'ActualTime',
'version' => PLUGIN_ACTUALTIME_VERSION,
'author' => '<a href="https://tic.gal">TICgal</a>',
'homepage' => 'https://tic.gal/en/project/actualtime-plugin-glpi/',
'license' => 'AGPLv3+',
'requirements' => [
'glpi' => [
'min' => PLUGIN_ACTUALTIME_MIN_GLPI,
// Allow all version from PLUGIN_ACTUALTIME_MIN_GLPI
//'max' => PLUGIN_ACTUALTIME_MAX_GLPI,
]
]];
}
/**
* Check plugin's prerequisites before installation
*/
function plugin_actualtime_check_prerequisites() {
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
// Devel version allowed
if ($version == '10.0.0') {
return true;
}
$matchMinGlpiReq = version_compare($version, PLUGIN_ACTUALTIME_MIN_GLPI, 'ge');
$matchMaxGlpiReq = version_compare($version, PLUGIN_ACTUALTIME_MAX_GLPI, 'lt');
if (!$matchMinGlpiReq || !$matchMaxGlpiReq) {
if (method_exists('Plugin', 'messageIncompatible')) {
//since GLPI 9.2
Plugin::messageIncompatible('core', PLUGIN_ACTUALTIME_MIN_GLPI, PLUGIN_ACTUALTIME_MAX_GLPI);
} else {
echo vsprintf(
'This plugin requires GLPI >= %1$s and < %2$s.',
[
PLUGIN_ACTUALTIME_MIN_GLPI,
PLUGIN_ACTUALTIME_MAX_GLPI,
]
);
}
return false;
}
return true;
}
/**
* Check plugin's config before activation
*/
function plugin_actualtime_check_config($verbose = false) {
return true;
}
function plugin_init_actualtime() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['actualtime'] = true;
$PLUGIN_HOOKS['post_item_form']['actualtime'] = ['PluginActualtimeTask', 'postForm'];
$PLUGIN_HOOKS['show_item_stats']['actualtime'] = ['Ticket'=> 'plugin_activetime_item_stats'];
$PLUGIN_HOOKS['pre_item_update']['actualtime'] = ['TicketTask'=>'plugin_activetime_item_update'];
$PLUGIN_HOOKS['post_show_item']['actualtime'] = ['PluginActualtimeTask', 'postShowItem'];
}