Пример #1
0
        initState($base, $index);
    }
    if (!strstr($index, "_OK") && strstr($previous[$base]->state, "_OK")) {
        $report['partial'][$base] = $report['complete'][$base];
        if (DEBUG) {
            print "[dbg] Bobone: update state of {$base} (P)\n";
        }
        #, 3, "/opt/Bobone/logs/debug.log" );
        updateState($base, $index);
    } elseif (isset($previous[$base]) && strstr($index, "_OK") && !strstr($previous[$base]->state, '_OK')) {
        $report['recovery'][$base] = sprintf($filters[$index]['message'], $base);
        if (DEBUG) {
            print "[dbg] Bobone: update state of {$base} (R)\n";
        }
        #, 3, "/opt/Bobone/logs/debug.log" );
        updateState($base, $index);
    }
    if (DEBUG) {
        print "[dbg] out of foreach( \$pid ... ): next item\n";
    }
}
if (DEBUG) {
    print "[dbg] out of foreach( \$pid ... )\n";
}
#if (DEBUG) var_dump($report);
if (DEBUG) {
    print "[DBG] \$contacts = ";
    var_dump($contacts);
}
if (DEBUG) {
    print "[DBG] \$report = ";
Пример #2
0
 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;
 }