forked from pluginsGLPI/tag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.php
113 lines (93 loc) · 4.4 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Check plugin's config before activation
*/
function plugin_tag_check_config($verbose=false) {
return true;
}
function getBlacklistItemtype() {
return array('Tag');
}
function plugin_init_tag() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['tag'] = true;
// plugin datainjection
$PLUGIN_HOOKS['plugin_datainjection_populate']['tag'] = "plugin_datainjection_populate_tag";
Plugin::registerClass('PluginTagTagItem',
array('addtabon' => array('PluginTagTag')));
$plugin = new Plugin();
if ($plugin->isInstalled("tag") && $plugin->isActivated("tag")) {
// add link on plugin name in Configuration > Plugin
$PLUGIN_HOOKS['config_page']['tag'] = "front/tag.php";
// Plugin uninstall : after uninstall action
$UNINSTALL_TYPES = array('Computer', 'Monitor', 'NetworkEquipment',
'Peripheral', 'Phone', 'Printer');
foreach ($UNINSTALL_TYPES as $uninstall_itemtype) {
$PLUGIN_HOOKS['plugin_uninstall_after']['tag'][$uninstall_itemtype] = 'plugin_uninstall_after_tag';
}
$PLUGIN_HOOKS['add_javascript']['tag'][] = 'js/scripts.js';
}
// only on itemtype form
if (preg_match_all("/.*\/(.*)\.form\.php/", $_SERVER['REQUEST_URI'], $matches) !== false) {
if (strpos($_SERVER['REQUEST_URI'], "/front/dropdown.php") === false &&
strpos($_SERVER['REQUEST_URI'], ".form.php?") !== false &&
strpos($_SERVER['REQUEST_URI'], "id=-1") === false && //for Computer
strpos($_SERVER['REQUEST_URI'], "withtemplate=") === false && //exclude template
strpos($_SERVER['REQUEST_URI'], "?new=1") === false && //for exemple : for checklistconfig in plugin resources
strpos($_SERVER['REQUEST_URI'], "popup=1&rand=") === false && //item no exist
strpos($_SERVER['REQUEST_URI'], "/front/queuedmail") === false && //quemail items are temporary
strpos($_SERVER['REQUEST_URI'], "plugins/tag/front/tag.form.php") === false &&
strpos($_SERVER['REQUEST_URI'], "plugins/tag/front/tagtype") === false &&
strpos($_SERVER['REQUEST_URI'], "plugins/datainjection/front/model.form.php") === false &&
strpos($_SERVER['REQUEST_URI'], "plugins/webservices/front/client.form.php?new=1") === false &&
strpos($_SERVER['REQUEST_URI'], "plugins/printercounters/") === false &&
isset ($_SESSION["glpiroot"]) &&
strpos($_SERVER['REQUEST_URI'], $_SESSION["glpiroot"]."/front/reservation.form.php") === false &&
strpos($_SERVER['REQUEST_URI'], $_SESSION["glpiroot"]."/front/config.form.php") === false) { //for ?forcetab=PluginBehaviorsConfig%241
if (Session::haveRight("itilcategory", READ)) {
$PLUGIN_HOOKS['add_javascript']['tag'][] = 'js/show_tags.js';
}
}
if (isset($matches[1][0])) {
$itemtype = $matches[1][0];
if (preg_match_all("/plugins\/(.*)\//U", $_SERVER['REQUEST_URI'], $matches_plugin) !== false) {
if (isset($matches_plugin[1][0])) {
$itemtype = "Plugin" . ucfirst($matches_plugin[1][0]) . ucfirst($itemtype);
}
}
// stop on blaclisted itemtype
if (in_array($itemtype, array_map('strtolower', getBlacklistItemtype()))) {
return '';
}
if (class_exists($itemtype)) {
//normalize classname case
$obj = new $itemtype();
$itemtype = get_class($obj);
// Tag have no tag associated
if ($itemtype != 'PluginTagTag') {
$PLUGIN_HOOKS['pre_item_update']['tag'][$itemtype] = 'plugin_pre_item_update_tag';
$PLUGIN_HOOKS['pre_item_purge']['tag'][$itemtype] = 'plugin_pre_item_purge_tag';
}
}
}
}
}
function plugin_version_tag() {
return array('name' => __('Tag Management', 'tag'),
'version' => '0.90-1.2',
'author' => 'Emmanuel Haguet (Teclib\') - Ludovic Dupont (Infotel conseil)',
'homepage' => 'http://www.teclib.com',
'license' => '<a href="../plugins/tag/LICENSE" target="_blank">GPLv2+</a>',
'minGlpiVersion' => "0.90");
}
/**
* Check plugin's prerequisites before installation
*/
function plugin_tag_check_prerequisites() {
if (version_compare(GLPI_VERSION,'0.90','lt')) {
echo __('This plugin requires GLPI >= 0.90');
} else {
return true;
}
return false;
}