Skip to content

Commit 4f8d375

Browse files
committed
Add GLPI asset definitions Fix #88
Change icons
1 parent 56b462d commit 4f8d375

6 files changed

Lines changed: 49 additions & 46 deletions

File tree

hook.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,17 @@ function plugin_addressing_giveItem($type, $ID, $data, $num)
311311
switch ($table . '.' . $field) {
312312
case "glpi_plugin_addressing_pinginfos.ping_response":
313313
if ($data[$num][0]['name'] == "1") {
314-
$out .= "<i class=\"fas fa-check-square fa-2x\" style='color: darkgreen'></i><br>" . __(
314+
$out .= "<i class=\"ti ti-square-check\" style='color: darkgreen;font-size: 2em;'></i><br>" . __(
315315
'Last ping OK',
316316
'addressing'
317317
);
318318
} elseif ($data[$num][0]['name'] == "0") {
319-
$out .= "<i class=\"fas fa-window-close fa-2x\" style='color: darkred'></i><br>" . __(
319+
$out .= "<i class=\"ti ti-square-x\" style='color: darkred;font-size: 2em;'></i><br>" . __(
320320
'Last ping KO',
321321
'addressing'
322322
);
323323
} else {
324-
$out .= "<i class=\"fas fa-question fa-2x\" style='color: orange'></i><br>" . __(
324+
$out .= "<i class=\"ti ti-question\" style='color: orange;font-size: 2em;'></i><br>" . __(
325325
"Ping informations not available",
326326
'addressing'
327327
);

src/Addressing.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -886,17 +886,17 @@ public function compute($start, $params = [])
886886
$where['dev.networks_id'] = $this->fields["networks_id"];
887887
}
888888

889+
$addtype = addslashes($type);
889890
$select = [
890891
'port.id',
891-
new QueryExpression("'" . $type . "' AS itemtype"),
892+
new QueryExpression("'" . $addtype . "' AS itemtype"),
892893
'port.items_id',
893894
'dev.name AS dname',
894895
'port.name AS pname',
895-
'glpi_ipaddresses.name AS ip',
896+
'glpi_ipaddresses.name AS ipaddr',
896897
'port.mac'
897898
];
898-
if ($type == 'PluginFusioninventoryUnknownDevice'
899-
|| $type == 'Enclosure' || $type == 'PDU' || $type == 'Cluster' || $type == 'Unmanaged') {
899+
if ($type == 'Enclosure' || $type == 'PDU' || $type == 'Cluster' || $type == 'Unmanaged') {
900900
$select[] = new QueryExpression("0 AS users_id");
901901
} else {
902902
$select[] = 'dev.users_id';
@@ -928,7 +928,7 @@ public function compute($start, $params = [])
928928
]
929929
],
930930
'WHERE' => $where,
931-
'GROUPBY' => ['ip', 'port.mac'],
931+
'GROUPBY' => ['ipaddr', 'port.mac'],
932932
'ORDER' => 'ipnum'
933933
]);
934934
}
@@ -1148,7 +1148,7 @@ public function showReport($params)
11481148
'Manual launch of ping',
11491149
'addressing'
11501150
) . "'>";
1151-
echo "<i class='fas fa-spinner' data-hasqtip='0' aria-hidden='true'></i>&nbsp;";
1151+
echo "<i class='ti ti-refresh' data-hasqtip='0' aria-hidden='true'></i>&nbsp;";
11521152
echo _sx('button', 'Manual launch of ping', 'addressing');
11531153
echo "</button>";
11541154
echo "</td>";
@@ -1335,12 +1335,14 @@ public static function processMassiveActionsForOneItemtype(
13351335
**/
13361336
public static function getTypes($all = false)
13371337
{
1338+
global $CFG_GLPI;
1339+
13381340
if ($all) {
1339-
return self::$types;
1341+
return $CFG_GLPI['networkport_types'];
13401342
}
13411343

13421344
// Only allowed types
1343-
$types = self::$types;
1345+
$types = $CFG_GLPI['networkport_types'];
13441346

13451347
foreach ($types as $key => $type) {
13461348
if (!class_exists($type)) {
@@ -1352,6 +1354,7 @@ public static function getTypes($all = false)
13521354
unset($types[$key]);
13531355
}
13541356
}
1357+
13551358
return $types;
13561359
}
13571360

@@ -1368,11 +1371,11 @@ public static function dropdownItemtype()
13681371
//Add definition : display dropdown
13691372
$types = self::getTypes();
13701373

1371-
// $options[0] = Dropdown::EMPTY_VALUE;
1374+
$options = [];
13721375

13731376
foreach ($types as $itemtype) {
13741377
$item = new $itemtype();
1375-
$options[$itemtype] = $item->getTypeName($itemtype);
1378+
$options[$itemtype] = $item->getTypeName(1);
13761379
}
13771380

13781381
// asort($options);

src/PingInfo.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ public static function getPingResponseForItem($params)
185185
}
186186

