From 647ac2625a20d1e8ca62bcf2ee41cd108d1fd40d Mon Sep 17 00:00:00 2001 From: jsatoh Date: Sun, 8 Apr 2012 12:43:18 +0000 Subject: [PATCH] 2012-04-08 Junichi Satoh * include/db/postgresql.php, include/functions_config.php, godmode/massive/massive_delete_modules.php, godmode/massive/massive_edit_modules.php: Fixed SQL error with PostgreSQL. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5910 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++++ .../massive/massive_delete_modules.php | 28 ++++++++++++++----- .../godmode/massive/massive_edit_modules.php | 28 ++++++++++++++----- pandora_console/include/db/postgresql.php | 4 +-- pandora_console/include/functions_config.php | 2 +- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 047847271c..6a8bb08bf9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-04-08 Junichi Satoh + + * include/db/postgresql.php, include/functions_config.php, + godmode/massive/massive_delete_modules.php, + godmode/massive/massive_edit_modules.php: Fixed SQL error with + PostgreSQL. + 2012-04-08 Junichi Satoh * godmode/admin_access_logs.php: Fixed SQL error with PostgreSQL. diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index c8faa345c9..11466b9b56 100644 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -170,13 +170,27 @@ if ($delete) { $groups = users_get_groups (); $agents = agents_get_group_agents (array_keys (users_get_groups ()), false, "none"); -$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', - array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', - 'id_agente' => array_keys ($agents), - 'disabled' => 0, - 'order' => 'ttipo_modulo.nombre'), - array ('DISTINCT(id_tipo)', - 'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description')); +switch ($config["dbtype"]) { + case "mysql": + case "oracle": + $module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', + array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', + 'id_agente' => array_keys ($agents), + 'disabled' => 0, + 'order' => 'ttipo_modulo.nombre'), + array ('DISTINCT(id_tipo)', + 'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description')); + break; + case "postgresql": + $module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', + array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', + 'id_agente' => array_keys ($agents), + 'disabled' => 0, + 'order' => 'description'), + array ('DISTINCT(id_tipo)', + 'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description')); + break; +} if ($module_types === false) $module_types = array (); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 833146bc00..4428e1b3dd 100644 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -233,13 +233,27 @@ if (! $module_type) { $table->rowstyle['edit7'] = 'display: none'; } $agents = agents_get_group_agents (array_keys (users_get_groups ()), false, "none"); -$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', - array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', - 'id_agente' => array_keys ($agents), - 'disabled' => 0, - 'order' => 'ttipo_modulo.nombre'), - array ('DISTINCT(id_tipo)', - 'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description')); +switch ($config["dbtype"]) { + case "mysql": + case "oracle": + $module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', + array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', + 'id_agente' => array_keys ($agents), + 'disabled' => 0, + 'order' => 'ttipo_modulo.nombre'), + array ('DISTINCT(id_tipo)', + 'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description')); + break; + case "postgresql": + $module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo', + array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo', + 'id_agente' => array_keys ($agents), + 'disabled' => 0, + 'order' => 'description'), + array ('DISTINCT(id_tipo)', + 'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description')); + break; +} if ($module_types === false) $module_types = array (); diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index b68eb6b4ec..af3a4976d9 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -540,7 +540,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p foreach ($values as $field => $value) { if (is_numeric ($field)) { /* User provide the exact operation to do */ - $query .= sprintf ("%s = %d", $field, $value); + $query .= $value; if ($i < $max) { $query .= ' '.$join.' '; @@ -729,7 +729,7 @@ function postgresql_db_get_all_rows_filter ($table, $filter = array(), $fields = $filter = ''; } - $sql = sprintf ('SELECT %s FROM "%s" %s', $fields, $table, $filter); + $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); if ($returnSQL) return $sql; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 40b0a619c3..9c19badeff 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -677,7 +677,7 @@ function config_check (){ $now = date("U"); // First action in order to know if it's a new installation or db maintenance never have been executed - $first_action = db_get_value_filter('utimestamp', 'tsesion', array('1' => '1', 'order' => 'id_sesion ASC')); + $first_action = db_get_value_filter('utimestamp', 'tsesion', array('1 = 1', 'order' => 'id_sesion ASC')); $fresh_installation = $now - $first_action; $resta = $now - $db_maintance;