Kill pink unicorns

This commit is contained in:
m-lopez-f 2017-03-07 16:30:40 +01:00
parent ba423c93d8
commit e5ec0cb35a
3 changed files with 29 additions and 30 deletions

View File

@ -196,7 +196,6 @@ if ($create_agent) {
if($alias_as_name){ if($alias_as_name){
$sql = 'SELECT nombre FROM tagente WHERE nombre = "' . $alias . '"'; $sql = 'SELECT nombre FROM tagente WHERE nombre = "' . $alias . '"';
$exists_alias = db_get_row_sql($sql); $exists_alias = db_get_row_sql($sql);
html_debug_print($exists_alias, true);
$nombre_agente = $alias; $nombre_agente = $alias;
} }

View File

@ -2524,7 +2524,9 @@ function agents_get_agent_custom_field ($agent_id, $custom_field_name) {
return db_get_value_sql($sql); return db_get_value_sql($sql);
} }
function select_modules_for_agent_group($id_group, $id_agents, $selection, $return=true){ function select_modules_for_agent_group($id_group, $id_agents,
$selection, $return = true) {
$agents = implode(",", $id_agents); $agents = implode(",", $id_agents);
$filter_group = ""; $filter_group = "";

View File

@ -490,35 +490,33 @@ if (is_ajax ()) {
asort($result); asort($result);
} }
else { else {
if(implode(',', $idAgents) < 0) {
if(implode(',', $idAgents) < 0){ $sql = 'SELECT DISTINCT(nombre) FROM tagente_modulo
WHERE nombre IN (
SELECT nombre
$sql = 'SELECT DISTINCT(nombre) FROM tagente_modulo FROM tagente_modulo
WHERE nombre IN ( GROUP BY nombre
SELECT nombre HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))';
FROM tagente_modulo }
GROUP BY nombre else {
HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))'; $sql = 'SELECT DISTINCT(nombre)
} FROM tagente_modulo t1
else{ WHERE ' . $filter . '
$sql = 'SELECT DISTINCT(nombre) AND t1.delete_pending = 0
FROM tagente_modulo t1 AND t1.id_agente IN (' . implode(',', $idAgents) . ')';
WHERE ' . $filter . '
AND t1.delete_pending = 0 if ($selection_mode == 'common') {
AND t1.id_agente IN (' . implode(',', $idAgents) . ')'; $sql .= ' AND (
SELECT count(nombre)
if ($selection_mode == 'common') { FROM tagente_modulo t2
$sql .= ' AND ( WHERE t2.delete_pending = 0
SELECT count(nombre) AND t1.nombre = t2.nombre
FROM tagente_modulo t2 AND t2.id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')';
WHERE t2.delete_pending = 0 }
AND t1.nombre = t2.nombre elseif ($selection_mode == 'unknown') {
AND t2.id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')'; $sql .= 'AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = 3 OR estado = 4)';
}elseif ($selection_mode == 'unknown'){ }
$sql .= 'AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = 3 OR estado = 4)';
} }
}
$sql .= ' ORDER BY nombre'; $sql .= ' ORDER BY nombre';
$nameModules = db_get_all_rows_sql($sql); $nameModules = db_get_all_rows_sql($sql);