forked from Probesys/glpi-plugins-groupcategory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
69 lines (60 loc) · 1.84 KB
/
setup.php
File metadata and controls
69 lines (60 loc) · 1.84 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
<?php
define('PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION', '9.4');
define('PLUGIN_GROUPCATEGORY_NAMESPACE', 'groupcategory');
/**
* Plugin description
*
* @return boolean
*/
function plugin_version_groupcategory() {
return [
'name' => 'GroupCategory',
'version' => '1.2.4',
'author' => 'Pierre de Vésian, Philippe GODOT - <a href="http://www.probesys.com">PROBESYS</a>',
'homepage' => 'https://probesys.com/',
'license' => 'GPLv2+',
'minGlpiVersion' => PLUGIN_GROUPCATEGORY_MIN_GLPI_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 if plugin prerequisites are met
*
* @return boolean
*/
function plugin_groupcategory_check_prerequisites() {
$prerequisites_check_ok = false;
try {
if (version_compare(GLPI_VERSION, PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION, '<')) {
throw new Exception('This plugin requires GLPI >= ' . PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION);
}
$prerequisites_check_ok = true;
} catch (Exception $e) {
echo $e->getMessage();
}
return $prerequisites_check_ok;
}
/**
* Check if config is compatible with plugin
*
* @return boolean
*/
function plugin_groupcategory_check_config() {
// nothing to do
return true;
}