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:
mdtrooper 2011-05-06 09:17:40 +00:00
parent 833f927ab6
commit 985fd754fb
3 changed files with 72 additions and 29 deletions

View File

@ -129,6 +129,7 @@ if ($create_agent) {
$cascade_protection = (int) get_parameter_post ("cascade_protection", 0);
$icon_path = (string) get_parameter_post ("icon_path",'');
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();

View File

@ -112,41 +112,77 @@ if ($searchAgents) {
$userGroups = get_user_groups($config['id_user'], 'AR', false);
$id_userGroups = array_keys($userGroups);
$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
switch ($config["dbtype"]) {
case "mysql":
$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'] . "'
)
)
)
AND (
t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'
)
";
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 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";
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
" 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) {
$totalAgents = db_get_row_sql('SELECT COUNT(id_agente) AS agent_count ' . $sql);

View File

@ -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>
* include/functions_visual_map.php,