-
Notifications
You must be signed in to change notification settings - Fork 60
/
index.php
93 lines (85 loc) · 3.41 KB
/
index.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
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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 3 of the License, or
* (at your option) any later version.
*
* GenericObject 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/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2023 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
define('GLPI_ROOT', '../..');
include(GLPI_ROOT . "/inc/includes.php");
if (isset($_GET['itemtypes_id']) && $_GET['itemtypes_id'] != '') {
$type = new PluginGenericobjectType();
$type->getFromDB($_GET['itemtypes_id']);
Html::redirect(Toolbox::getItemTypeSearchURL($type->fields['itemtype']));
} else {
$types = PluginGenericobjectType::getTypesByFamily();
foreach ($types as $family => $typeData) {
foreach ($typeData as $ID => $value) {
if (!Session::haveRight($value['itemtype'], READ)) {
unset($types[$family][$ID]);
}
}
}
//There's only one family
if (count($types) == 1) {
//There's only one itemtype ? If yes, then automatically
//redirect to the search engine
if (key($types) == null) {
$mytypes = $types;
$tmp = array_pop($mytypes);
if (count($tmp) == 1) {
Html::redirect(Toolbox::getItemTypeSearchURL(key($tmp)));
}
}
}
Html::header(
__("Objects management", "genericobject"),
$_SERVER['PHP_SELF'],
"plugins",
"genericobject"
);
foreach ($types as $family => $typeData) {
$PluginGenericobjectTypefamily = new PluginGenericobjectTypefamily();
$PluginGenericobjectTypefamily->getFromDB($family);
echo "<table class='tab_cadre_fixe'>";
if ($family == 0) {
echo "<tr class='tab_bg_2'><th>" . __("Empty family", "genericobject") . "</th></tr>";
} else {
echo "<tr class='tab_bg_2'><th>" . $PluginGenericobjectTypefamily->getField("name") . "</th></tr>";
}
if (!count($types)) {
echo "<tr class='tab_bg_1'><td align='center'>" . __("No item to display") . "</td></tr>";
} else {
foreach ($typeData as $ID => $value) {
echo "<tr class='tab_bg_1'><td align='center'>";
echo "<a href='" . Toolbox::getItemTypeSearchURL($value['itemtype']) . "'>";
$itemtype = $value['itemtype'];
echo $itemtype::getTypeName();
echo "</a></td></tr>";
}
}
echo "</table>";
}
Html::footer();
}