Exemple #1
0
 /**
  * @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())
 {
     $column_name = __CLASS__;
     if (isset($options['dont_display'][$column_name])) {
         return;
     }
     if ($item->fields["interfacetypes_id"]) {
         $row->addCell($row->getHeaderByName($column_name), Dropdown::getDropdownName("glpi_interfacetypes", $item->fields["interfacetypes_id"]));
     }
 }
 /**
  * Add a new row of header cells to the current end of the table
  *
  * @access public
  * @param  array List of strings that should go into the TableCells
  */
 function addHeaderRow($coldata)
 {
     $row = new HTMLTableRow('', $coldata);
     $num = $row->getCellCount();
     for ($i = 0; $i < $num; $i++) {
         $cell =& $row->getCell($i);
         $cell->setIsHeader(true);
     }
     $this->_rows[] = $row;
 }
 /**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     if (isset($this->fields['networkports_id_list']) && is_string($this->fields['networkports_id_list'])) {
         $this->fields['networkports_id_list'] = importArrayFromDB($this->fields['networkports_id_list']);
     }
     $row->addCell($row->getHeaderByName('Instantiation', 'Origin'), $this->getInstantiationNetworkPortHTMLTable());
     parent::getInstantiationHTMLTable($netport, $row, $father, $options);
     return NULL;
 }
 /**
  * @since version 0.84
  *
  * @warning note the difference between getHTMLTableCellForItem and getHTMLTableCellsForItem
  *
  * @param $row                HTMLTableRow object
  * @param $item               CommonDBTM object (default NULL)
  * @param $father             HTMLTableCell object (default NULL)
  * @param $options   array
  **/
 function getHTMLTableCellForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     global $CFG_GLPI;
     $this_type = $this->getType();
     if (isset($options['dont_display'][$this_type])) {
         return $father;
     }
     if (static::canView()) {
         $content = $this->getLink();
     } else {
         $content = $this->getName();
     }
     if ($options['canedit']) {
         $field_name = 'quantity_' . $this->getType() . '_' . $this->getID();
         $content .= "&nbsp;<img title='" . __s('Add') . "' alt='" . __s('Add') . "'\n                      onClick=\"" . Html::jsShow($field_name) . "\"\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $content .= "<span id='{$field_name}' style='display:none'><br>";
         $content .= __('Add') . "&nbsp;";
         $content = array($content, array('function' => 'Dropdown::showInteger', 'parameters' => array($field_name, 0, 0, 10)), "</span>");
     }
     $linktype = static::getItem_DeviceType();
     if (in_array($item->getType(), $linktype::itemAffinity())) {
         $cell = $row->addCell($row->getHeaderByName('common', 'device'), $content, $father, $this);
     } else {
         $cell = $father;
     }
     return $cell;
 }
 /**
  * @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);
         }
     }
 }
 /**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     $row->addCell($row->getHeaderByName('Instantiation', 'Origin'), $this->getInstantiationNetworkPortHTMLTable());
     parent::getInstantiationHTMLTable($netport, $row, $father, $options);
     return NULL;
 }
 /**
  * Get HTMLTable row for a given item
  *
  * @param $netport         NetworkPort object (contains item)
  * @param $row             HTMLTableRow object
  * @param $father          HTMLTableHeader object (default NULL)
  * @param $options   array of possible options:
  *       - 'dont_display' : array of the elements that must not be display
  *       - 'withtemplate' : integer withtemplate param
  *
  * @return the father cell for the Internet Informations ...
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     global $DB;
     $display_options = $options['display_options'];
     if ($this->canHaveVirtualPort && $display_options['virtual_ports']) {
         $virtual_header = $row->getHeaderByName('Instantiation', 'VirtualPorts');
         $query = "(SELECT `networkports_id`\n                    FROM `glpi_networkportaliases`\n                    WHERE `networkports_id_alias`='" . $netport->getID() . "')\n                   UNION\n                   (SELECT `networkports_id`\n                    FROM `glpi_networkportaggregates`\n                    WHERE `networkports_id_list` LIKE '%\"" . $netport->getID() . "\"%')";
         $iterator = $DB->request($query);
         if ($iterator->numrows() > 0) {
             $new_father = $row->addCell($virtual_header, __('this port'), $father);
         } else {
             $new_father = $row->addCell($virtual_header, '', $father);
         }
         foreach ($iterator as $networkports_ids) {
             $virtualPort = new NetworkPort();
             if ($virtualPort->getFromDB($networkports_ids['networkports_id'])) {
                 $cell_value = '<i>' . $virtualPort->getLink() . '</i>';
                 $virtual_cell = $row->addCell($virtual_header, $cell_value, $father);
                 $virtual_cell->setAttributForTheRow(array('class' => 'htmltable_upper_separation_cell'));
                 if ($this->canHaveVLAN && $display_options['vlans']) {
                     NetworkPort_Vlan::getHTMLTableCellsForItem($row, $virtualPort, $virtual_cell, $options);
                 }
                 if ($display_options['internet']) {
                     NetworkName::getHTMLTableCellsForItem($row, $virtualPort, $virtual_cell, $options);
                 }
             }
             unset($virtualPort);
         }
         $father = $new_father;
     }
     if ($this->canHaveVLAN && $display_options['vlans']) {
         NetworkPort_Vlan::getHTMLTableCellsForItem($row, $netport, $father, $options);
     }
     if ($this->haveMAC && $display_options['mac'] && !empty($netport->fields["mac"])) {
         $row->addCell($row->getHeaderByName('Instantiation', 'MAC'), $netport->fields["mac"], $father);
     }
     if ($display_options['internet']) {
         NetworkName::getHTMLTableCellsForItem($row, $netport, $father, $options);
     }
     return NULL;
 }
 /**
  * @since version 0.84
  *
  * @see CommonDevice::getHTMLTableCellForItem()
  **/
 static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     $column_name = __CLASS__;
     if (isset($options['dont_display'][$column_name])) {
         return;
     }
     if (empty($item)) {
         if (empty($father)) {
             return;
         }
         $item = $father->getItem();
     }
     if (in_array($item->getType(), NetworkPort::getNetworkPortInstantiations())) {
         $link = new Item_DeviceNetworkCard();
         if ($link->getFromDB($item->fields['items_devicenetworkcards_id'])) {
             $device = $link->getOnePeer(1);
             if ($device) {
                 $row->addCell($row->getHeaderByName($column_name), $device->getLink(), $father);
             }
         }
     }
 }
