forked from Probesys/glpi-plugins-groupcategory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
76 lines (68 loc) · 2.24 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
70
71
72
73
74
75
76
<?php
// Version of the plugin
define('PLUGIN_GROUPCATEGORY_VERSION', "1.4.0RC3");
define('PLUGIN_GROUPCATEGORY_GLPI_MIN_VERSION', '9.4');
define('PLUGIN_GROUPCATEGORY_NAMESPACE', 'groupcategory');
// Maximum GLPI version, exclusive
define("PLUGIN_GROUPCATEGORY_GLPI_MAX_VERSION", "9.6");
if (!defined("PLUGIN_GROUPCATEGORY_DIR")) {
define("PLUGIN_GROUPCATEGORY_DIR", Plugin::getPhpDir("groupcategory"));
}
if (!defined("PLUGIN_GROUPCATEGORY_WEB_DIR")) {
define("PLUGIN_GROUPCATEGORY_WEB_DIR", Plugin::getWebDir("groupcategory"));
}
/**
* Plugin description
*
* @return boolean
*/
function plugin_version_groupcategory()
{
return [
'name' => 'GroupCategory',
'version' => PLUGIN_GROUPCATEGORY_VERSION,
'author' => '<a href="https://www.probesys.com">PROBESYS</a>',
'homepage' => 'https://github.com/Probesys/glpi-plugins-groupcategory',
'license' => 'GPLv2+',
'minGlpiVersion' => PLUGIN_GROUPCATEGORY_GLPI_MIN_VERSION,
];
}
/**
* Initialize plugin
*
* @return boolean
*/
function plugin_init_groupcategory()
{
if (Session::getLoginUserID()) {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant'][PLUGIN_GROUPCATEGORY_NAMESPACE] = true;
//$PLUGIN_HOOKS['post_show_item'][PLUGIN_GROUPCATEGORY_NAMESPACE] = ['PluginGroupcategoryGroupcategory', 'post_show_item'];
$PLUGIN_HOOKS['post_item_form'][PLUGIN_GROUPCATEGORY_NAMESPACE] = ['PluginGroupcategoryGroupcategory', 'post_item_form'];
$PLUGIN_HOOKS['pre_item_update'][PLUGIN_GROUPCATEGORY_NAMESPACE] = [
'Group' => 'plugin_groupcategory_group_update',
];
}
}
/**
* Check plugin's prerequisites before installation
*/
function plugin_groupcategory_check_prerequisites()
{
if (version_compare(GLPI_VERSION, PLUGIN_GROUPCATEGORY_GLPI_MIN_VERSION, 'lt') || version_compare(GLPI_VERSION, PLUGIN_GROUPCATEGORY_GLPI_MAX_VERSION, 'ge')) {
echo __('This plugin requires GLPI >= ' . PLUGIN_GROUPCATEGORY_GLPI_MIN_VERSION . ' and GLPI < ' . PLUGIN_GROUPCATEGORY_GLPI_MAX_VERSION . '<br>');
} else {
return true;
}
return false;
}
/**
* Check if config is compatible with plugin
*
* @return boolean
*/
function plugin_groupcategory_check_config()
{
// nothing to do
return true;
}