Skip to content

Commit c8beade

Browse files
committed
Add missing setup
1 parent c3c2878 commit c8beade

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

setup.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
define('PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION', '9.2.1');
4+
define('PLUGIN_GROUPCATEGORY_NAMESPACE', 'groupcategory');
5+
6+
/**
7+
* Plugin description
8+
*
9+
* @return boolean
10+
*/
11+
function plugin_version_groupcategory()
12+
{
13+
return [
14+
'name' => 'GroupCategory',
15+
'version' => '1.1',
16+
'author' => 'Pierre de Vésian - <a href="http://www.probesys.com">Probesys</a>',
17+
'homepage' => 'https://probesys.com/',
18+
'license' => 'GPLv2+',
19+
'minGlpiVersion' => PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION,
20+
];
21+
}
22+
23+
/**
24+
* Initialize plugin
25+
*
26+
* @return boolean
27+
*/
28+
function plugin_init_groupcategory()
29+
{
30+
if (Session::getLoginUserID()) {
31+
global $PLUGIN_HOOKS;
32+
33+
$PLUGIN_HOOKS['csrf_compliant'][PLUGIN_GROUPCATEGORY_NAMESPACE] = true;
34+
$PLUGIN_HOOKS['post_show_item'][PLUGIN_GROUPCATEGORY_NAMESPACE] = 'plugin_groupcategory_post_show_item';
35+
$PLUGIN_HOOKS['pre_item_update'][PLUGIN_GROUPCATEGORY_NAMESPACE] = [
36+
'Group' => 'plugin_groupcategory_group_update',
37+
];
38+
}
39+
}
40+
41+
/**
42+
* Check if plugin prerequisites are met
43+
*
44+
* @return boolean
45+
*/
46+
function plugin_groupcategory_check_prerequisites()
47+
{
48+
$prerequisites_check_ok = false;
49+
50+
try {
51+
if (version_compare(GLPI_VERSION, PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION, '<')) {
52+
throw new Exception('This plugin requires GLPI >= ' . PLUGIN_GROUPCATEGORY_MIN_GLPI_VERSION);
53+
}
54+
55+
$prerequisites_check_ok = true;
56+
} catch (Exception $e) {
57+
echo $e->getMessage();
58+
}
59+
60+
return $prerequisites_check_ok;
61+
}
62+
63+
/**
64+
* Check if config is compatible with plugin
65+
*
66+
* @return boolean
67+
*/
68+
function plugin_groupcategory_check_config()
69+
{
70+
// nothing to do
71+
return true;
72+
}

0 commit comments

Comments
 (0)