diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4fb9bb77a8..0b98322df8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-05-17 Juan Manuel Ramon + + * include/graphs/fgraph.php + include/config_process.php + include/functions_agents.php + operation/agentes/status_monitor.php + operation/agentes/estado_agente.php: Several corrections + over sql queries for Oracle DBMS. + * godmode/db/db_info.php: Added include to + functions_fsgraph.php + 2011-05-17 Juan Manuel Ramon * include/graphs/fgraph.php diff --git a/pandora_console/godmode/db/db_info.php b/pandora_console/godmode/db/db_info.php index d7bfe6e2f7..f3c5ccd364 100644 --- a/pandora_console/godmode/db/db_info.php +++ b/pandora_console/godmode/db/db_info.php @@ -21,6 +21,7 @@ global $config; require_once ($config["homedir"] . '/include/functions_graph.php'); require_once($config['homedir'] . "/include/functions_agents.php"); require_once($config['homedir'] . "/include/functions_modules.php"); +require_once($config['homedir'] . "/include/functions_fsgraph.php"); ui_print_page_header (__('Database maintenance').' » '.__('Database information'), "images/god8.png", false, "", true); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 24de41bc39..3e9be02bd4 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -152,7 +152,22 @@ if (isset($config['history_db_enabled'])) { // Make dbconnection the default connection again (the link identifier of the already opened link will be returned) db_connect(); -require_once("include/fgraph.php"); + +function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) { + global $ttl; + global $homeurl; + + $ttl = $serialize_ttl; + $homeurl = $home_url; + + include_once($homeurl . 'include/functions.php'); + include_once($homeurl . 'include/functions_html.php'); + + include_once($homeurl . 'include/graphs/functions_fsgraph.php'); + include_once($homeurl . 'include/graphs/functions_gd.php'); + include_once($homeurl . 'include/graphs/functions_utils.php'); +} +//require_once("include/fgraph.php"); include_graphs_dependencies(); ?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 578e331d4f..694a1c52a0 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -803,7 +803,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower $search_sql .= ' AND nombre COLLATE utf8_general_ci LIKE \'' . $name . '\' '; break; case "oracle": - $search_sql .= ' AND nombre LIKE UPPER("' . $name . '") '; + $search_sql .= ' AND UPPER(nombre) LIKE UPPER(\'' . $name . '\') '; break; } @@ -958,13 +958,29 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false } if ($value[0] == '%') { - array_push ($fields, $field.' LIKE "'.$value.'"'); + switch ($config['dbtype']){ + case "mysql": + case "postgresql": + array_push ($fields, $field.' LIKE "'.$value.'"'); + break; + case "oracle": + array_push ($fields, $field.' LIKE \''.$value.'\''); + break; + } } else if ($operatorDistin) { array_push($fields, $field.' <> ' . substr($value, 2)); } else if (substr($value, -1) == '%') { - array_push ($fields, $field.' LIKE "'.$value.'"'); + switch ($config['dbtype']){ + case "mysql": + case "postgresql": + array_push ($fields, $field.' LIKE "'.$value.'"'); + break; + case "oracle": + array_push ($fields, $field.' LIKE \''.$value.'\''); + break; + } } else { switch ($config["dbtype"]) { diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 7aaebc324f..197953319c 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -13,7 +13,7 @@ $ttl = 1; $homeurl = ''; -function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) { +/*function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) { global $ttl; global $homeurl; @@ -26,7 +26,7 @@ function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) { include_once($homeurl . 'include/graphs/functions_fsgraph.php'); include_once($homeurl . 'include/graphs/functions_gd.php'); include_once($homeurl . 'include/graphs/functions_utils.php'); -} +}*/ /* // If is called from index if(file_exists('include/functions.php')) { diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 0903f5a5ad..da091e4501 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -60,6 +60,15 @@ if (is_ajax ()) { ORDER BY sort_order DESC", $id_template, $filter_groups); break; case "oracle": + $sql = sprintf ("SELECT t1.id, t1.name, + (SELECT COUNT(t2.id) + FROM talert_templates t2 + WHERE t2.id = %d + AND t2.id_alert_action = t1.id) as sort_order + FROM talert_actions t1 + WHERE id_group IN (%s) + ORDER BY sort_order DESC", $id_template, $filter_groups); + break; case "postgresql": $sql = sprintf ("SELECT t1.id, t1.name, (SELECT COUNT(t2.id) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index a796d757f7..5de8d6eeb4 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -129,44 +129,46 @@ switch ($config["dbtype"]) { $sql .= ')'; break; case "oracle": - //TODO PENDING TO OPTIMIZE - $names = oracle_db_get_all_rows_filter ('user_tab_columns',array ('table_name' => 'TAGENTE_MODULO', 'column_name' => '<>NOMBRE'), 'column_name'); - $column_names = ''; - foreach ($names as $column_name => $value) { - $column_names .= $value['column_name'] . ','; - } + $profiles = db_get_all_rows_sql('SELECT id_grupo + FROM tusuario_perfil t1 + INNER JOIN tperfil t2 ON t1.id_perfil = t2.id_perfil + WHERE t2.agent_view = 1 AND t1.id_usuario = \'' . $config['id_user'] . '\';'); + if ($profiles === false) + $profiles = array(); - $column_names = substr($column_names,0,-1); - $sql = ' - select nombre - from (select distinct dbms_lob.substr(nombre,4000,1) as nombre, ' . $column_names .' from tagente_modulo) - where nombre <> \'delete_pending\' ' . $subquery_enterprise . ' AND id_agente in + $id_groups = array(); + $flag_all_group = false; + foreach ($profiles as $profile) { + if ($profile['id_grupo'] == 0) { + $flag_all_group = true; + } + $id_groups[] = $profile['id_grupo']; + } + + //The check of is_admin + $flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); + + $sql = ' SELECT distinct dbms_lob.substr(nombre,4000,1) as nombre + FROM tagente_modulo + WHERE dbms_lob.substr(nombre,4000,1) <> \'delete_pending\' ' . $subquery_enterprise . ' AND id_agente IN ( - select id_agente - from tagente where id_grupo IN ( - select id_grupo - from tusuario_perfil - where id_usuario = \'' . $config['id_user'] . '\' - and id_perfil IN ( - select id_perfil - from tperfil where agent_view = 1 - ) - ) - OR - (1 = ( - SELECT is_admin FROM tusuario WHERE id_user = \'' . $config['id_user'] . '\' - ) - ) - OR 0 IN ( - select id_grupo - from tusuario_perfil - where id_usuario = \'' . $config['id_user'] . '\' - and id_perfil IN ( - select id_perfil - from tperfil where agent_view = 1 - ) - ) - )'; + SELECT id_agente + FROM tagente + WHERE'; + + if ($flag_is_admin || $flag_all_group) { + $sql .= ' 1 = 1 '; + } + else { + if (empty($id_groups)) { + $sql .= ' 1 = 0 '; + } + else { + $sql .= ' id_grupo IN (' . implode(',', $id_groups) . ') '; + } + } + + $sql .= ')'; break; }