diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 698ae48eb6..89f2cf3bf7 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -73,9 +73,6 @@ if (is_ajax ()) { if (is_metaconsole()) { $server_id = (int) get_parameter('serverID'); $server = metaconsole_get_servers($server_id); - - if (metaconsole_connect($server) != NOERR) - return; } ob_clean(); @@ -98,11 +95,7 @@ if (is_ajax ()) { } } echo '
'; - - if (!empty($server) && is_metaconsole()) { - metaconsole_restore_db(); - } - + return; } diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index c0db1f33bb..d18d625a00 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -38,7 +38,14 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = enterprise_include_once ('meta/include/functions_modules_meta.php'); enterprise_include_once ('meta/include/functions_ui_meta.php'); enterprise_include_once ('meta/include/functions_metaconsole.php'); - + + $user_access_node = can_user_access_node (); + + if (is_metaconsole()) { + if (metaconsole_connect($server_data) != NOERR) + return; + } + $filter["id_agente_modulo"] = $id_module; $module = db_get_row_filter ("tagente_modulo", $filter); @@ -47,14 +54,7 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = ui_print_error_message(__('There was a problem loading module')); return; } - - /*if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) { - db_pandora_audit("ACL Violation", - "Trying to access Module Information"); - require_once ("general/noaccess.php"); - return; - }*/ - + $table = new StdClass(); $table->width = "100%"; $table->class = "databox data"; @@ -68,24 +68,24 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = $table->head_colspan[] = 2; $table->data = array(); - + //Module name if ($module["disabled"]) $cellName = "" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; else $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); - + $row = array(); $row['title'] = __('Name'); $row['data'] = "".$cellName.""; $table->data['name'] = $row; - + // Interval $row = array(); $row['title'] = __('Interval'); $row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true); $table->data['interval'] = $row; - + // Warning Min/Max if (modules_is_string_type($module['id_tipo_modulo'])) { $warning_status_str = __('Str.') . ': ' . $module['str_warning']; @@ -93,12 +93,12 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = else { $warning_status_str = __('Min.') . ': ' . (float)$module['min_warning'] . '
' . __('Max.') . ': ' . (float)$module['max_warning']; } - + $row = array(); $row['title'] = __('Warning status'); $row['data'] = $warning_status_str; $table->data['watning_status'] = $row; - + // Critical Min/Max if (modules_is_string_type($module['id_tipo_modulo'])) { $critical_status_str = __('Str.') . ': ' . $module['str_warning']; @@ -110,7 +110,7 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = $row['title'] = __('Critical status'); $row['data'] = $critical_status_str; $table->data['critical_status'] = $row; - + // Module group $module_group = modules_get_modulegroup_name($module['id_module_group']); @@ -118,31 +118,32 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = $module_group = __('Not assigned'); else $module_group = __("$module_group"); - + $row = array(); $row['title'] = __('Module group'); $row['data'] = $module_group; $table->data['module_group'] = $row; - + // Description $row = array(); $row['title'] = __('Description'); $row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]'); $table->data['description'] = $row; - + // Tags $tags = tags_get_module_tags($module['id_agente_modulo']); if (empty($tags)) { $tags = array(); } - + $user_tags = tags_get_user_tags($config["id_user"]); - + foreach ($tags as $k => $v) { if (!array_key_exists($v, $user_tags)) { //only show user's tags. unset($tags[$k]); - } else { + } + else { $tag_name = tags_get_name($v); if (empty($tag_name)) { unset($tags[$k]); @@ -152,19 +153,19 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = } } } - + if (empty($tags)) { $tags = '' . __('N/A') . ''; } else { $tags = implode(', ' , $tags); } - + $row = array(); $row['title'] = __('Tags'); $row['data'] = $tags; $table->data['tags'] = $row; - + // Data $last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC'))); if ($config["render_proc"]) { @@ -292,20 +293,20 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = else { $last_data_str = '' . __('No data') . ''; } - + $row = array(); $row['title'] = __('Last data'); $row['data'] = $last_data_str; $table->data['last_data'] = $row; - + //End of table html_print_table($table); - + $id_group = agents_get_agent_group($module['id_agente']); $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); $agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']); - - if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) { + + if ($user_access_node && check_acl ($config["id_user"], $id_group, 'AW')) { // Actions table echo '
'; echo ''; @@ -314,14 +315,18 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = echo '
'; } - + //id_module and id_agent hidden echo ''; - + + if (!empty($server_data) && is_metaconsole()) { + metaconsole_restore_db(); + } + return; } @@ -340,7 +345,14 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head $console_url = $server_data['server_url'] . '/'; $url_hash = metaconsole_get_servers_url_hash($server_data); } - + + $user_access_node = can_user_access_node (); + + if (is_metaconsole()) { + if (metaconsole_connect($server_data) != NOERR) + return; + } + $module_alerts = alerts_get_alerts_agent_module($id_module); $module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module); $agent_id = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_module); @@ -427,7 +439,7 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head } html_print_table($table2); - if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) { + if ($user_access_node && check_acl ($config["id_user"], $id_group, 'LW')) { // Actions table echo '
'; echo ''; @@ -435,6 +447,12 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head echo ''; echo '
'; } + + if (!empty($server_data) && is_metaconsole()) { + metaconsole_restore_db(); + } + + return; } function treeview_printTable($id_agente, $server_data = array(), $no_head = false) { @@ -467,16 +485,23 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals if ($is_extra === ENTERPRISE_NOT_HOOK) { $is_extra = false; } + + $user_access_node = can_user_access_node (); + + if (is_metaconsole()) { + if (metaconsole_connect($server_data) != NOERR) + return; + } + $agent = db_get_row ("tagente", "id_agente", $id_agente); + if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR") && ! check_acl ($config["id_user"], $agent["id_grupo"], "AW") && !$is_extra) { db_pandora_audit("ACL Violation", "Trying to access Agent General Information"); require_once ("general/noaccess.php"); return; } - - $agent = db_get_row ("tagente", "id_agente", $id_agente); - + if ($agent === false) { ui_print_error_message(__('There was a problem loading agent')); return; @@ -498,7 +523,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals $cellName = ''; } - $cellName .= ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true, $console_url, $url_hash, false, can_user_access_node ()); + $cellName .= ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true, $console_url, $url_hash, false, $user_access_node); if ($agent['disabled']) { $cellName .= ui_print_help_tip(__('Disabled'), true) . "
"; @@ -567,7 +592,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals //End of table $agent_table = html_print_table($table, true); - if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { + if ( $user_access_node && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { $go_to_agent = '
'; $go_to_agent .= ''; $go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); @@ -748,8 +773,11 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)'); } - + + if (!empty($server_data) && is_metaconsole()) { + metaconsole_restore_db(); + } + return; } - -?> +?> \ No newline at end of file