pluginsGLPI / ocsinventoryng

Plugin ocsinventoryng for GLPI
GNU General Public License v2.0
68 stars 52 forks source link

Force full import delete software if it is installed once. #226

Open fgendorf opened 5 years ago

fgendorf commented 5 years ago

Hi, when I force synchronization of a computer, if software there are one version, the software is deleted and recreated again and all information about this software is lost, doesn't matter if the software was licenses, attributes, etc

file: plugins/ocsinventoryng/inc/software.class.php lines: 484:495

$query3  = "SELECT COUNT(*)
                          FROM `glpi_softwareversions`
                          WHERE `softwares_id`= " . $vers->fields['softwares_id'];
               $result3 = $DB->query($query3);

               if ($DB->result($result3, 0, 0) == 1) {
                  $soft = new Software();
                  $soft->delete(['id'          => $vers->fields['softwares_id'],
                                 '_no_history' => !$uninstall_history],
                                true,
                                $uninstall_history);
               }

maybe check if software have attributes like category changed

$query3  = "SELECT glpi.glpi_softwares.softwarecategories_id 
                          FROM `glpi_softwareversions`
                          INNER JOIN glpi.glpi_softwares ON (glpi_softwareversions.softwares_id = glpi_softwares.id )
                          WHERE glpi_softwareversions.`softwares_id`='{$vers->fields['softwares_id']}'
                          LIMIT 1";
               $result3 = $DB->query($query3);

               if ($DB->result($result3, 0, 0) == 0) {
                  $soft = new Software();
                  $soft->delete(['id'          => $vers->fields['softwares_id'],
                                 '_no_history' => !$uninstall_history],
                                true,
                                $uninstall_history);
               }