diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c8c56832d2..35ff699fd9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,7 @@ +2012-04-16 Vanessa Gil + + * extensions/tree.php: Added policy tab. + 2012-04-16 Vanessa Gil * extensions/tree.php diff --git a/pandora_console/extensions/tree.php b/pandora_console/extensions/tree.php index c3b7d754d6..48c3a3bca6 100644 --- a/pandora_console/extensions/tree.php +++ b/pandora_console/extensions/tree.php @@ -225,10 +225,15 @@ if (is_ajax ()) require_once ('include/functions_reporting.php'); require_once ('include/functions_users.php'); require_once ('include/functions_servers.php'); - require_once ('enterprise/include/functions_policies.php'); global $config; + $enterpriseEnable = false; + if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { + $enterpriseEnable = true; + require_once ('enterprise/include/functions_policies.php'); + } + $type = get_parameter('type'); $id = get_parameter('id'); $id_father = get_parameter('id_father'); @@ -263,7 +268,7 @@ if (is_ajax ()) $countRows = 0; if (!empty($avariableGroupsIds)) { - $extra_sql = policies_get_agents_sql_condition(); + $extra_sql = enterprise_hook('policies_get_agents_sql_condition'); if($extra_sql != '') { $extra_sql .= ' OR'; } @@ -294,10 +299,10 @@ if (is_ajax ()) if ($id == 0) $queryWhere = 'id_agente NOT IN (SELECT id_agent FROM tpolicy_agents)'; else - $queryWhere = sprintf('id_agente IN (SELECT id_agent FROM tpolicy_agents WHERE id_policy = %s)',$id); + $queryWhere = sprintf(' id_agente IN (SELECT id_agent FROM tpolicy_agents WHERE id_policy = %s)',$id); $sql = sprintf('SELECT * FROM tagente - WHERE %s (%s id_grupo IN (%s))', $queryWhere, $extra_sql, $groups_sql); + WHERE %s AND ( %s id_grupo IN (%s))', $queryWhere, $extra_sql, $groups_sql); break; case 'module': //Replace separator token "articapandora_32_pandoraartica_" for " " @@ -351,6 +356,13 @@ if (is_ajax ()) case 'module_group': $agent_info = reporting_get_agent_module_info ($row["id_agente"], ' id_module_group = ' . $id); break; + case 'policies': + $whereQuery = ''; + if ($id_father != 0) + $whereQuery = ' id_modulo IN + (SELECT id_module FROM tpolicy_modules WHERE id_policy = ' . $id_father . ')'; + $agent_info = reporting_get_agent_module_info ($row["id_agente"], $whereQuery); + break; case 'module': switch ($config["dbtype"]) { case "mysql": @@ -634,6 +646,7 @@ if (is_ajax ()) include_once($config['homedir'] . "/include/functions_groups.php"); include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_reporting.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); function printTree_($type) { @@ -698,7 +711,22 @@ function printTree_($type) { array_push($list, array('id_mg' => 0, 'name' => 'Not assigned')); } break; - + case 'policies': + if ($search_free != '') { + $groups_id = array_keys($avariableGroups); + $groups = implode(',',$groups_id); + $sql = "SELECT * FROM tpolicies + WHERE id_group IN ($groups) + AND id IN (SELECT id_policy FROM tpolicy_agents + WHERE id_agent IN (SELECT id_agente FROM tagente + WHERE nombre LIKE '%$search_free%'))"; + $list = db_get_all_rows_sql($sql); + } else { + $list = db_get_all_rows_filter('tpolicies', array('id_group' => array_keys($avariableGroups))); + if ($list !== false) + array_push($list, array('id' => 0, 'name' => 'No policy')); + } + break; case 'module': if ($search_free != '') { $sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente @@ -725,7 +753,8 @@ function printTree_($type) { } if ($list === false) { - echo __("

There aren't agents in this agrupation.

"); + ui_print_error_message("There aren't agents in this agrupation"); + } else { echo "