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


PHP Monitor::reset方法代码示例

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


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

示例1: importMonitor

 /**
  *
  * Import monitors from OCS
  * @since 1.0
  * @param $cfg_ocs OCSNG mode configuration
  * @param $computers_id computer's id in GLPI
  * @param $ocsservers_id OCS server id
  * @param $ocsid computer's id in OCS
  * @param entity the entity in which the monitor will be created
  * @param dohistory record in history link between monitor and computer
  */
 static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsComputer, $entity, $dohistory)
 {
     global $DB;
     $already_processed = array();
     $do_clean = true;
     $m = new Monitor();
     $conn = new Computer_Item();
     $monitors = array();
     $checkserial = true;
     // First pass - check if all serial present
     if ($ocsComputer) {
         if (isset($ocsComputer["MONITORS"])) {
             foreach ($ocsComputer["MONITORS"] as $monitor) {
                 // Config says import monitor with serial number only
                 // Restrict SQL query ony for monitors with serial present
                 if ($cfg_ocs["import_monitor"] > 2 && empty($monitor["SERIAL"])) {
                     unset($monitor);
                 } else {
                     $monitors[] = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($monitor));
                 }
             }
         }
     }
     if (count($monitors) > 0 && $cfg_ocs["import_monitor"] > 0) {
         foreach ($monitors as $monitor) {
             $mon = array();
             if (!empty($monitor["CAPTION"])) {
                 $mon["name"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $monitor["CAPTION"]);
                 $mon["monitormodels_id"] = Dropdown::importExternal('MonitorModel', $monitor["CAPTION"]);
             }
             if (empty($monitor["CAPTION"]) && !empty($monitor["MANUFACTURER"])) {
                 $mon["name"] = $monitor["MANUFACTURER"];
             }
             if (empty($monitor["CAPTION"]) && !empty($monitor["TYPE"])) {
                 if (!empty($monitor["MANUFACTURER"])) {
                     $mon["name"] .= " ";
                 }
                 $mon["name"] .= $monitor["TYPE"];
             }
             if (!empty($monitor["TYPE"])) {
                 $mon["monitortypes_id"] = Dropdown::importExternal('MonitorType', $monitor["TYPE"]);
             }
             $mon["serial"] = $monitor["SERIAL"];
             //Look for a monitor with the same name (and serial if possible) already connected
             //to this computer
             $query = "SELECT `m`.`id`, `gci`.`is_deleted`\n                         FROM `glpi_monitors` as `m`, `glpi_computers_items` as `gci`\n                         WHERE `m`.`id` = `gci`.`items_id`\n                            AND `gci`.`is_dynamic`='1'\n                            AND `computers_id`='{$computers_id}'\n                            AND `itemtype`='Monitor'\n                            AND `m`.`name`='" . $mon["name"] . "'";
             if ($cfg_ocs["import_monitor"] > 2 && !empty($mon["serial"])) {
                 $query .= " AND `m`.`serial`='" . $mon["serial"] . "'";
             }
             $results = $DB->query($query);
             $id = false;
             $lock = false;
             if ($DB->numrows($results) == 1) {
                 $id = $DB->result($results, 0, 'id');
                 $lock = $DB->result($results, 0, 'is_deleted');
             }
             if ($id == false) {
                 // Clean monitor object
                 $m->reset();
                 $mon["manufacturers_id"] = Dropdown::importExternal('Manufacturer', $monitor["MANUFACTURER"]);
                 if ($cfg_ocs["import_monitor_comment"]) {
                     $mon["comment"] = $monitor["DESCRIPTION"];
                 }
                 $id_monitor = 0;
                 if ($cfg_ocs["import_monitor"] == 1) {
                     //Config says : manage monitors as global
                     //check if monitors already exists in GLPI
                     $mon["is_global"] = 1;
                     $query = "SELECT `id`\n                               FROM `glpi_monitors`\n                               WHERE `name` = '" . $mon["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_monitor = $DB->result($result_search, 0, "id");
                     } else {
                         $input = $mon;
                         if ($cfg_ocs["states_id_default"] > 0) {
                             $input["states_id"] = $cfg_ocs["states_id_default"];
                         }
                         $input["entities_id"] = $entity;
                         $id_monitor = $m->add($input);
                     }
                 } else {
                     if ($cfg_ocs["import_monitor"] >= 2) {
                         //Config says : manage monitors as single units
                         //Import all monitors as non global.
                         $mon["is_global"] = 0;
                         // Try to find a monitor with the same serial.
                         if (!empty($mon["serial"])) {
//.........这里部分代码省略.........
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:ocsserver.class.php

示例2: importMonitor

 /**
  *
  * Import monitors from OCS
  * @since 1.0
  * @param $cfg_ocs OCSNG mode configuration
  * @param $computers_id computer's id in GLPI
  * @param $ocsservers_id OCS server id
  * @param $ocsid computer's id in OCS
  * @param entity the entity in which the monitor will be created
  * @param dohistory record in history link between monitor and computer
  */
 static function importMonitor($cfg_ocs, $computers_id, $ocsservers_id, $ocsid, $entity, $dohistory)
 {
     global $PluginOcsinventoryngDBocs, $DB;
     self::checkOCSconnection($ocsservers_id);
     if ($cfg_ocs["import_monitor"]) {
         $already_processed = array();
         $do_clean = true;
         $m = new Monitor();
         $conn = new Computer_Item();
         $query = "SELECT DISTINCT `CAPTION`, `MANUFACTURER`, `DESCRIPTION`, `SERIAL`, `TYPE`\n                   FROM `monitors`\n                   WHERE `HARDWARE_ID` = '{$ocsid}'";
         // Config says import monitor with serial number only
         // Restrict SQL query ony for monitors with serial present
         if ($cfg_ocs["import_monitor"] == 4) {
             $query = $query . " AND `SERIAL` NOT LIKE ''";
         }
         $result = $PluginOcsinventoryngDBocs->query($query);
         $lines = array();
         $checkserial = true;
         // First pass - check if all serial present
         if ($PluginOcsinventoryngDBocs->numrows($result) > 0) {
             while ($line = $PluginOcsinventoryngDBocs->fetch_array($result)) {
                 if (empty($line["SERIAL"])) {
                     $checkserial = false;
                 }
                 $lines[] = Toolbox::clean_cross_side_scripting_deep(Toolbox::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"];
                 //Look for a monitor with the same name (and serial if possible) already connected
                 //to this computer
                 $query = "SELECT `m`.`id`, `gci`.`is_deleted`\n                         FROM `glpi_monitors` as `m`, `glpi_computers_items` as `gci`\n                         WHERE `m`.`id` = `gci`.`items_id`\n                            AND `gci`.`is_dynamic`='1'\n                            AND `computers_id`='{$computers_id}'\n                            AND `itemtype`='Monitor'\n                            AND `m`.`name`='" . $mon["name"] . "'";
                 if (!empty($mon["serial"])) {
                     $query .= " AND `m`.`serial`='" . $mon["serial"] . "'";
                 }
                 $results = $DB->query($query);
                 $id = false;
                 $lock = false;
                 if ($DB->numrows($results) == 1) {
                     $id = $DB->result($results, 0, 'id');
                     $lock = $DB->result($results, 0, 'is_deleted');
                 }
                 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) {
                         //Config says : manage monitors as global
                         //check if monitors already exists in GLPI
                         $mon["is_global"] = 1;
                         $query = "SELECT `id`\n                               FROM `glpi_monitors`\n                               WHERE `name` = '" . $mon["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_monitor = $DB->result($result_search, 0, "id");
                         } else {
                             $input = $mon;
                             if ($cfg_ocs["states_id_default"] > 0) {
                                 $input["states_id"] = $cfg_ocs["states_id_default"];
                             }
                             $input["entities_id"] = $entity;
                             $id_monitor = $m->add($input);
                         }
                     } else {
                         if ($cfg_ocs["import_monitor"] >= 2) {
                             //Config says : manage monitors as single units
                             //Import all monitors as non global.
                             $mon["is_global"] = 0;
                             // Try to find a monitor with the same serial.
                             if (!empty($mon["serial"])) {
                                 $query = "SELECT `id`\n                                  FROM `glpi_monitors`\n                                  WHERE `serial` LIKE '%" . $mon["serial"] . "%'\n                                     AND `is_global` = '0'\n                                     AND `entities_id` = '{$entity}'";
                                 $result_search = $DB->query($query);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:ocsserver.class.php

示例3: 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


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