当前位置: 首页>>代码示例>>PHP>>正文


PHP Printer::update方法代码示例

本文整理汇总了PHP中Printer::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::update方法的具体用法?PHP Printer::update怎么用?PHP Printer::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Printer的用法示例。


在下文中一共展示了Printer::update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updatePrinter

 /**
  * Function to update Printer
  *
  * @param array $a_inventory data fron agent inventory
  * @param id $items_id id of the printer
  *
  * @return nothing
  */
 function updatePrinter($a_inventory, $items_id)
 {
     global $DB;
     $printer = new Printer();
     $pfPrinter = new PluginFusioninventoryPrinter();
     $printer->getFromDB($items_id);
     if (!isset($_SESSION['glpiactiveentities_string'])) {
         $_SESSION['glpiactiveentities_string'] = $printer->fields['entities_id'];
     }
     if (!isset($_SESSION['glpiactiveentities'])) {
         $_SESSION['glpiactiveentities'] = array($printer->fields['entities_id']);
     }
     if (!isset($_SESSION['glpiactive_entity'])) {
         $_SESSION['glpiactive_entity'] = $printer->fields['entities_id'];
     }
     // * Printer
     $db_printer = $printer->fields;
     $a_lockable = PluginFusioninventoryLock::getLockFields('glpi_printers', $items_id);
     $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['Printer'], $db_printer, $a_lockable);
     $a_inventory['Printer'] = $a_ret[0];
     $input = $a_inventory['Printer'];
     $input['id'] = $items_id;
     $printer->update($input);
     // * Printer fusion (ext)
     $db_printer = array();
     $query = "SELECT *\n            FROM `" . getTableForItemType("PluginFusioninventoryPrinter") . "`\n            WHERE `printers_id` = '{$items_id}'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_assoc($result)) {
         foreach ($data as $key => $value) {
             $db_printer[$key] = Toolbox::addslashes_deep($value);
         }
     }
     if (count($db_printer) == '0') {
         // Add
         $a_inventory['PluginFusioninventoryPrinter']['printers_id'] = $items_id;
         $pfPrinter->add($a_inventory['PluginFusioninventoryPrinter']);
     } else {
         // Update
         $idtmp = $db_printer['id'];
         unset($db_printer['id']);
         unset($db_printer['printers_id']);
         unset($db_printer['plugin_fusioninventory_configsecurities_id']);
         $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['PluginFusioninventoryPrinter'], $db_printer);
         $a_inventory['PluginFusioninventoryPrinter'] = $a_ret[0];
         $input = $a_inventory['PluginFusioninventoryPrinter'];
         $input['id'] = $idtmp;
         $pfPrinter->update($input);
     }
     // * Ports
     $this->importPorts($a_inventory, $items_id);
     // Page counters
     $this->importPageCounters($a_inventory['pagecounters'], $items_id);
     // Cartridges
     $this->importCartridges($a_inventory['cartridge'], $items_id);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:63,代码来源:inventoryprinterlib.class.php

示例2: pluginFusioninventoryUpdate


