Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Add an option to enable monitor serialnumber partial matching (#2865)
Browse files Browse the repository at this point in the history
* Add an option to enable monitor serialnumber partial matching
Option is disabled by default

* Try monitor serial partial match only if the serial number has at least 4 chars
  • Loading branch information
g-bougard authored and trasher committed Sep 20, 2019
1 parent 279dc3b commit efdd214
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function initConfigModule($getOnly = false) {
$input['import_registry'] = 1;
$input['import_process'] = 1;
$input['import_vm'] = 1;
$input['import_monitor_on_partial_sn'] = 0;
$input['component_processor'] = 1;
$input['component_memory'] = 1;
$input['component_harddrive'] = 1;
Expand Down Expand Up @@ -591,7 +592,12 @@ static function showFormInventory($options = []) {
echo "<td>";
Dropdown::showYesNo("manage_osname", $pfConfig->getValue('manage_osname'));
echo "</td>";
echo "<td colspan='2'></td>";
echo "<td>";
echo __('Import monitor on serial partial match:', 'fusioninventory');
echo "</td>";
echo "<td>";
Dropdown::showYesNo("import_monitor_on_partial_sn", $pfConfig->getValue('import_monitor_on_partial_sn'));
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
Expand Down
8 changes: 8 additions & 0 deletions inc/inventoryruleimport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ function getCriteriaByID($critname) {
function findWithGlobalCriteria($input) {
global $DB, $CFG_GLPI;

$pfConfig = new PluginFusioninventoryConfig();

PluginFusioninventoryToolbox::logIfExtradebug(
"pluginFusioninventory-rules",
$input
Expand Down Expand Up @@ -568,6 +570,12 @@ function findWithGlobalCriteria($input) {
OR `[typetable]`.`serial`='".$serial2."')";
$_SESSION["plugin_fusioninventory_serialHP"] = $serial2;

} else if (isset($input['itemtype'])
AND $input['itemtype'] == 'Monitor'
AND $pfConfig->getValue('import_monitor_on_partial_sn') == 1
AND strlen($input["serial"]) >= 4) {
// Support partial match for monitor serial
$sql_where_temp = " AND `[typetable]`.`serial` LIKE '%".$input["serial"]."%'";
} else {
$sql_where_temp = " AND `[typetable]`.`serial`='".$input["serial"]."'";
}
Expand Down
1 change: 1 addition & 0 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ function pluginFusioninventoryUpdate($current_version, $migrationname = 'Migrati
'import_registry' => 1,
'import_process' => 1,
'import_vm' => 1,
'import_monitor_on_partial_sn' => 0,
'component_processor' => 1,
'component_memory' => 1,
'component_harddrive' => 1,
Expand Down

0 comments on commit efdd214

Please sign in to comment.