Merge branch '8-tree-view-metaconsola-con-usuario-ad-no-muestra-hiperlink-nodo' into 'develop'

Fixed problems with access a node with user in metaconsole.

#8

See merge request !17
This commit is contained in:
mlopez 2017-01-13 10:46:40 +01:00
commit 0933ccd5a6
2 changed files with 71 additions and 50 deletions

View File

@ -73,9 +73,6 @@ if (is_ajax ()) {
if (is_metaconsole()) { if (is_metaconsole()) {
$server_id = (int) get_parameter('serverID'); $server_id = (int) get_parameter('serverID');
$server = metaconsole_get_servers($server_id); $server = metaconsole_get_servers($server_id);
if (metaconsole_connect($server) != NOERR)
return;
} }
ob_clean(); ob_clean();
@ -99,10 +96,6 @@ if (is_ajax ()) {
} }
echo '<br></div>'; echo '<br></div>';
if (!empty($server) && is_metaconsole()) {
metaconsole_restore_db();
}
return; return;
} }

View File

@ -39,6 +39,13 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
enterprise_include_once ('meta/include/functions_ui_meta.php'); enterprise_include_once ('meta/include/functions_ui_meta.php');
enterprise_include_once ('meta/include/functions_metaconsole.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; $filter["id_agente_modulo"] = $id_module;
$module = db_get_row_filter ("tagente_modulo", $filter); $module = db_get_row_filter ("tagente_modulo", $filter);
@ -48,13 +55,6 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
return; 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 = new StdClass();
$table->width = "100%"; $table->width = "100%";
$table->class = "databox data"; $table->class = "databox data";
@ -142,7 +142,8 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
foreach ($tags as $k => $v) { foreach ($tags as $k => $v) {
if (!array_key_exists($v, $user_tags)) { //only show user's tags. if (!array_key_exists($v, $user_tags)) { //only show user's tags.
unset($tags[$k]); unset($tags[$k]);
} else { }
else {
$tag_name = tags_get_name($v); $tag_name = tags_get_name($v);
if (empty($tag_name)) { if (empty($tag_name)) {
unset($tags[$k]); unset($tags[$k]);
@ -305,7 +306,7 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
$group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
$agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']); $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 // Actions table
echo '<div style="width:100%; text-align: right; min-width: 300px;">'; echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">'; echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">';
@ -322,6 +323,10 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
html_print_input_text('server_name', $server_name); html_print_input_text('server_name', $server_name);
echo '</div>'; echo '</div>';
if (!empty($server_data) && is_metaconsole()) {
metaconsole_restore_db();
}
return; return;
} }
@ -341,6 +346,13 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head
$url_hash = metaconsole_get_servers_url_hash($server_data); $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_alerts = alerts_get_alerts_agent_module($id_module);
$module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $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); $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); 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 // Actions table
echo '<div style="width:100%; text-align: right; min-width: 300px;">'; echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">'; echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
@ -435,6 +447,12 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head
echo '</a>'; echo '</a>';
echo '</div>'; echo '</div>';
} }
if (!empty($server_data) && is_metaconsole()) {
metaconsole_restore_db();
}
return;
} }
function treeview_printTable($id_agente, $server_data = array(), $no_head = false) { function treeview_printTable($id_agente, $server_data = array(), $no_head = false) {
@ -468,6 +486,15 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
$is_extra = false; $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) { 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", db_pandora_audit("ACL Violation",
"Trying to access Agent General Information"); "Trying to access Agent General Information");
@ -475,8 +502,6 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
return; return;
} }
$agent = db_get_row ("tagente", "id_agente", $id_agente);
if ($agent === false) { if ($agent === false) {
ui_print_error_message(__('There was a problem loading agent')); ui_print_error_message(__('There was a problem loading agent'));
return; return;
@ -498,7 +523,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
$cellName = ''; $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']) { if ($agent['disabled']) {
$cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>"; $cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>";
@ -567,7 +592,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
//End of table //End of table
$agent_table = html_print_table($table, true); $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 = '<div style="text-align: right;">'; $go_to_agent = '<div style="text-align: right;">';
$go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">'; $go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); $go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
@ -749,7 +774,10 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)'); ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)');
} }
return; if (!empty($server_data) && is_metaconsole()) {
metaconsole_restore_db();
} }
return;
}
?> ?>