//.........这里部分代码省略.........
                    $result = $DB->query($query);
                    while ($data = $DB->fetch_array($result)) {
                        $prepare_agentConfig[] = array("id" => $data["ID"], "threads_networkinventory" => $data['threads_query'], "threads_networkdiscovery" => $data['threads_discovery'], "NETORKINVENTORY" => $data['module_snmpquery'], "NETWORKDISCOVERY" => $data['module_netdiscovery'], "INVENTORY" => $data['module_inventory'], "WAKEONLAN" => $data['module_wakeonlan']);
                    }
                }
            }
        }
    }
    $a_table = array();
    $a_table['name'] = 'glpi_plugin_fusioninventory_agents';
    $a_table['oldname'] = array('glpi_plugin_tracker_agents');
    $a_table['fields'] = array();
    $a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
    $a_table['fields']['entities_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['is_recursive'] = array('type' => 'bool', 'value' => '1');
    $a_table['fields']['name'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['last_contact'] = array('type' => 'datetime', 'value' => NULL);
    $a_table['fields']['version'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['lock'] = array('type' => 'bool', 'value' => NULL);
    $a_table['fields']['device_id'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['computers_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['token'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['useragent'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['tag'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['threads_networkdiscovery'] = array('type' => "int(4) NOT NULL DEFAULT '1' COMMENT 'array(xmltag=>value)'", 'value' => NULL);
    $a_table['fields']['threads_networkinventory'] = array('type' => "int(4) NOT NULL DEFAULT '1' COMMENT 'array(xmltag=>value)'", 'value' => NULL);
    $a_table['fields']['senddico'] = array('type' => 'bool', 'value' => NULL);
    $a_table['fields']['timeout_networkdiscovery'] = array('type' => "int(4) NOT NULL DEFAULT '0' COMMENT 'Network Discovery task timeout'", 'value' => NULL);
    $a_table['fields']['timeout_networkinventory'] = array('type' => "int(4) NOT NULL DEFAULT '0' COMMENT 'Network Inventory task timeout'", 'value' => NULL);
    $a_table['fields']['agent_port'] = array('type' => 'varchar(6)', 'value' => NULL);
    $a_table['oldfields'] = array('module_snmpquery', 'module_netdiscovery', 'module_inventory', 'module_wakeonlan', 'core_discovery', 'threads_discovery', 'core_query', 'threads_query', 'tracker_agent_version', 'logs', 'fragment', 'itemtype', 'device_type');
    $a_table['renamefields'] = array();
    $a_table['renamefields']['ID'] = 'id';
    $a_table['renamefields']['last_agent_update'] = 'last_contact';
    $a_table['renamefields']['fusioninventory_agent_version'] = 'version';
    $a_table['renamefields']['key'] = 'device_id';
    $a_table['renamefields']['on_device'] = 'computers_id';
    $a_table['renamefields']['items_id'] = 'computers_id';
    $a_table['keys'] = array();
    $a_table['keys'][] = array('field' => 'name', 'name' => '', 'type' => 'INDEX');
    $a_table['keys'][] = array('field' => 'device_id', 'name' => '', 'type' => 'INDEX');
    $a_table['keys'][] = array('field' => 'computers_id', 'name' => '', 'type' => 'INDEX');
    $a_table['oldkeys'] = array('key');
    migrateTablesFusionInventory($migration, $a_table);
    /*
     * Table glpi_plugin_fusioninventory_agentmodules
     */
    $a_table = array();
    $a_table['name'] = 'glpi_plugin_fusioninventory_agentmodules';
    $a_table['oldname'] = array();
    $a_table['fields'] = array();
    $a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
    $a_table['fields']['modulename'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['is_active'] = array('type' => 'bool', 'value' => NULL);
    $a_table['fields']['exceptions'] = array('type' => 'text', 'value' => NULL);
    $a_table['oldfields'] = array();
    $a_table['oldfields'][] = 'plugins_id';
    $a_table['oldfields'][] = 'entities_id';
    $a_table['oldfields'][] = 'url';
    $a_table['renamefields'] = array();
    $a_table['keys'] = array();
    $a_table['keys'][] = array('field' => 'modulename', 'name' => '', 'type' => 'UNIQUE');
    $a_table['oldkeys'] = array('unicity', 'entities_id');
    migrateTablesFusionInventory($migration, $a_table);
    /*
     * Add Deploy module
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:67,代码来源:update.php

示例3: replayDictionnaryOnOnePrinter

 /**
  * Replay dictionnary on one printer
  *
  * @param &$new_printers   array containing new printers already computed
  * @param $res_rule        array of rule results
  * @param $params          array
  * @param &$printers_ids   array containing replay printer need to be dustbined
  **/
 function replayDictionnaryOnOnePrinter(array &$new_printers, array $res_rule, $params = array(), array &$printers_ids)
 {
     global $DB;
     $p['id'] = 0;
     $p['name'] = '';
     $p['manufacturer'] = '';
     $p['is_global'] = '';
     $p['entity'] = 0;
     foreach ($params as $key => $value) {
         $p[$key] = $value;
     }
     $input["name"] = $p['name'];
     $input["manufacturer"] = $p['manufacturer'];
     if (empty($res_rule)) {
         $res_rule = $this->processAllRules($input, array(), array());
     }
     $printer = new Printer();
     //Printer's name has changed
     if (isset($res_rule["name"]) && $res_rule["name"] != $p['name']) {
         $manufacturer = "";
         if (isset($res_rule["manufacturer"])) {
             $manufacturer = addslashes(Dropdown::getDropdownName("glpi_manufacturers", $res_rule["manufacturer"]));
         } else {
             $manufacturer = addslashes($p['manufacturer']);
         }
         //New printer not already present in this entity
         if (!isset($new_printers[$p['entity']][$res_rule["name"]])) {
             // create new printer or restore it from dustbin
             $new_printer_id = $printer->addOrRestoreFromTrash($res_rule["name"], $manufacturer, $p['entity']);
             $new_printers[$p['entity']][$res_rule["name"]] = $new_printer_id;
         } else {
             $new_printer_id = $new_printers[$p['entity']][$res_rule["name"]];
         }
         // Move direct connections
         $this->moveDirectConnections($p['id'], $new_printer_id);
     } else {
         $new_printer_id = $p['id'];
         $res_rule["id"] = $p['id'];
         if (isset($res_rule["manufacturer"])) {
             if ($res_rule["manufacturer"] != '') {
                 $res_rule["manufacturers_id"] = $res_rule["manufacturer"];
             }
             unset($res_rule["manufacturer"]);
         }
         $printer->update($res_rule);
     }
     // Add to printer to deleted list
     if ($new_printer_id != $p['id']) {
         $printers_ids[] = $p['id'];
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:59,代码来源:ruledictionnaryprintercollection.class.php

示例4: commonHeader

 } else {
     if (isset($_POST["restore"])) {
         $print->check($_POST["id"], 'd');
         $print->restore($_POST);
         Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]);
         $print->redirectToList();
     } else {
         if (isset($_REQUEST["purge"])) {
             $print->check($_REQUEST["id"], 'd');
             $print->delete($_REQUEST, 1);
             Event::log($_REQUEST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]);
             $print->redirectToList();
         } else {
             if (isset($_POST["update"])) {
                 $print->check($_POST["id"], 'w');
                 $print->update($_POST);
                 Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
                 glpi_header($_SERVER['HTTP_REFERER']);
             } else {
                 if (isset($_GET["unglobalize"])) {
                     $print->check($_GET["id"], 'w');
                     Computer_Item::unglobalizeItem($print);
                     Event::log($_GET["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][60]);
                     glpi_header($CFG_GLPI["root_doc"] . "/front/printer.form.php?id=" . $_GET["id"]);
                 } else {
                     commonHeader($LANG['Menu'][2], $_SERVER['PHP_SELF'], "inventory", "printer");
                     $print->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
                     commonFooter();
                 }
             }
         }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:printer.form.php

示例5: importPrinter


//.........这里部分代码省略.........
                 $params['manufacturer'] = "";
                 $params['DRIVER'] = $line['DRIVER'];
                 $params['PORT'] = $line['PORT'];
                 if (!empty($print["name"])) {
                     $rulecollection = new RuleDictionnaryPrinterCollection();
                     $res_rule = Toolbox::addslashes_deep($rulecollection->processAllRules(Toolbox::stripslashes_deep($params), array(), array()));
                     if (!isset($res_rule["_ignore_import"]) || !$res_rule["_ignore_import"]) {
                         foreach ($res_rule as $key => $value) {
                             if ($value != '' && $value[0] != '_') {
                                 $print[$key] = $value;
                             }
                         }
                         if (isset($res_rule['is_global'])) {
                             if (!$res_rule['is_global']) {
                                 $management_process = 2;
                             } else {
                                 $management_process = 1;
                             }
                         }
                         //Look for a monitor with the same name (and serial if possible) already connected
                         //to this computer
                         $query = "SELECT `p`.`id`, `gci`.`is_deleted`\n                               FROM `glpi_printers` as `p`, `glpi_computers_items` as `gci`\n                               WHERE `p`.`id` = `gci`.`items_id`\n                                  AND `gci`.`is_dynamic`='1'\n                                  AND `computers_id`='{$computers_id}'\n                                  AND `itemtype`='Printer'\n                                  AND `p`.`name`='" . $print["name"] . "'";
                         $results = $DB->query($query);
                         $id = false;
                         $lock = false;
                         if ($DB->numrows($results) > 0) {
                             $id = $DB->result($results, 0, 'id');
                             $lock = $DB->result($results, 0, 'is_deleted');
                         }
                         if (!$id) {
                             // Clean printer object
                             $p->reset();
                             $print["comment"] = $line["PORT"] . "\r\n" . $line["DRIVER"];
                             self::analizePrinterPorts($print, $line["PORT"]);
                             $id_printer = 0;
                             if ($management_process == 1) {
                                 //Config says : manage printers as global
                                 //check if printers already exists in GLPI
                                 $print["is_global"] = MANAGEMENT_GLOBAL;
                                 $query = "SELECT `id`\n                                      FROM `glpi_printers`\n                                      WHERE `name` = '" . $print["name"] . "'\n                                         AND `is_global` = '1'\n                                         AND `entities_id` = '{$entity}'";
                                 $result_search = $DB->query($query);
                                 if ($DB->numrows($result_search) > 0) {
                                     //Periph is already in GLPI
                                     //Do not import anything just get periph ID for link
                                     $id_printer = $DB->result($result_search, 0, "id");
                                     $already_processed[] = $id_printer;
                                 } else {
                                     $input = $print;
                                     if ($cfg_ocs["states_id_default"] > 0) {
                                         $input["states_id"] = $cfg_ocs["states_id_default"];
                                     }
                                     $input["entities_id"] = $entity;
                                     $id_printer = $p->add($input);
                                 }
                             } else {
                                 if ($management_process == 2) {
                                     //Config says : manage printers as single units
                                     //Import all printers as non global.
                                     $input = $print;
                                     $input["is_global"] = MANAGEMENT_UNITARY;
                                     if ($cfg_ocs["states_id_default"] > 0) {
                                         $input["states_id"] = $cfg_ocs["states_id_default"];
                                     }
                                     $input["entities_id"] = $entity;
                                     $input['is_dynamic'] = 1;
                                     $id_printer = $p->add($input);
                                 }
                             }
                             if ($id_printer) {
                                 $already_processed[] = $id_printer;
                                 $conn = new Computer_Item();
                                 $connID = $conn->add(array('computers_id' => $computers_id, 'itemtype' => 'Printer', 'items_id' => $id_printer, '_no_history' => !$dohistory, 'is_dynamic' => 1));
                                 //Update column "is_deleted" set value to 0 and set status to default
                                 $input = array();
                                 $input["id"] = $id_printer;
                                 $input["is_deleted"] = 0;
                                 $input["entities_id"] = $entity;
                                 if ($cfg_ocs["states_id_default"] > 0) {
                                     $input["states_id"] = $cfg_ocs["states_id_default"];
                                 }
                                 $p->update($input);
                             }
                         } else {
                             $already_processed[] = $id;
                         }
                     }
                 }
             }
         }
         //Look for all monitors, not locked, not linked to the computer anymore
         $query = "SELECT `id`\n                    FROM `glpi_computers_items`\n                    WHERE `itemtype`='Printer'\n                       AND `computers_id`='{$computers_id}'\n                       AND `is_dynamic`='1'\n                       AND `is_deleted`='0'";
         if (!empty($already_processed)) {
             $query .= "AND `items_id` NOT IN (" . implode(',', $already_processed) . ")";
         }
         foreach ($DB->request($query) as $data) {
             //Delete all connexions
             $conn->delete(array('id' => $data['id'], '_ocsservers_id' => $ocsservers_id), true);
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:ocsserver.class.php

示例6: Printer

 function post_updateItem($history = 1)
 {
     if (in_array('pages', $this->updates)) {
         $printer = new Printer();
         if ($printer->getFromDB($this->fields['printers_id']) && ($this->fields['pages'] > $printer->getField('last_pages_counter') || $this->oldvalues['pages'] == $printer->getField('last_pages_counter'))) {
             $printer->update(array('id' => $printer->getID(), 'last_pages_counter' => $this->fields['pages']));
         }
     }
     parent::post_updateItem($history);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:10,代码来源:cartridge.class.php

示例7: importPrinter


//.........这里部分代码省略.........
                     $id = $DB->result($results, 0, 'id');
                     $lock = $DB->result($results, 0, 'is_deleted');
                 }
                 if (!$id) {
                     // Clean printer object
                     $p->reset();
                     $print["comment"] = $printer["PORT"] . "\r\n" . $printer["DRIVER"];
                     self::analizePrinterPorts($print, $printer["PORT"]);
                     $id_printer = 0;
                     if ($management_process == 1) {
                         //Config says : manage printers as global
                         //check if printers already exists in GLPI
                         $print["is_global"] = MANAGEMENT_GLOBAL;
                         $query = "SELECT `id`\n                                         FROM `glpi_printers`\n                                         WHERE `name` = '" . $print["name"] . "'\n                                            AND `is_global` = '1' ";
                         if ($CFG_GLPI['transfers_id_auto'] < 1) {
                             $query .= " AND `entities_id` = '{$entity}'";
                         }
                         $result_search = $DB->query($query);
                         if ($DB->numrows($result_search) > 0) {
                             //Periph is already in GLPI
                             //Do not import anything just get periph ID for link
                             $id_printer = $DB->result($result_search, 0, "id");
                             $already_processed[] = $id_printer;
                         } else {
                             $input = $print;
                             if ($cfg_ocs["states_id_default"] > 0) {
                                 $input["states_id"] = $cfg_ocs["states_id_default"];
                             }
                             $input["entities_id"] = $entity;
                             $id_printer = $p->add($input, array(), $cfg_ocs['history_printer']);
                         }
                     } else {
                         if ($management_process == 2) {
                             //Config says : manage printers as single units
                             //Import all printers as non global.
                             $input = $print;
                             $input["is_global"] = MANAGEMENT_UNITARY;
                             if ($cfg_ocs["states_id_default"] > 0) {
                                 $input["states_id"] = $cfg_ocs["states_id_default"];
                             }
                             $input["entities_id"] = $entity;
                             $input['is_dynamic'] = 1;
                             $id_printer = $p->add($input, array(), $cfg_ocs['history_printer']);
                         }
                     }
                     if ($id_printer) {
                         $already_processed[] = $id_printer;
                         $conn = new Computer_Item();
                         $connID = $conn->add(array('computers_id' => $computers_id, 'itemtype' => 'Printer', 'items_id' => $id_printer, 'is_dynamic' => 1), array(), $cfg_ocs['history_printer']);
                         //Update column "is_deleted" set value to 0 and set status to default
                         $input = array();
                         $input["id"] = $id_printer;
                         $input["is_deleted"] = 0;
                         $input["entities_id"] = $entity;
                         if ($cfg_ocs["states_id_default"] > 0) {
                             $input["states_id"] = $cfg_ocs["states_id_default"];
                         }
                         $p->update($input, $cfg_ocs['history_printer']);
                     }
                 } else {
                     $already_processed[] = $id;
                 }
             }
         }
     }
     //Look for all printers, not locked, not linked to the computer anymore
     $query = "SELECT `id`\n                    FROM `glpi_computers_items`\n                    WHERE `itemtype`='Printer'\n                       AND `computers_id`='{$computers_id}'\n                       AND `is_dynamic`\n                       AND `is_deleted`='0'";
     if (!empty($already_processed)) {
         $query .= "AND `items_id` NOT IN (" . implode(',', $already_processed) . ")";
     }
     foreach ($DB->request($query) as $data) {
         // Delete all connexions
         //Get OCS configuration
         $ocs_config = self::getConfig($ocsservers_id);
         //Get the management mode for this device
         $mode = self::getDevicesManagementMode($ocs_config, 'Printer');
         $decoConf = $ocs_config["deconnection_behavior"];
         //Change status if :
         // 1 : the management mode IS NOT global
         // 2 : a deconnection's status have been defined
         // 3 : unique with serial
         if ($mode >= 2 && strlen($decoConf) > 0) {
             //Delete periph from glpi
             if ($decoConf == "delete") {
                 $query = "DELETE\n                FROM `glpi_computers_items`\n                WHERE `id`='" . $data['id'] . "'";
                 $DB->query($query);
                 //Put periph in dustbin
             } else {
                 if ($decoConf == "trash") {
                     $query = "UPDATE\n                `glpi_computers_items`\n                SET `is_deleted` = 1\n                WHERE `id`='" . $data['id'] . "'";
                     $DB->query($query);
                 }
             }
         }
         // foreach ($DB->request($query) as $data){
         // Delete all connexions
         // $conn->delete(array('id'             => $data['id'],
         // '_ocsservers_id' => $ocsservers_id), true);
     }
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:101,代码来源:ocsserver.class.php

示例8: updatePeripherals

 /**
  * Import the devices for a computer
  *
  * @param $itemtype integer : item type
  * @param $entity integer : entity of the computer
  * @param $computers_id integer : glpi computer id.
  * @param $ocsid integer : ocs computer id (ID).
  * @param $ocsservers_id integer : ocs server id
  * @param $cfg_ocs array : ocs config
  * @param $import_periph array : already imported periph
  * @param $dohistory boolean : log changes ?
  *
  * @return Nothing (void).
  **/
 static function updatePeripherals($itemtype, $entity, $computers_id, $ocsid, $ocsservers_id, $cfg_ocs, $import_periph, $dohistory)
 {
     global $DB, $DBocs;
     self::checkOCSconnection($ocsservers_id);
     $do_clean = false;
     $connID = 0;
     //Tag for data since 0.70 for the import_monitor array.
     $count_monitor = count($import_periph);
     switch ($itemtype) {
         case 'Monitor':
             if ($cfg_ocs["import_monitor"]) {
                 //Update data in import_monitor array for 0.70
                 if (!in_array(self::IMPORT_TAG_070, $import_periph)) {
                     foreach ($import_periph as $key => $val) {
                         $monitor_tag = $val;
                         //delete old value
                         self::deleteInOcsArray($computers_id, $key, "import_monitor");
                         //search serial when it exists
                         $monitor_serial = "";
                         $query_monitor_id = "SELECT `items_id`\n                                          FROM `glpi_computers_items`\n                                          WHERE `id` = '{$key}'";
                         $result_monitor_id = $DB->query($query_monitor_id);
                         if ($DB->numrows($result_monitor_id) == 1) {
                             //get monitor Id
                             $id_monitor = $DB->result($result_monitor_id, 0, "items_id");
                             $query_monitor_serial = "SELECT `serial`\n                                                 FROM `glpi_monitors`\n                                                 WHERE `id` = '{$id_monitor}'";
                             $result_monitor_serial = $DB->query($query_monitor_serial);
                             //get serial
                             if ($DB->numrows($result_monitor_serial) == 1) {
                                 $monitor_serial = $DB->result($result_monitor_serial, 0, "serial");
                             }
                         }
                         //concat name + serial
                         $monitor_tag .= $monitor_serial;
                         //add new value (serial + name when its possible)
                         self::addToOcsArray($computers_id, array($key => $monitor_tag), "import_monitor");
                         //Update the array with the new value of the monitor
                         $import_periph[$key] = $monitor_tag;
                     }
                     //add the tag for the array version's
                     self::addToOcsArray($computers_id, array(0 => self::IMPORT_TAG_070), "import_monitor");
                 }
                 $do_clean = true;
                 $m = new Monitor();
                 $query = "SELECT DISTINCT `CAPTION`, `MANUFACTURER`, `DESCRIPTION`, `SERIAL`, `TYPE`\n                         FROM `monitors`\n                         WHERE `HARDWARE_ID` = '{$ocsid}'";
                 $result = $DBocs->query($query);
                 $lines = array();
                 $checkserial = true;
                 // First pass - check if all serial present
                 if ($DBocs->numrows($result) > 0) {
                     while ($line = $DBocs->fetch_array($result)) {
                         if (empty($line["SERIAL"])) {
                             $checkserial = false;
                         }
                         $lines[] = clean_cross_side_scripting_deep(addslashes_deep($line));
                     }
                 }
                 if (count($lines) > 0 && ($cfg_ocs["import_monitor"] <= 2 || $checkserial)) {
                     foreach ($lines as $line) {
                         $mon = array();
                         $mon["name"] = $line["CAPTION"];
                         if (empty($line["CAPTION"]) && !empty($line["MANUFACTURER"])) {
                             $mon["name"] = $line["MANUFACTURER"];
                         }
                         if (empty($line["CAPTION"]) && !empty($line["TYPE"])) {
                             if (!empty($line["MANUFACTURER"])) {
                                 $mon["name"] .= " ";
                             }
                             $mon["name"] .= $line["TYPE"];
                         }
                         $mon["serial"] = $line["SERIAL"];
                         $checkMonitor = $mon["name"];
                         if (!empty($mon["serial"])) {
                             $checkMonitor .= $mon["serial"];
                         }
                         if (!empty($mon["name"])) {
                             $id = array_search(stripslashes($checkMonitor), $import_periph);
                         }
                         if ($id === false) {
                             // Clean monitor object
                             $m->reset();
                             $mon["manufacturers_id"] = Dropdown::importExternal('Manufacturer', $line["MANUFACTURER"]);
                             if ($cfg_ocs["import_monitor_comment"]) {
                                 $mon["comment"] = $line["DESCRIPTION"];
                             }
                             $id_monitor = 0;
                             if ($cfg_ocs["import_monitor"] == 1) {
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:ocsserver.class.php


注:本文中的Printer::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。