function addToDB() { if ($this->getName()) { $cfg_ocs = getOcsConf($_SESSION["ocs_server_id"]); parent::getEmpty(); $this->fields = array(); $this->fields["name"] = $this->getName(); $this->fields["comments"] = $this->port . '\\n' . $this->error; $this->fields["date_mod"] = date("Y-m-d H:i:s"); $this->fields["is_global"] = 0; $this->fields["model"] = ocsImportDropdown("glpi_dropdown_model_printers", "name", $this->driver); if ($this->fgLPT) { $this->fields["flags_par"] = 1; } if ($this->fgCOM) { $this->fields["flags_serial"] = 1; } if ($this->fgUSB) { $this->fields["flags_usb"] = 1; } if ($this->id = parent::addToDB()) { if ($cfg_ocs["default_state"]) { updateState(PRINTER_TYPE, $this->id, $cfg_ocs["default_state"], 0, 0); } // Si connexion directe : connexion avec lien du lieu et du contact foreach ($this->servers as $server => &$queue) { // Si serveur : le lieu et le contact seront ceux du serveur if ($server === $this->server) { $queue->connectToServer($this->id); } else { $queue->connectToUC($this->id); } } // Connexion des files d'impression foreach ($this->queues as $host => &$queue) { if ($host != $queue->server) { $queue->connectToUC($this->id); } } // Connexion IP if ($this->IP != '') { $netport = array(); $netport["ifaddr"] = $this->IP; $netport["ifmac"] = ''; //$line2["MACADDR"]; $netport["iface"] = ocsImportDropdown("glpi_dropdown_iface", "name", "Ethernet"); $netport["name"] = "Ethernet"; $netport["on_device"] = $this->id; $netport["logical_number"] = 0; $netport["device_type"] = PRINTER_TYPE; $np = new Netport(); $np->add($netport); } } } return $this->id; }