2012-02-13 Miguel de Dios <miguel.dedios@artica.es>

* 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.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5568 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-02-13 12:54:41 +00:00
parent 71adb8aa2c
commit dc37bda382
4 changed files with 35 additions and 37 deletions

View File

@ -1,3 +1,11 @@
2012-02-13 Miguel de Dios <miguel.dedios@artica.es>
* 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 <juanmanuel.ramon@artica.es> 2012-02-13 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_graph.php: Module event graph resized. * include/functions_graph.php: Module event graph resized.
@ -37,7 +45,7 @@
2012-02-10 Miguel de Dios <miguel.dedios@artica.es> 2012-02-10 Miguel de Dios <miguel.dedios@artica.es>
* * extensions/module_groups.php, include/functions_modules.php, * extensions/module_groups.php, include/functions_modules.php,
godmode/agentes/module_manager_editor_prediction.php: cleaned godmode/agentes/module_manager_editor_prediction.php: cleaned
source code style. source code style.

View File

@ -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) { function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) {
global $config; global $config;
$policy_sql = '';
if ($id_agent === null) { if ($id_agent === null) {
//Extract the agents of group user. //Extract the agents of group user.
$groups = users_get_groups(false, 'AR', false); $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']; $temp[] = $item['id_agente'];
} }
$id_agent = $temp; $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)) { if (!is_array($id_agent)) {
$id_agent = safe_int ($id_agent, 1); $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); $userGroups = users_get_groups($config['id_user'], 'AR', false);
if(empty($userGroups)) { if(empty($userGroups)) {

View File

@ -155,9 +155,10 @@ switch ($config["dbtype"]) {
// Get the enterprise acl sql condition // Get the enterprise acl sql condition
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente)); $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 = ''; $extra_sql = '';
}else if ($extra_sql != '') { }
else if ($extra_sql != '') {
$extra_sql = "(($extra_sql) OR id_policy_module = 0) AND"; $extra_sql = "(($extra_sql) OR id_policy_module = 0) AND";
} }
@ -165,18 +166,6 @@ if($extra_sql == ENTERPRISE_NOT_HOOK) {
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
case "postgresql": 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(" $sql = sprintf("
SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = 0 AND disabled = 0) tagente_modulo 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 LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg

View File

@ -326,7 +326,7 @@ if (is_ajax ()) {
AND talert_template_modules.times_fired > 0 ', AND talert_template_modules.times_fired > 0 ',
$id_agent); $id_agent);
$alert_modules = db_get_sql ($sql); $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 $sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
FROM talert_template_modules, tagente_modulo, tagente FROM talert_template_modules, tagente_modulo, tagente
WHERE tagente.id_agente = %d WHERE tagente.id_agente = %d
@ -414,7 +414,7 @@ if (is_ajax ()) {
if($groups_sons === false){ if($groups_sons === false){
echo __('None').'<br />'; echo __('None').'<br />';
} }
else{ else {
echo '<br /><br />'; echo '<br /><br />';
foreach($groups_sons as $group_son) { foreach($groups_sons as $group_son) {
echo html_print_image("images/groups_small/" . groups_get_icon ($group_son['id_grupo']) . ".png", true); echo html_print_image("images/groups_small/" . groups_get_icon ($group_son['id_grupo']) . ".png", true);
@ -425,11 +425,11 @@ if (is_ajax ()) {
return; return;
} }
if ($get_agent_id){ if ($get_agent_id) {
$agent_name = (string) get_parameter ("agent_name"); $agent_name = (string) get_parameter ("agent_name");
echo agents_get_agent_id ($agent_name); echo agents_get_agent_id ($agent_name);
return; return;
} }
return; return;
@ -446,7 +446,7 @@ $id_grupo = $agent['id_grupo'];
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); $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; $is_extra = false;
} }
@ -468,7 +468,7 @@ if ($flag !== '') {
} }
// Check for Network FLAG change request // Check for Network FLAG change request
$flag_agent = get_parameter('flag_agent',''); $flag_agent = get_parameter('flag_agent','');
if ($flag_agent !== ''){ if ($flag_agent !== '') {
if ($flag_agent == 1 && check_acl ($config['id_user'], $id_grupo, "AW")) { 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)); db_process_sql_update('tagente_modulo', array('flag' => 1), array('id_agente' =>$id_agente));
} }