#10860 Create function get_agent_module_childs
This commit is contained in:
parent
77ac357745
commit
5cb01d2079
|
@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_categories.php';
|
||||||
require_once $config['homedir'].'/include/graphs/functions_d3.php';
|
require_once $config['homedir'].'/include/graphs/functions_d3.php';
|
||||||
|
|
||||||
use PandoraFMS\Agent;
|
use PandoraFMS\Agent;
|
||||||
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
include_javascript_d3();
|
include_javascript_d3();
|
||||||
|
|
||||||
|
@ -944,6 +945,15 @@ $table_advanced->data['tags_module_parent'][0] .= html_print_div(
|
||||||
|
|
||||||
if ((bool) $in_policies_page === false) {
|
if ((bool) $in_policies_page === false) {
|
||||||
// Cannot select the current module to be itself parent.
|
// Cannot select the current module to be itself parent.
|
||||||
|
if ($id_agent_module !== 0) {
|
||||||
|
$module_parent_filter['tagente_modulo.id_agente_modulo'] = '<>'.$id_agent_module;
|
||||||
|
$array_parent_module_id = [];
|
||||||
|
get_agent_module_childs($array_parent_module_id, $id_agent_module, $id_agente);
|
||||||
|
} else {
|
||||||
|
$module_parent_filter = [];
|
||||||
|
$array_parent_module_id = [];
|
||||||
|
}
|
||||||
|
|
||||||
$module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : [];
|
$module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : [];
|
||||||
$table_advanced->data['caption_tags_module_parent'][1] = __('Module parent');
|
$table_advanced->data['caption_tags_module_parent'][1] = __('Module parent');
|
||||||
// TODO. Review cause dont know not works.
|
// TODO. Review cause dont know not works.
|
||||||
|
@ -959,6 +969,13 @@ if ((bool) $in_policies_page === false) {
|
||||||
false,
|
false,
|
||||||
$module_parent_filter
|
$module_parent_filter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (empty($array_parent_module_id) === false) {
|
||||||
|
foreach ($array_parent_module_id as $key => $value) {
|
||||||
|
unset($modules_can_be_parent[$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the user cannot have access to parent module, only print the name.
|
// If the user cannot have access to parent module, only print the name.
|
||||||
if ((int) $parent_module_id !== 0
|
if ((int) $parent_module_id !== 0
|
||||||
&& in_array($parent_module_id, array_keys($modules_can_be_parent)) === true
|
&& in_array($parent_module_id, array_keys($modules_can_be_parent)) === true
|
||||||
|
|
|
@ -4655,3 +4655,26 @@ function policies_type_modules_availables(string $sec2): array
|
||||||
|
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_agent_module_childs(
|
||||||
|
&$array_parent_module_id=[],
|
||||||
|
$id_agent_module=false,
|
||||||
|
$id_agente=false
|
||||||
|
) {
|
||||||
|
if ($array_parent_module_id !== false && $id_agent_module !== false && $id_agente !== false) {
|
||||||
|
$parent['parent_module_id'] = $id_agent_module;
|
||||||
|
$module_childs_id = agents_get_modules(
|
||||||
|
$id_agente,
|
||||||
|
'parent_module_id',
|
||||||
|
$parent
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($module_childs_id as $key => $value) {
|
||||||
|
if ($value !== 0) {
|
||||||
|
$array_parent_module_id[] = $key;
|
||||||
|
get_agent_module_childs($array_parent_module_id, $key, $id_agente);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue