2011-05-13 Miguel de Dios <miguel.dedios@artica.es>

* operation/agentes/estado_agente.php: fixed ACL when the user have a
	"Pandora Management" in any group that show agents of all groups.
	
	Fixes: #3300611



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4350 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-05-13 09:01:57 +00:00
parent 2b18e2ff02
commit 5de63d0177
2 changed files with 33 additions and 64 deletions

View File

@ -1,3 +1,10 @@
2011-05-13 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/estado_agente.php: fixed ACL when the user have a
"Pandora Management" in any group that show agents of all groups.
Fixes: #3300611
2011-05-13 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2011-05-13 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_servers.php * include/functions_servers.php

View File

@ -248,15 +248,13 @@ if ($group_id > 0) {
$agent_names = agents_get_group_agents ($group_id, $filter, "upper"); $agent_names = agents_get_group_agents ($group_id, $filter, "upper");
} }
else { else {
// Not selected any specific group $groups = array();
if (check_acl ($config['id_user'], 0, "PM")){
$agent_names = agents_get_group_agents(0, $filter, "upper", true); $user_group = users_get_groups($config["id_user"], "PM");
} $groups = array_keys($user_group);
else{ $user_group = users_get_groups($config["id_user"], "AR");
$user_group = users_get_groups($config["id_user"], "AR"); $groups = array_unique(array_merge($groups, array_keys($user_group)));
$groups = array_keys($user_group); $agent_names = agents_get_group_agents($groups, $filter, "upper");
$agent_names = agents_get_group_agents(array_keys ($user_group), $filter, "upper");
}
} }
$total_agents = 0; $total_agents = 0;
@ -267,61 +265,25 @@ if (! empty ($agent_names)) {
$subquery_enterprise = subquery_acl_enterprise(); $subquery_enterprise = subquery_acl_enterprise();
} }
if (check_acl ($config['id_user'], 0, "PM")) { $total_agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s %s', $search_sql, $subquery_enterprise); 'order' => 'nombre ASC',
$total_agents = db_get_sql ($sql); 'disabled' => 0,
'id_grupo' => $groups),
array ('COUNT(*) as total'));
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
switch ($config["dbtype"]) { $agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
case "mysql": 'order' => 'nombre ASC',
case "postgresql": 'id_grupo' => $groups,
$sql = sprintf ('SELECT * FROM tagente 'offset' => (int) get_parameter ('offset'),
WHERE 1=1 %s %s 'limit' => (int) $config['block_size']),
ORDER BY %s %s LIMIT %d, %d', $search_sql, $subquery_enterprise, array ('id_agente',
$order['field'], $order['order'], $offset, $config["block_size"]); 'id_grupo',
break; 'id_os',
case "oracle": 'ultimo_contacto',
$set = array (); 'intervalo'),
$set['limit'] = $config["block_size"]; 'AR',
$set['offset'] = $offset; $order);
$sql = sprintf ('SELECT * FROM tagente
WHERE 1=1 %s %s
ORDER BY %s %s', $search_sql, $subquery_enterprise,
$order['field'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
}
$agents = db_get_all_rows_sql ($sql);
// Delete rnum row generated by oracle_recode_query() function
if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
for ($i=0; $i < count($agents); $i++) {
unset($agents[$i]['rnum']);
}
}
}
else{
$total_agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
'order' => 'nombre ASC',
'disabled' => 0,
'id_grupo' => $groups),
array ('COUNT(*) as total'));
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
$agents = agents_get_agents(array ('id_agente' => array_keys ($agent_names),
'order' => 'nombre ASC',
'id_grupo' => $groups,
'offset' => (int) get_parameter ('offset'),
'limit' => (int) $config['block_size']),
array ('id_agente',
'id_grupo',
'id_os',
'ultimo_contacto',
'intervalo'),
'AR',
$order);
}
} }
if (empty ($agents)) { if (empty ($agents)) {