static function assign($id, $source_type, $source_field, $source_value) { global $DB; $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); if ($source_field == "model") { // Get auth $snmp_auth = new PluginFusioninventorySnmpauth(); switch ($source_type) { case NETWORKING_TYPE: $FK_snmp_auth_DB = $snmp_auth->GetSNMPAuth($id, NETWORKING_TYPE); $plugin_fusioninventory_snmp->update_network_infos($id, $source_value, $FK_snmp_auth_DB); break; case PRINTER_TYPE: $FK_snmp_auth_DB = $snmp_auth->GetSNMPAuth($id, PRINTER_TYPE); $plugin_fusioninventory_snmp->update_printer_infos($id, $source_value, $FK_snmp_auth_DB); break; } } else { if ($source_field == "auth") { switch ($source_type) { case NETWORKING_TYPE: // Get model $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($id, NETWORKING_TYPE); $plugin_fusioninventory_snmp->update_network_infos($id, $FK_model_DB, $source_value); break; case PRINTER_TYPE: // Get model $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($id, PRINTER_TYPE); $plugin_fusioninventory_snmp->update_printer_infos($id, $FK_model_DB, $source_value); break; } } } }
function plugin_fusioninventory_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB, $INFOFORM_PAGES, $LINK_ID_TABLE, $LANG, $SEARCH_OPTION, $FUSIONINVENTORY_MAPPING; $table = $SEARCH_OPTION[$type][$ID]["table"]; $field = $SEARCH_OPTION[$type][$ID]["field"]; // echo "GiveItem : ".$field."<br/>"; switch ($type) { // * Computer List (front/computer.php) case COMPUTER_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, NETWORKING_TYPE); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[NETWORKING_TYPE] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; $out .= $vartmp; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; } break; // * Networking List (front/networking.php) // * Networking List (front/networking.php) case NETWORKING_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - last inventory case "glpi_plugin_fusioninventory_networking.FK_networking": $query = "SELECT *\n FROM `glpi_plugin_fusioninventory_networking`\n WHERE `FK_networking` = '" . $data["ID"] . "';"; if ($result = $DB->query($query)) { $data2 = $DB->fetch_array($result); } $last_date = ""; if (isset($data2["last_fusioninventory_update"])) { $last_date = $data2["last_fusioninventory_update"]; } $out = "<div align='center'>" . convDateTime($last_date) . "</div>"; return $out; break; // ** FusionInventory - SNMP models // ** FusionInventory - SNMP models case "glpi_plugin_fusioninventory_model_infos.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/models.form.php?ID=" . $FK_model_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_model_infos", $FK_model_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; // ** FusionInventory - SNMP authentification // ** FusionInventory - SNMP authentification case "glpi_plugin_fusioninventory_snmpauths.name": $plugin_fusioninventory_snmp = new PluginFusioninventorySnmpauth(); $FK_auth_DB = $plugin_fusioninventory_snmp->GetSNMPAuth($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/snmp_auth.form.php?ID=" . $FK_auth_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_snmpauths", $FK_auth_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; } break; // * Printer List (front/printer.php) // * Printer List (front/printer.php) case PRINTER_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, NETWORKING_TYPE); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[NETWORKING_TYPE] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; // ** FusionInventory - last inventory // ** FusionInventory - last inventory case "glpi_plugin_fusioninventory_printers.FK_printers": $query = "SELECT *\n FROM `glpi_plugin_fusioninventory_printers`\n WHERE `FK_printers` = '" . $data["ID"] . "';"; if ($result = $DB->query($query)) { $data2 = $DB->fetch_array($result); } $last_date = ""; if (isset($data2["last_fusioninventory_update"])) { $last_date = $data2["last_fusioninventory_update"]; } $out = "<div align='center'>" . convDateTime($last_date) . "</div>"; return $out; break; // ** FusionInventory - SNMP models // ** FusionInventory - SNMP models case "glpi_plugin_fusioninventory_model_infos.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/models.form.php?ID=" . $FK_model_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_model_infos", $FK_model_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; // ** FusionInventory - SNMP authentification // ** FusionInventory - SNMP authentification case "glpi_plugin_fusioninventory_snmpauths.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySnmpauth(); $FK_auth_DB = $plugin_fusioninventory_snmp->GetSNMPAuth($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/snmp_auth.form.php?ID=" . $FK_auth_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_snmpauths", $FK_auth_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; } break; // * Model List (plugins/fusioninventory/front/models.php) // * Model List (plugins/fusioninventory/front/models.php) case PLUGIN_FUSIONINVENTORY_MODEL: switch ($table . '.' . $field) { // ** Name of type of model (network, printer...) case "glpi_plugin_fusioninventory_model_infos.device_type": $out = '<center> '; switch ($data["ITEM_{$num}"]) { case COMPUTER_TYPE: $out .= $LANG["Menu"][0]; break; case NETWORKING_TYPE: $out .= $LANG["Menu"][1]; break; case PRINTER_TYPE: $out .= $LANG["Menu"][2]; break; case PERIPHERAL_TYPE: $out .= $LANG["Menu"][16]; break; case PHONE_TYPE: $out .= $LANG["Menu"][34]; break; } $out .= '</center>'; return $out; break; // ** Display pic / link for exporting model // ** Display pic / link for exporting model case "glpi_plugin_fusioninventory_model_infos.ID": $out = "<div align='center'><form></form><form method='get' action='" . GLPI_ROOT . "/plugins/fusioninventory/front/models.export.php' target='_blank'>\n\t\t\t\t\t\t<input type='hidden' name='model' value='" . $data["ID"] . "' />\n\t\t\t\t\t\t<input name='export' src='" . GLPI_ROOT . "/pics/right.png' title='Exporter' value='Exporter' type='image'>\n\t\t\t\t\t\t</form></div>"; return "<center>" . $out . "</center>"; break; } break; // * Authentification List (plugins/fusioninventory/front/snmp_auth.php) // * Authentification List (plugins/fusioninventory/front/snmp_auth.php) case PLUGIN_FUSIONINVENTORY_SNMP_AUTH: switch ($table . '.' . $field) { // ** Hidden auth passphrase (SNMP v3) case "glpi_plugin_fusioninventory_snmpauths.auth_passphrase": $out = ""; if (empty($data["ITEM_{$num}"])) { } else { $out = "********"; } return $out; break; // ** Hidden priv passphrase (SNMP v3) // ** Hidden priv passphrase (SNMP v3) case "glpi_plugin_fusioninventory_snmpauths.priv_passphrase": $out = ""; if (empty($data["ITEM_{$num}"])) { } else { $out = "********"; } return $out; break; } break; // * Unknown mac addresses connectd on switch - report (plugins/fusioninventory/report/unknown_mac.php) // * Unknown mac addresses connectd on switch - report (plugins/fusioninventory/report/unknown_mac.php) case PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; case "glpi_plugin_fusioninventory_unknown_device.type": $out = '<center> '; switch ($data["ITEM_{$num}"]) { case COMPUTER_TYPE: $out .= $LANG["Menu"][0]; break; case NETWORKING_TYPE: $out .= $LANG["Menu"][1]; break; case PRINTER_TYPE: $out .= $LANG["Menu"][2]; break; case PERIPHERAL_TYPE: $out .= $LANG["Menu"][16]; break; case PHONE_TYPE: $out .= $LANG["Menu"][34]; break; } $out .= '</center>'; return $out; break; } break; // * // * case PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS: switch ($table . '.' . $field) { } break; // * Ports date connection - report (plugins/fusioninventory/report/ports_date_connections.php) // * Ports date connection - report (plugins/fusioninventory/report/ports_date_connections.php) case PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS2: switch ($table . '.' . $field) { // ** Name and link of networking device (switch) case "glpi_plugin_fusioninventory_networking_ports.ID": $query = "SELECT `glpi_networking`.`name` AS `name`, `glpi_networking`.`ID` AS `ID`\n FROM `glpi_networking`\n LEFT JOIN `glpi_networking_ports`\n ON `on_device` = `glpi_networking`.`ID`\n LEFT JOIN `glpi_plugin_fusioninventory_networking_ports`\n ON `glpi_networking_ports`.`ID`=`FK_networking_ports`\n WHERE `glpi_plugin_fusioninventory_networking_ports`.`ID`='" . $data["ITEM_{$num}"] . "'\n LIMIT 0,1;"; $result = $DB->query($query); $data2 = $DB->fetch_assoc($result); $out = "<a href='" . GLPI_ROOT . "/front/networking.form.php?ID=" . $data2["ID"] . "'>" . $data2["name"] . "</a>"; return "<center>" . $out . "</center>"; break; // ** Name and link of port of networking device (port of switch) // ** Name and link of port of networking device (port of switch) case "glpi_plugin_fusioninventory_networking_ports.FK_networking_ports": $netport = new Netport(); $netport->getFromDB($data["ITEM_{$num}"]); $name = ""; if (isset($netport->fields["name"])) { $name = $netport->fields["name"]; } $out = "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $data["ITEM_{$num}"] . "'>" . $name . "</a>"; return "<center>" . $out . "</center>"; break; // ** Location of switch // ** Location of switch case "glpi_dropdown_locations.ID": $out = Dropdown::getDropdownName("glpi_dropdown_locations", $data["ITEM_{$num}"]); return "<center>" . $out . "</center>"; break; } break; // * FusionInventory Agents list (plugins/fusioninventory/front/agents.php) // * FusionInventory Agents list (plugins/fusioninventory/front/agents.php) case PLUGIN_FUSIONINVENTORY_SNMP_AGENTS: break; // * range IP list (plugins/fusioninventory/front/rangeip.php) // * range IP list (plugins/fusioninventory/front/rangeip.php) case PLUGIN_FUSIONINVENTORY_SNMP_RANGEIP: switch ($table . '.' . $field) { // ** Display entity name case "glpi_entities.name": if ($data["ITEM_{$num}"] == '') { $out = Dropdown::getDropdownName("glpi_entities", $data["ITEM_{$num}"]); return "<center>" . $out . "</center>"; } break; } break; // * Detail of ports history (plugins/fusioninventory/report/switch_ports.history.php) // * Detail of ports history (plugins/fusioninventory/report/switch_ports.history.php) case PLUGIN_FUSIONINVENTORY_SNMP_HISTORY: switch ($table . '.' . $field) { // ** Display switch and Port case "glpi_networking_ports.ID": $Array_device = PluginFusioninventoryPort::getUniqueObjectfieldsByportID($data["ITEM_{$num}"]); $CommonItem = new CommonItem(); $CommonItem->getFromDB($Array_device["device_type"], $Array_device["on_device"]); $out = "<div align='center'>" . $CommonItem->getLink(1); $query = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `ID`='" . $data["ITEM_{$num}"] . "';"; $result = $DB->query($query); if ($DB->numrows($result) != "0") { $out .= "<br/><a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $data["ITEM_{$num}"] . "'>" . $DB->result($result, 0, "name") . "</a>"; } $out .= "</td>"; return $out; break; // ** Display GLPI field of device // ** Display GLPI field of device case "glpi_plugin_fusioninventory_snmphistories.Field": $out = $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data["ITEM_{$num}"]]['name']; return $out; break; // ** Display Old Value (before changement of value) // ** Display Old Value (before changement of value) case "glpi_plugin_fusioninventory_snmphistories.old_value": // TODO ADD LINK TO DEVICE if (substr_count($data["ITEM_{$num}"], ":") == 5 and empty($data["ITEM_3"])) { return "<center><b>" . $data["ITEM_{$num}"] . "</b></center>"; } break; // ** Display New Value (new value modified) // ** Display New Value (new value modified) case "glpi_plugin_fusioninventory_snmphistories.new_value": if (substr_count($data["ITEM_{$num}"], ":") == 5 and empty($data["ITEM_3"])) { return "<center><b>" . $data["ITEM_{$num}"] . "</b></center>"; } break; } break; } return ""; }