Skip to content

Commit

Permalink
Uses isAgentCanDo() to filter agents with module enabled
Browse files Browse the repository at this point in the history
Please see PR glpi-project#627
  • Loading branch information
eduardomozart authored Jan 31, 2025
1 parent 7d03c7d commit 85c0ade
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions inc/taskjobview.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,6 @@ public function ajaxModuleItemsDropdown($options)
// remove install suffix from deploy
$modulename = str_replace('DEPLOYINSTALL', 'DEPLOY', strtoupper($method));

switch (strtoupper($modulename)) {
case "INVENTORYCOMPUTERESX":
$moduleactive = "agents.use_module_esx_remote_inventory";
break;
case "NETWORKDISCOVERY":
$moduleactive = "agents.use_module_network_discovery";
break;
case "NETWORKINVENTORY":
$moduleactive = "agents.use_module_network_inventory";
break;
case "DEPLOY":
$moduleactive = "agents.use_module_package_deployment";
break;
case "COLLECT":
$moduleactive = "agents.use_module_collect_data";
break;
}

// prepare a query to retrieve agent's & computer's id
$crit = [
'SELECT' => [
Expand Down Expand Up @@ -483,11 +465,6 @@ public function ajaxModuleItemsDropdown($options)
]
];

if (isset($moduleactive)) {
array_push($crit['SELECT'], $moduleactive);
$crit['WHERE'] += [ $moduleactive => 1 ];
}

$item = getItemForItemtype($itemtype);
if ($item->isEntityAssign()) {
// get entity ID from task ID
Expand All @@ -509,7 +486,10 @@ public function ajaxModuleItemsDropdown($options)
if ($itemtype == 'Computer') {
$filter_id[] = $data_filter['items_id'];
} else {
$filter_id[] = $data_filter['agents_id'];
$pfAgentModule = new PluginGlpiinventoryAgentmodule();
if ($pfAgentModule->isAgentCanDo($modulename, $data_filter['agents_id'])) {
$filter_id[] = $data_filter['agents_id'];
}
}
}

Expand Down

0 comments on commit 85c0ade

Please sign in to comment.