187187
if ($ping_action == 0) {
188-
$content = "<i class=\"fas fa-question fa-2x\" style='color: orange' title=\"" . __(
188+
$content = "<i class=\"ti ti-question\" style='color: orange;font-size: 2em;' title=\"" . __(
189189
"Automatic action has not be launched",
190190
'addressing'
191191
) . "\">
192192
</i><br>" . __("Ping informations not available", 'addressing');
193193
} else {
194194
if ($ping_value == 1) {
195-
$content = "<i class=\"fas fa-check-square fa-2x\" style='color: darkgreen' title='" . __(
195+
$content = "<i class=\"ti ti-square-check\" style='color: darkgreen;font-size: 2em;' title='" . __(
196196
"Last ping attempt",
197197
'addressing'
198198
) . " : "
@@ -205,7 +205,7 @@ public static function getPingResponseForItem($params)
205205
substr($ipname, 2)
206206
);
207207
} else {
208-
$content = "<i class=\"fas fa-window-close fa-2x\" style='color: darkred' title='" . __(
208+
$content = "<i class=\"ti ti-square-x\" style='color: darkred;font-size: 2em;' title='" . __(
209209
"Last ping attempt",
210210
'addressing'
211211
) . " : "
@@ -233,7 +233,7 @@ public static function getPingResponseForItem($params)
233233
$rand = mt_rand();
234234
echo "<button form='' class='submit btn btn-warning'
235235
onclick='javascript:viewPingform" . $items_id . "$rand();'>";
236-
echo "<i class='fas fa-terminal fa-2x' style='color: orange' title='" . _sx(
236+
echo "<i class='ti ti-terminal-2' style='color: orange;font-size:2em;' title='" . _sx(
237237
'button',
238238
'Manual launch of ping',
239239
'addressing'

src/Ping_Equipment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function showPingForm($itemtype, $items_id)
106106
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 left'>";
107107
echo "<tr><th colspan='3'>" . __('IP ping', 'addressing') . "</th>";
108108
echo "<th>";
109-
echo "<i class='fas fa-times-circle fa-1x' onclick='$(\"#ping_item\").hide();'></i>";
109+
echo "<i class='ti ti-circle-x' onclick='$(\"#ping_item\").hide();'></i>";
110110
echo "</tr>";
111111

112112
if (count($list_ip) > 0) {
@@ -301,9 +301,9 @@ public function showIPForm($ip)
301301

302302
echo "<div class='me-2'>";
303303
if ($error) {
304-
echo "<i style='color:forestgreen' class='fas fa-check-circle fa-2x'></i>";
304+
echo "<i style='color:forestgreen;font-size: 2em;' class='ti ti-circle-check'></i>";
305305
} else {
306-
echo "<i style='color:orange' class='fas fa-exclamation-triangle fa-2x'></i>";
306+
echo "<i style='color:orange;font-size: 2em;' class='ti ti-alert-triangle'></i>";
307307
}
308308
echo "</div>";
309309

0 commit comments

Comments
 (0)