diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f3500e9fae..8658411b89 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2012-02-13 Miguel de Dios + + * operation/agentes/estado_monitores.php, operation/agentes/ver_agente.php: + cleaned source code style. + + * include/functions_agents.php: refixed the query to extract modules for the + ACL policies. + 2012-02-13 Juan Manuel Ramon * include/functions_graph.php: Module event graph resized. @@ -37,7 +45,7 @@ 2012-02-10 Miguel de Dios - * * extensions/module_groups.php, include/functions_modules.php, + * extensions/module_groups.php, include/functions_modules.php, godmode/agentes/module_manager_editor_prediction.php: cleaned source code style. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 41bacd992b..2e5ace2b9a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1043,6 +1043,8 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) { global $config; + $policy_sql = ''; + if ($id_agent === null) { //Extract the agents of group user. $groups = users_get_groups(false, 'AR', false); @@ -1064,24 +1066,23 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false $temp[] = $item['id_agente']; } $id_agent = $temp; + + if (!empty($id_agent)) { + $extra_policy_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agent)); + if ($policy_sql === ENTERPRISE_NOT_HOOK) { + $policy_sql = ''; + } + else if ($policy_sql != '') { + //It is AND instead OR, because It is necesary apply the filter. + $policy_sql = ' OR ' . $policy_sql; + } + } } if (!is_array($id_agent)) { $id_agent = safe_int ($id_agent, 1); } - - $policy_sql = ''; - if ($id_agent != 0){ - $extra_policy_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agent)); - if ($policy_sql === ENTERPRISE_NOT_HOOK) { - $policy_sql = ''; - } - else if ($policy_sql != '') { - //It is AND instead OR, because It is necesary apply the filter. - $policy_sql = ' OR ' . $policy_sql; - } - } - + $userGroups = users_get_groups($config['id_user'], 'AR', false); if(empty($userGroups)) { diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 56182eab41..a6578299e3 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -155,9 +155,10 @@ switch ($config["dbtype"]) { // Get the enterprise acl sql condition $extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente)); -if($extra_sql == ENTERPRISE_NOT_HOOK) { +if ($extra_sql == ENTERPRISE_NOT_HOOK) { $extra_sql = ''; -}else if ($extra_sql != '') { +} +else if ($extra_sql != '') { $extra_sql = "(($extra_sql) OR id_policy_module = 0) AND"; } @@ -165,18 +166,6 @@ if($extra_sql == ENTERPRISE_NOT_HOOK) { switch ($config["dbtype"]) { case "mysql": case "postgresql": - /* $sql = sprintf (" - SELECT * - FROM tagente_estado, tagente_modulo - LEFT JOIN tmodule_group - ON tagente_modulo.id_module_group = tmodule_group.id_mg - WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.id_agente = %d - AND tagente_modulo.disabled = 0 - AND tagente_modulo.delete_pending = 0 - AND tagente_estado.utimestamp != 0 - ORDER BY tagente_modulo.id_module_group , %s %s - ", $id_agente, $order['field'], $order['order']); */ $sql = sprintf(" SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = 0 AND disabled = 0) tagente_modulo LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 47f2f95a2b..0f195f0006 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -326,7 +326,7 @@ if (is_ajax ()) { AND talert_template_modules.times_fired > 0 ', $id_agent); $alert_modules = db_get_sql ($sql); - if ($alert_modules > 0){ + if ($alert_modules > 0) { $sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired FROM talert_template_modules, tagente_modulo, tagente WHERE tagente.id_agente = %d @@ -414,7 +414,7 @@ if (is_ajax ()) { if($groups_sons === false){ echo __('None').'
'; } - else{ + else { echo '

'; foreach($groups_sons as $group_son) { echo html_print_image("images/groups_small/" . groups_get_icon ($group_son['id_grupo']) . ".png", true); @@ -425,11 +425,11 @@ if (is_ajax ()) { return; } - if ($get_agent_id){ - $agent_name = (string) get_parameter ("agent_name"); - - echo agents_get_agent_id ($agent_name); - return; + if ($get_agent_id) { + $agent_name = (string) get_parameter ("agent_name"); + + echo agents_get_agent_id ($agent_name); + return; } return; @@ -446,7 +446,7 @@ $id_grupo = $agent['id_grupo']; $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); -if($is_extra === ENTERPRISE_NOT_HOOK) { +if ($is_extra === ENTERPRISE_NOT_HOOK) { $is_extra = false; } @@ -468,7 +468,7 @@ if ($flag !== '') { } // Check for Network FLAG change request $flag_agent = get_parameter('flag_agent',''); -if ($flag_agent !== ''){ +if ($flag_agent !== '') { if ($flag_agent == 1 && check_acl ($config['id_user'], $id_grupo, "AW")) { db_process_sql_update('tagente_modulo', array('flag' => 1), array('id_agente' =>$id_agente)); }