forked from pluginsGLPI/genericobject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.php
executable file
·159 lines (136 loc) · 6.67 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/*
This file is part of the genericobject plugin.
Order plugin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Order plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Genericobject. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
@package genericobject
@author the genericobject plugin team
@copyright Copyright (c) 2010-2011 Order plugin team
@license GPLv2+
http://www.gnu.org/licenses/gpl.txt
@link https://forge.indepnet.net/projects/genericobject
@link http://www.glpi-project.org/
@since 2009
---------------------------------------------------------------------- */
if (!defined("GENERICOBJECT_DIR")) {
define("GENERICOBJECT_DIR",GLPI_ROOT . "/plugins/genericobject");
}
if (!defined("GENERICOBJECT_FRONT_PATH")) {
define("GENERICOBJECT_FRONT_PATH", GENERICOBJECT_DIR."/front");
}
if (!defined("GENERICOBJECT_AJAX_PATH")) {
define("GENERICOBJECT_AJAX_PATH", GENERICOBJECT_DIR . "/ajax");
}
if (!defined("GENERICOBJECT_CLASS_PATH")) {
define("GENERICOBJECT_CLASS_PATH", GENERICOBJECT_DIR . "/inc");
}
if (!defined("GENERICOBJECT_LOCALES_PATH")) {
define("GENERICOBJECT_LOCALES_PATH", GENERICOBJECT_DIR . "/locales");
}
// Init the hooks of the plugins -Needed
function plugin_init_genericobject() {
global $PLUGIN_HOOKS, $LANG, $CFG_GLPI, $GO_BLACKLIST_FIELDS, $GO_FIELDS,
$GENERICOBJECT_PDF_TYPES;
$GO_BLACKLIST_FIELDS = array ("itemtype", "table", "is_deleted", "id", "entities_id",
"is_recursive", "is_template", "notepad", "template_name",
"is_helpdesk_visible", "comment", "name", "date_mod");
$GENERICOBJECT_PDF_TYPES = array ();
$plugin = new Plugin();
if ($plugin->isInstalled("genericobject") && $plugin->isActivated("genericobject")) {
//Load genericobject default constants
include_once (GLPI_ROOT . "/plugins/genericobject/fields/field.constant.php");
//Include user constants, that must be accessible for all itemtypes
if (file_exists(GLPI_ROOT . "/plugins/genericobject/fields/myconstant.php")) {
include_once (GLPI_ROOT . "/plugins/genericobject/fields/myconstant.php");
}
$PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1;
/* load changeprofile function */
$PLUGIN_HOOKS['change_profile']['genericobject'] = array('PluginGenericobjectProfile',
'changeProfile');
// Display a menu entry ?
$PLUGIN_HOOKS['menu_entry']['genericobject'] = true;
$PLUGIN_HOOKS['submenu_entry']['genericobject']['config'] = 'front/type.php';
//Do not display icon if not using the genericobject plugin
if (isset($_GET['id'])
&& strpos($_SERVER['REQUEST_URI'], getItemTypeFormURL("PluginGenericobjectType")) !== false) {
$url = '/plugins/genericobject/index.php';
$type = new PluginGenericobjectType();
$type->getFromDB($_GET['id']);
if ($type->fields['is_active']) {
$url.= '?itemtypes_id='.$_GET['id'];
$image = "<img src='".$CFG_GLPI["root_doc"]."/pics/stats_item.png' title=\"".
$LANG['genericobject']['common'][7].
"\" alt=\"".$LANG['genericobject']['common'][7]."\">";
$PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links'][$image]
= $url;
}
}
$PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['add']
= getItemTypeFormURL('PluginGenericobjectType', false);
$PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['search']
= getItemTypeSearchURL('PluginGenericobjectType', false);
// Config page
if (haveRight('config', 'w')) {
$PLUGIN_HOOKS['config_page']['genericobject'] = 'front/type.php';
$PLUGIN_HOOKS['submenu_entry']['genericobject']['add']['type'] = 'front/type.form.php';
$PLUGIN_HOOKS['submenu_entry']['genericobject']['search']['type'] = 'front/type.php';
}
$PLUGIN_HOOKS['assign_to_ticket']['genericobject'] = true;
$PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1;
// Onglets management
$PLUGIN_HOOKS['headings']['genericobject'] = 'plugin_get_headings_genericobject';
$PLUGIN_HOOKS['headings_action']['genericobject'] = 'plugin_headings_actions_genericobject';
$PLUGIN_HOOKS['post_init']['genericobject'] = 'plugin_post_init_genericobject';
$PLUGIN_HOOKS['plugin_datainjection_populate']['genericobject'] = "plugin_datainjection_populate_genericobject";
}
}
function plugin_post_init_genericobject() {
foreach (PluginGenericobjectType::getTypes() as $id => $objecttype) {
call_user_func(array($objecttype['itemtype'], 'registerType'));
}
}
// Get the name and the version of the plugin - Needed
function plugin_version_genericobject() {
global $LANG;
return array ('name' => $LANG["genericobject"]["title"][1],
'version' => '2.0.1',
'author' => 'Alexandre Delaunay & Walid Nouh',
'homepage' => 'https://forge.indepnet.net/projects/show/genericobject',
'minGlpiVersion' => '0.80');
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_genericobject_check_prerequisites() {
if (version_compare(GLPI_VERSION,'0.80','lt') || version_compare(GLPI_VERSION,'0.81','ge')) {
echo "This plugin requires GLPI 0.80";
}
return true;
}
// Check configuration process for plugin : need to return true if succeeded
// Can display a message only if failure and $verbose is true
function plugin_genericobject_check_config($verbose = false) {
global $LANG;
if (true) { // Your configuration check
return true;
}
if ($verbose) {
echo $LANG['plugins'][2];
}
return false;
}
function plugin_genericobject_haveTypeRight($itemtype, $right) {
switch ($itemtype) {
case 'PluginGenericobjectType' :
return haveRight("config", $right);
default :
return haveRight($itemtype, $right);
}
}