Exemple #9
0
 /**
  * @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 (isset($options['dont_display'][$column_name])) {
         return;
     }
     if (empty($item)) {
         if (empty($father)) {
             return;
         }
         $item = $father->getItem();
     }
     $canedit = isset($options['canedit']) && $options['canedit'];
     if ($item->getType() == 'NetworkPort_Vlan') {
         if (isset($item->fields["tagged"]) && $item->fields["tagged"] == 1) {
             $tagged_msg = __('Tagged');
         } else {
             $tagged_msg = __('Untagged');
         }
         $vlan = new self();
         if ($vlan->getFromDB($options['items_id'])) {
             $content = sprintf(__('%1$s - %2$s'), $vlan->getName(), $tagged_msg);
             $content .= Html::showToolTip(sprintf(__('%1$s: %2$s'), __('ID TAG'), $vlan->fields['tag']) . "<br>" . sprintf(__('%1$s: %2$s'), __('Comments'), $vlan->fields['comment']), array('display' => false));
             $this_cell = $row->addCell($row->getHeaderByName($column_name), $content, $father);
         }
     }
 }
Exemple #10
0
 /**
  * @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() != 'IPAddress') {
         return;
     }
     $column_name = __CLASS__;
     if (isset($options['dont_display'][$column_name])) {
         return;
     }
     $header = $row->getGroup()->getHeaderByName('Internet', __CLASS__);
     if (!$header) {
         return;
     }
     $createRow = isset($options['createRow']) && $options['createRow'];
     $options['createRow'] = false;
     $network = new self();
     foreach (self::searchNetworksContainingIP($item) as $networks_id) {
         if ($network->getFromDB($networks_id)) {
             if ($createRow) {
                 $row = $row->createRow();
             }
             //TRANS: %1$s is address, %2$s is netmask
             $content = sprintf(__('%1$s / %2$s'), $network->getAddress()->getTextual(), $network->getNetmask()->getTextual());
             if ($network->fields['addressable'] == 1) {
                 $content = "<span class='b'>" . $content . "</span>";
             }
             $content = sprintf(__('%1$s - %2$s'), $content, $network->getLink());
             $this_cell = $row->addCell($header, $content, $father, $network);
         }
     }
 }