2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* operation/search_agents.php: changed the SQL query for PostgreSQL. * godmode/agentes/configurar_agente.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4313 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
833f927ab6
commit
985fd754fb
|
@ -129,6 +129,7 @@ if ($create_agent) {
|
||||||
$cascade_protection = (int) get_parameter_post ("cascade_protection", 0);
|
$cascade_protection = (int) get_parameter_post ("cascade_protection", 0);
|
||||||
$icon_path = (string) get_parameter_post ("icon_path",'');
|
$icon_path = (string) get_parameter_post ("icon_path",'');
|
||||||
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
|
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
|
||||||
|
|
||||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||||
|
|
||||||
if($fields === false) $fields = array();
|
if($fields === false) $fields = array();
|
||||||
|
|
|
@ -112,41 +112,77 @@ if ($searchAgents) {
|
||||||
$userGroups = get_user_groups($config['id_user'], 'AR', false);
|
$userGroups = get_user_groups($config['id_user'], 'AR', false);
|
||||||
$id_userGroups = array_keys($userGroups);
|
$id_userGroups = array_keys($userGroups);
|
||||||
|
|
||||||
$sql = "
|
switch ($config["dbtype"]) {
|
||||||
FROM tagente AS t1
|
case "mysql":
|
||||||
INNER JOIN tgrupo AS t2
|
$sql = "
|
||||||
ON t2.id_grupo = t1.id_grupo
|
FROM tagente AS t1
|
||||||
WHERE (
|
INNER JOIN tgrupo AS t2
|
||||||
1 = (
|
ON t2.id_grupo = t1.id_grupo
|
||||||
SELECT is_admin
|
WHERE (
|
||||||
FROM tusuario
|
1 = (
|
||||||
WHERE id_user = '" . $config['id_user'] . "'
|
SELECT is_admin
|
||||||
)
|
FROM tusuario
|
||||||
OR t1.id_grupo IN (
|
WHERE id_user = '" . $config['id_user'] . "'
|
||||||
" . implode(',', $id_userGroups) . "
|
|
||||||
)
|
|
||||||
OR 0 IN (
|
|
||||||
SELECT id_grupo
|
|
||||||
FROM tusuario_perfil
|
|
||||||
WHERE id_usuario = '" . $config['id_user'] . "'
|
|
||||||
AND id_perfil IN (
|
|
||||||
SELECT id_perfil
|
|
||||||
FROM tperfil WHERE agent_view = 1
|
|
||||||
)
|
)
|
||||||
)
|
OR t1.id_grupo IN (
|
||||||
)
|
" . implode(',', $id_userGroups) . "
|
||||||
AND (
|
)
|
||||||
t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
OR 0 IN (
|
||||||
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'
|
SELECT id_grupo
|
||||||
)
|
FROM tusuario_perfil
|
||||||
";
|
WHERE id_usuario = '" . $config['id_user'] . "'
|
||||||
|
AND id_perfil IN (
|
||||||
|
SELECT id_perfil
|
||||||
|
FROM tperfil WHERE agent_view = 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
AND (
|
||||||
|
t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'
|
||||||
|
)
|
||||||
|
";
|
||||||
|
break;
|
||||||
|
case "postgresql":
|
||||||
|
case "oracle":
|
||||||
|
$sql = "
|
||||||
|
FROM tagente AS t1
|
||||||
|
INNER JOIN tgrupo AS t2
|
||||||
|
ON t2.id_grupo = t1.id_grupo
|
||||||
|
WHERE (
|
||||||
|
1 = (
|
||||||
|
SELECT is_admin
|
||||||
|
FROM tusuario
|
||||||
|
WHERE id_user = '" . $config['id_user'] . "'
|
||||||
|
)
|
||||||
|
OR t1.id_grupo IN (
|
||||||
|
" . implode(',', $id_userGroups) . "
|
||||||
|
)
|
||||||
|
OR 0 IN (
|
||||||
|
SELECT id_grupo
|
||||||
|
FROM tusuario_perfil
|
||||||
|
WHERE id_usuario = '" . $config['id_user'] . "'
|
||||||
|
AND id_perfil IN (
|
||||||
|
SELECT id_perfil
|
||||||
|
FROM tperfil WHERE agent_view = 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
AND (
|
||||||
|
t1.nombre LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t2.nombre LIKE '%%" . $stringSearchSQL . "%%'
|
||||||
|
)
|
||||||
|
";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled";
|
$select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled";
|
||||||
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
|
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
|
||||||
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
|
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
|
||||||
|
|
||||||
$agents = db_process_sql($select . $sql . $limit);
|
$query = $select . $sql . $limit;
|
||||||
|
|
||||||
|
$agents = db_process_sql($query);
|
||||||
|
|
||||||
if($agents !== false) {
|
if($agents !== false) {
|
||||||
$totalAgents = db_get_row_sql('SELECT COUNT(id_agente) AS agent_count ' . $sql);
|
$totalAgents = db_get_row_sql('SELECT COUNT(id_agente) AS agent_count ' . $sql);
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* operation/search_agents.php: changed the SQL query for PostgreSQL.
|
||||||
|
|
||||||
|
* godmode/agentes/configurar_agente.php: cleaned source code style.
|
||||||
|
|
||||||
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
|
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_visual_map.php,
|
* include/functions_visual_map.php,
|
||||||
|
|
Loading…
Reference in New Issue