Ejemplo n.º 1
0
 /**
  * Function to uninstall an object
  *
  * @param $computers_id the computer's ID in GLPI
  *
  * @return nothing
  **/
 static function deleteOcsLink($computers_id)
 {
     $link = new PluginOcsinventoryngOcslink();
     $link->dohistory = false;
     $link->deleteByCriteria(array('computers_id' => $computers_id));
     $reg = new PluginOcsinventoryngRegistryKey();
     $reg->deleteByCriteria(array('computers_id' => $computers_id));
 }
Ejemplo n.º 2
0
 /**
  * if Computer deleted
  *
  * @param $comp   Computer object
  **/
 static function purgeComputer(Computer $comp)
 {
     $link = new self();
     $link->deleteByCriteria(array('computers_id' => $comp->getField("id")));
     $reg = new PluginOcsinventoryngRegistryKey();
     $reg->deleteByCriteria(array('computers_id' => $comp->getField("id")));
 }
Ejemplo n.º 3
0
 /**
  * Update config of the registry
  *
  * This function erase old data and import the new ones about registry (Microsoft OS after Windows 95)
  *
  * @param $computers_id integer : glpi computer id.
  * @param $ocsid integer : ocs computer id (ID).
  * @param $plugin_ocsinventoryng_ocsservers_id integer : ocs server id
  * @param $cfg_ocs array : ocs config
  *
  * @return Nothing (void).
  **/
 static function updateRegistry($computers_id, $ocsComputer, $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs)
 {
     global $DB;
     //before update, delete all entries about $computers_id
     $query_delete = "DELETE\n                          FROM `glpi_plugin_ocsinventoryng_registrykeys`\n                          WHERE `computers_id` = '{$computers_id}'";
     $DB->query($query_delete);
     if (isset($ocsComputer['REGISTRY'])) {
         if (count($ocsComputer["REGISTRY"]) > 0) {
             $reg = new PluginOcsinventoryngRegistryKey();
             //update data
             foreach ($ocsComputer["REGISTRY"] as $registry) {
                 $input = array();
                 $input["computers_id"] = $computers_id;
                 $input["hive"] = $registry["regtree"];
                 $input["value"] = $registry["regvalue"];
                 $input["path"] = $registry["regkey"];
                 $input["ocs_name"] = $registry["name"];
                 $isNewReg = $reg->add($input, array('disable_unicity_check' => true));
                 unset($reg->fields);
             }
         }
     }
     return;
 }
Ejemplo n.º 4
0
 /**
  * Update config of the registry
  *
  * This function erase old data and import the new ones about registry (Microsoft OS after Windows 95)
  *
  * @param $computers_id integer : glpi computer id.
  * @param $ocsid integer : ocs computer id (ID).
  * @param $plugin_ocsinventoryng_ocsservers_id integer : ocs server id
  * @param $cfg_ocs array : ocs config
  *
  * @return Nothing (void).
  **/
 static function updateRegistry($computers_id, $ocsid, $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs)
 {
     global $DB, $PluginOcsinventoryngDBocs;
     self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
     if ($cfg_ocs["import_registry"]) {
         //before update, delete all entries about $computers_id
         $query_delete = "DELETE\n                          FROM `glpi_plugin_ocsinventoryng_registrykeys`\n                          WHERE `computers_id` = '{$computers_id}'";
         $DB->query($query_delete);
         //Get data from OCS database
         $query = "SELECT `registry`.`NAME` AS name,\n                          `registry`.`REGVALUE` AS regvalue,\n                          `registry`.`HARDWARE_ID` AS computers_id,\n                          `regconfig`.`REGTREE` AS regtree,\n                          `regconfig`.`REGKEY` AS regkey\n                   FROM `registry`\n                   LEFT JOIN `regconfig` ON (`registry`.`NAME` = `regconfig`.`NAME`)\n                   WHERE `HARDWARE_ID` = '{$ocsid}'";
         $result = $PluginOcsinventoryngDBocs->query($query);
         if ($PluginOcsinventoryngDBocs->numrows($result) > 0) {
             $reg = new PluginOcsinventoryngRegistryKey();
             //update data
             while ($data = $PluginOcsinventoryngDBocs->fetch_array($result)) {
                 $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
                 $input = array();
                 $input["computers_id"] = $computers_id;
                 $input["hive"] = $data["regtree"];
                 $input["value"] = $data["regvalue"];
                 $input["path"] = $data["regkey"];
                 $input["ocs_name"] = $data["name"];
                 $isNewReg = $reg->add($input, array('disable_unicity_check' => true));
                 unset($reg->fields);
             }
         }
     }
     return;
 }
Ejemplo n.º 5
0
 /**
  * Update config of the registry
  *
  * This function erase old data and import the new ones about registry (Microsoft OS after Windows 95)
  *
  * @param $computers_id integer : glpi computer id.
  * @param $ocsComputer
  * @internal param int $plugin_ocsinventoryng_ocsservers_id : ocs server id
  * @internal param array $cfg_ocs : ocs config
  * @internal param int $ocsid : ocs computer id (ID).
  */
 static function updateRegistry($computers_id, $ocsComputer)
 {
     //before update, delete all entries about $computers_id
     self::resetRegistry($computers_id);
     $reg = new PluginOcsinventoryngRegistryKey();
     //update data
     foreach ($ocsComputer as $registry) {
         $registry = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($registry));
         $input = array();
         $input["computers_id"] = $computers_id;
         $input["hive"] = $registry["regtree"];
         $input["value"] = $registry["regvalue"];
         $input["path"] = $registry["regkey"];
         $input["ocs_name"] = $registry["name"];
         $reg->add($input, array('disable_unicity_check' => true));
         unset($reg->fields);
     }
     return;
 }