. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * @since 0.84 **/ class IPNetwork_Vlan extends CommonDBRelation { // From CommonDBRelation static public $itemtype_1 = 'IPNetwork'; static public $items_id_1 = 'ipnetworks_id'; static public $itemtype_2 = 'Vlan'; static public $items_id_2 = 'vlans_id'; static public $checkItem_2_Rights = self::HAVE_VIEW_RIGHT_ON_ITEM; function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } /** * @param $portID * @param $vlanID **/ function unassignVlan($portID, $vlanID) { $this->getFromDBByCrit([ 'ipnetworks_id' => $portID, 'vlans_id' => $vlanID ]); return $this->delete($this->fields); } /** * @param $port * @param $vlan **/ function assignVlan($port, $vlan) { $input = ['ipnetworks_id' => $port, 'vlans_id' => $vlan]; return $this->add($input); } /** * @param $port IPNetwork object **/ static function showForIPNetwork(IPNetwork $port) { global $DB, $CFG_GLPI; $ID = $port->getID(); if (!$port->can($ID, READ)) { return false; } $canedit = $port->canEdit($ID); $rand = mt_rand(); $iterator = $DB->request([ 'SELECT' => [ self::getTable() . '.id AS assocID', 'glpi_vlans.*' ], 'FROM' => self::getTable(), 'LEFT JOIN' => [ 'glpi_vlans' => [ 'ON' => [ self::getTable() => 'vlans_id', 'glpi_vlans' => 'id' ] ] ], 'WHERE' => ['ipnetworks_id' => $ID] ]); $vlans = []; $used = []; $number = count($iterator); while ($line = $iterator->next()) { $used[$line["id"]] = $line["id"]; $vlans[$line["assocID"]] = $line; } if ($canedit) { echo "
| ".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_top .= " | "; $header_bottom .= "".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= " | "; } $header_end .= "".__('Name')." | "; $header_end .= "".Entity::getTypeName(1)." | "; $header_end .= "".__('ID TAG')." | "; $header_end .= "
|---|---|---|---|---|
| "; Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); echo " | "; } $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } echo "".$name. ""; echo " | "; echo "".Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo " | ".$data["tag"]." | "; echo "