本文整理汇总了PHP中NetworkPort::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP NetworkPort::getName方法的具体用法?PHP NetworkPort::getName怎么用?PHP NetworkPort::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkPort
的用法示例。
在下文中一共展示了NetworkPort::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForItem
/**
* Display form to unlock fields and links
*
* @param CommonDBTM $item the source item
**/
static function showForItem(CommonDBTM $item)
{
global $DB;
$ID = $item->getID();
$itemtype = $item->getType();
$header = false;
//If user doesn't have write right on the item, lock form must not be displayed
if (!$item->canCreate()) {
return false;
}
echo "<div width='50%'>";
echo "<form method='post' id='lock_form'\n name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='id' value='{$ID}'>\n";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
//Use a hook to allow external inventory tools to manage per field lock
$results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
$header |= $results['header'];
//Special locks for computers only
if ($itemtype == 'Computer') {
//Locks for items recorded in glpi_computers_items table
$types = array('Monitor', 'Peripheral', 'Printer');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
$params['FIELDS'] = array('id', 'items_id');
$first = true;
foreach ($DB->request('glpi_computers_items', $params) as $line) {
$tmp = new $type();
$tmp->getFromDB($line['items_id']);
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
echo "</tr>\n";
}
}
$types = array('ComputerDisk', 'ComputerVirtualMachine');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$params['FIELDS'] = array('id', 'name');
$first = true;
foreach ($DB->request(getTableForItemType($type), $params) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
echo "</tr>\n";
}
}
//Software versions
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwareversions` AS csv\n LEFT JOIN `glpi_softwareversions` AS sv\n ON (`csv`.`softwareversions_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . Software::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
//Software licenses
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwarelicenses` AS csv\n LEFT JOIN `glpi_softwarelicenses` AS sv\n ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
}
$first = true;
$item = new NetworkPort();
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
$params['FIELDS'] = array('id');
foreach ($DB->request('glpi_networkports', $params) as $line) {
$item->getFromDB($line['id']);
//.........这里部分代码省略.........
示例2: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB;
$ID = $item->getField('id');
$type = get_class($item);
$query = "SELECT `glpi_networkports`.`id`\n FROM `glpi_networkports`\n WHERE `items_id` = '" . $ID . "'\n AND `itemtype` = '" . $type . "'\n ORDER BY `name`, `logical_number`";
$pdf->setColumnsSize(100);
if ($result = $DB->query($query)) {
$nb_connect = $DB->numrows($result);
if (!$nb_connect) {
$pdf->displayTitle('<b>0 ' . __('No network port found') . '</b>');
} else {
$pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$d'), _n('Network port', 'Network ports', $nb_connect), $nb_connect . "</b>"));
while ($devid = $DB->fetch_row($result)) {
$netport = new NetworkPort();
$netport->getfromDB(current($devid));
$instantiation_type = $netport->fields["instantiation_type"];
$instname = call_user_func(array($instantiation_type, 'getTypeName'));
$pdf->displayTitle('<b>' . $instname . '</b>');
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), '#</b>', $netport->fields["logical_number"]));
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Name') . '</b>', $netport->fields["name"]));
$contact = new NetworkPort();
$netport2 = new NetworkPort();
$add = __('Not connected.');
if ($cid = $contact->getContact($netport->fields["id"])) {
if ($netport2->getFromDB($cid) && ($device2 = getItemForItemtype($netport2->fields["itemtype"]))) {
if ($device2->getFromDB($netport2->fields["items_id"])) {
$add = $netport2->getName() . ' ' . __('on') . ' ' . $device2->getName() . ' (' . $device2->getTypeName() . ')';
}
}
}
if ($instantiation_type == 'NetworkPortEthernet') {
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Connected to') . '</b>', $add));
$netportethernet = new NetworkPortEthernet();
$speed = $type = '';
if ($netportethernet->getFromDB($netport->fields['id'])) {
$speed = NetworkPortEthernet::getPortSpeed($netportethernet->fields['speed']);
$type = NetworkPortEthernet::getPortTypeName($netportethernet->fields['type']);
}
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Ethernet port speed') . '</b>', $speed));
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Ethernet port type') . '</b>', $type));
$netpoint = new Netpoint();
$outlet = '';
if ($netpoint->getFromDB($netportethernet->fields['netpoints_id'])) {
$outlet = $netpoint->fields['name'];
}
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Network outlet') . '</b>', $outlet));
}
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('MAC') . '</b>', $netport->fields["mac"]));
$sqlip = "LEFT JOIN `glpi_networknames`\n ON (`glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`\n AND `glpi_ipaddresses`.`entities_id`\n = '" . $_SESSION['glpiactive_entity'] . "')\n WHERE `glpi_networknames`.`items_id` = '" . $netport->fields["id"] . "'";
$ipname = '';
$ip = new IPAddress();
if ($ip->getFromDBByQuery($sqlip)) {
$ipname = $ip->fields['name'];
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('ip') . '</b>', $ipname));
$sql = "SELECT `glpi_ipaddresses_ipnetworks`.`ipnetworks_id`\n FROM `glpi_ipaddresses_ipnetworks`\n LEFT JOIN `glpi_ipnetworks`\n ON (`glpi_ipaddresses_ipnetworks`.`ipnetworks_id` = `glpi_ipnetworks`.`id`)\n WHERE `glpi_ipaddresses_ipnetworks`.`ipaddresses_id` = '" . $ip->getID() . "'";
$res = $DB->query($sql);
if ($res) {
while ($row = $DB->fetch_assoc($res)) {
$ipnetwork = new IPNetwork();
if ($ipnetwork->getFromDB($row['ipnetworks_id'])) {
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('IP network') . '</b>', $ipnetwork->fields['address']));
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Subnet mask') . '</b>', $ipnetwork->fields['netmask']));
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Gateway') . '</b>', $ipnetwork->fields['gateway']));
}
}
}
}
}
// each port
}
// Found
}
// Query
$pdf->displaySpace();
}