Skip to content
Open
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fix PDF Generation involving a Network port with multiple IPs
- Fix PDF export of tabs renamed in GLPI 11

## [4.1.4] - 2026-07-30
Expand Down
52 changes: 31 additions & 21 deletions inc/networkport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,37 @@
$netport->fields['mac'],
));

$sqlip = ['LEFT JOIN' => ['glpi_networknames'
=> ['FKEY' => ['glpi_ipaddresses' => 'items_id',
'glpi_networknames' => 'id'],
['glpi_ipaddresses.entities_id'
=> $_SESSION['glpiactive_entity']]]],
'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']]];

$ipname = '';
$ip = new IPAddress();
if ($ip->getFromDBByRequest($sqlip)) {
$ipname = $ip->fields['name'];

$pdf->displayLine('<b>' . sprintf(__s('%1$s: %2$s'), __s('ip') . '</b>', $ipname));

$sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id',
'FROM' => 'glpi_ipaddresses_ipnetworks',
'LEFT JOIN' => ['glpi_ipnetworks'
=> ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id',
'glpi_ipnetworks' => 'id']]],
'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip->getID()]
+ $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')];
$ips = $DB->request(
[
'SELECT' => [IPAddress::getTable() . '.*'],
'FROM' => IPAddress::getTable(),
'LEFT JOIN' => [
'glpi_networknames' => [
'FKEY' => [
'glpi_ipaddresses' => 'items_id',
'glpi_networknames' => 'id',
],
[
'glpi_ipaddresses.entities_id' => $_SESSION['glpiactive_entity'],
],
],
],
'WHERE' => [
'glpi_networknames.items_id' => $netport->fields['id'],
'glpi_networknames.itemtype' => NetworkPort::class,
],
],
);

$pdf->displayLine('<b>' . sprintf(__s('%1$s: %2$s'), __s('ip') . '</b>', $ip['name']));

$sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id',
'FROM' => 'glpi_ipaddresses_ipnetworks',
'LEFT JOIN' => ['glpi_ipnetworks'
=> ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id',
'glpi_ipnetworks' => 'id']]],
Comment thread
jdurand-teclib marked this conversation as resolved.
Outdated
'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip['id']]
+ $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')];

$res = $DB->request($sql);
foreach ($res as $row) {
Expand All @@ -174,6 +184,6 @@
}
} // each port
} // Found
$pdf->displaySpace();

Check failure on line 187 in inc/networkport.class.php

View workflow job for this annotation

GitHub Actions / GLPI 11.0.x - php:8.2 - mariadb:10.6 / Continuous integration

Syntax error, unexpected T_VARIABLE on line 187

Check failure on line 187 in inc/networkport.class.php

View workflow job for this annotation

GitHub Actions / GLPI 11.0.x - php:8.5 - mariadb:11.8 / Continuous integration

Syntax error, unexpected T_VARIABLE on line 187
}
}
Loading