/** * @since version 0.84 * * @param $row HTMLTableRow object (default NULL) * @param $item CommonDBTM object (default NULL) * @param $father HTMLTableCell object (default NULL) * @param $options array **/ static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array()) { global $DB, $CFG_GLPI; if (empty($item)) { if (empty($father)) { return; } $item = $father->getItem(); } if ($item->getType() != 'NetworkName') { return; } $column_name = __CLASS__; if (isset($options['dont_display'][$column_name])) { return; } $header = $row->getGroup()->getHeaderByName('Internet', $column_name); if (!$header) { return; } $canedit = isset($options['canedit']) && $options['canedit']; $createRow = isset($options['createRow']) && $options['createRow']; $options['createRow'] = false; $query = "SELECT `id`\n FROM `glpi_networkaliases`\n WHERE `networknames_id` = '" . $item->getID() . "'"; $alias = new self(); foreach ($DB->request($query) as $line) { if ($alias->getFromDB($line["id"])) { if ($createRow) { $row = $row->createRow(); } $content = "<a href='" . $alias->getLinkURL() . "'>" . $alias->getInternetName() . "</a>"; $row->addCell($header, $content, $father, $alias); } } }
/** * @since version 0.84 * * @param $row HTMLTableRow object (default NULL) * @param $item CommonDBTM object (default NULL) * @param $father HTMLTableCell object (default NULL) * @param $options array **/ static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array()) { global $DB, $CFG_GLPI; $column_name = __CLASS__; if (empty($item)) { if (empty($father)) { return; } $item = $father->getItem(); } switch ($item->getType()) { case 'FQDN': $JOINS = ""; $ORDER = "`glpi_networknames`.`name`"; if (isset($options['order'])) { switch ($options['order']) { case 'name': break; case 'ip': $JOINS = " LEFT JOIN `glpi_ipaddresses`\n ON (`glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`\n AND `glpi_ipaddresses`.`itemtype` = 'NetworkName'\n AND `glpi_ipaddresses`.`is_deleted` = '0')"; $ORDER = "ISNULL (`glpi_ipaddresses`.`id`),\n `glpi_ipaddresses`.`binary_3`, `glpi_ipaddresses`.`binary_2`,\n `glpi_ipaddresses`.`binary_1`, `glpi_ipaddresses`.`binary_0`"; break; case 'alias': $JOINS = " LEFT JOIN `glpi_networkaliases`\n ON (`glpi_networkaliases`.`networknames_id`\n = `glpi_networknames`.`id`)"; $ORDER = "ISNULL(`glpi_networkaliases`.`name`),\n `glpi_networkaliases`.`name`"; break; } } $query = "SELECT `glpi_networknames`.`id`\n FROM `glpi_networknames`\n {$JOINS}\n WHERE `glpi_networknames`.`fqdns_id` = '" . $item->fields["id"] . "'\n AND `glpi_networknames`.`is_deleted` = '0'\n ORDER BY {$ORDER}"; break; case 'NetworkPort': $query = "SELECT `id`\n FROM `glpi_networknames`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `glpi_networknames`.`is_deleted` = '0'"; break; case 'NetworkEquipment': $query = "SELECT `glpi_networknames`.`id`\n FROM `glpi_networknames`, `glpi_networkports`\n WHERE `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n AND `glpi_networkports`.`items_id` ='" . $item->getID() . "'\n AND `glpi_networknames`.`itemtype` = 'NetworkPort'\n AND `glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n AND `glpi_networknames`.`is_deleted` = '0'"; break; } if (isset($options['SQL_options'])) { $query .= " " . $options['SQL_options']; } $canedit = isset($options['canedit']) && $options['canedit']; $createRow = isset($options['createRow']) && $options['createRow']; $options['createRow'] = false; $address = new self(); foreach ($DB->request($query) as $line) { if ($address->getFromDB($line["id"])) { if ($createRow) { $row = $row->createAnotherRow(); } if (isset($options['massiveactionnetworkname']) && $options['massiveactionnetworkname']) { $header = $row->getGroup()->getHeaderByName('Internet', 'delete'); $cell_value = Html::getMassiveActionCheckBox(__CLASS__, $line["id"]); $delete_cell = $row->addCell($header, $cell_value, $father); } $internetName = $address->getInternetName(); if (empty($internetName)) { $internetName = "(" . $line["id"] . ")"; } $content = $internetName; if (Session::haveRight('internet', READ)) { $content = "<a href='" . $address->getLinkURL() . "'>" . $internetName . "</a>"; } if (!isset($options['dont_display'][$column_name])) { $header = $row->getGroup()->getHeaderByName('Internet', $column_name); $name_cell = $row->addCell($header, $content, $father, $address); if (isset($options['display_isDynamic']) && $options['display_isDynamic']) { $dyn_header = $row->getGroup()->getHeaderByName('Internet', $column_name . '_dynamic'); $dynamic_cell = $row->addCell($dyn_header, Dropdown::getYesNo($address->fields['is_dynamic']), $name_cell); $father_for_children = $dynamic_cell; } else { $father_for_children = $name_cell; } } else { $father_for_children = $father; } NetworkAlias::getHTMLTableCellsForItem($row, $address, $father_for_children, $options); IPAddress::getHTMLTableCellsForItem($row, $address, $father_for_children, $options); } } }