From c4dfb79175e39af33cf454f7dc3becf20a00a611 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 29 Apr 2010 06:21:16 +0000 Subject: [PATCH] "Fix for PostgreSQL error, when ordering by a custom field (reported on the developer list)" --- addressbook/inc/class.addressbook_sql.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index a4f43d2c50..3b89043773 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -323,8 +323,9 @@ class addressbook_sql extends so_sql_cf if ($this->db->Type != 'mysql' && preg_match("/([a-zA-Z_.]+)<>''/",$order_by,$matches)) { if (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); - $extra_cols[] = $matches[1]; - $extra_cols[] = $matches[1]."<>''"; + $table = $matches[1] == $this->extra_value ? $this->extra_table : $this->table_name; + $extra_cols[] = $table.'.'.$matches[1]; + $extra_cols[] = $table.'.'.$matches[1]."<>''"; } } // add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)