Merge branch 'ent-8570-Error-SQL-en-wizard-consolas-visuales' into 'develop'

fix module name finish % pandora_enterprise#8570

See merge request artica/pandorafms!4694
This commit is contained in:
Daniel Rodriguez 2022-02-15 10:17:22 +00:00
commit f19387e40a
4 changed files with 36 additions and 47 deletions

View File

@ -31,6 +31,7 @@
global $config;
global $statusProcessInDB;
use PandoraFMS\Agent;
use PandoraFMS\User;
check_login();
@ -630,18 +631,7 @@ switch ($activeTab) {
'message' => $message,
];
} else {
// One item per module
if (empty($name_modules)) {
$statusProcessInDB = [
'flag' => true,
'message' => ui_print_error_message(
__('No modules selected'),
'',
true
),
];
} else {
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$agents_ids = [];
foreach ($id_agents as $id_agent_id) {
$server_and_agent = explode('|', $id_agent_id);
@ -661,13 +651,10 @@ switch ($activeTab) {
} else {
$agents[0] = $id_agents;
}
}
foreach ($agents as $id_server => $id_agents) {
// Any module
if ($name_modules[0] == '0') {
// Any module.
if (empty($name_modules) === true || $name_modules[0] === '0') {
$message .= visual_map_process_wizard_add_agents(
$id_agents,
$image,
@ -705,19 +692,14 @@ switch ($activeTab) {
} else {
foreach ($name_modules as $mod) {
foreach ($id_agents as $ag) {
$id_module = agents_get_modules(
$ag,
['id_agente_modulo'],
['nombre' => $mod]
);
$agent = new Agent($ag);
$id_module = $agent->searchModules(
['nombre' => $mod],
1
)->toArray()['id_agente_modulo'];
if (empty($id_module)) {
if (empty($id_module) === true) {
continue;
} else {
$id_module = reset($id_module);
$id_module = $id_module['id_agente_modulo'];
}
$id_modules[] = $id_module;

View File

@ -533,7 +533,7 @@ echo '</div>';
echo '</form>';
// Trick for it have a traduct text for javascript.
echo '<span id="any_text" class="invisible">'.__('Any').'</span>';
echo '<span id="any_text" class="invisible">'.__('None').'</span>';
echo '<span id="none_text" class="invisible">'.__('None').'</span>';
echo '<span id="loading_text" class="invisible">'.__('Loading...').'</span>';
?>

View File

@ -1430,6 +1430,9 @@ function agents_get_group_agents(
/**
* @deprecated use \PandoraFMS\Agent::searchModules
*
*
* Get all the modules in an agent. If an empty list is passed it will select all
*
* @param mixed Agent id to get modules. It can also be an array of agent id's, by default is null and this mean that use the ids of agents in user's groups.

View File

@ -549,7 +549,8 @@ class Agent extends Entity
* @param array $filter Filters.
* @param integer $limit Limit search results.
*
* @return array Of PandoraFMS\Module Modules found.
* @return array|Module Of PandoraFMS\Module Modules
* found or Module found is limit 1.
*/
public function searchModules(array $filter, int $limit=0)
{
@ -577,7 +578,10 @@ class Agent extends Entity
} else {
// Search in db.
$return = Module::search($filter, $limit);
if (is_array($return) === false) {
if (is_array($return) === false
&& is_object($return) === false
) {
return [];
}