diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 6a3e7b76..f20d749e 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -15,6 +15,7 @@ Changes after 2.3.3 release (postfixadmin-2.3 branch) - generate more secure random passwords - squirrelmail plugin: fix typo in variable name + - list-domain: fix SELECT query to work with PgSQL even when using custom fields Version 2.3.3 - 2011/03/14 - SVN r1010 (postfixadmin-2.3 branch) --------------------------------------------------------------- diff --git a/list-domain.php b/list-domain.php index 0592548b..7951a2b1 100644 --- a/list-domain.php +++ b/list-domain.php @@ -63,15 +63,21 @@ if ($list_all_domains == 1) { } # fetch domain data and number of mailboxes -# (PgSQL requires the extensive GROUP BY statement, https://sourceforge.net/forum/message.php?msg_id=7386240) +# PgSQL requires the extensive GROUP BY statement (https://sourceforge.net/forum/message.php?msg_id=7386240) +# and also in the field list (https://sourceforge.net/tracker/?func=detail&aid=2859165&group_id=191583&atid=937964) +# Note: future versions should auto-generate the field list based on $struct in DomainHandler (use all fields from the domain table) +$table_domain_fieldlist = " + $table_domain.domain, $table_domain.description, $table_domain.aliases, $table_domain.mailboxes, + $table_domain.maxquota, $table_domain.quota, $table_domain.transport, $table_domain.backupmx, $table_domain.created, + $table_domain.modified, $table_domain.active +"; + $query = " - SELECT $table_domain.* , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count + SELECT $table_domain_fieldlist , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count FROM $table_domain LEFT JOIN $table_mailbox ON $table_domain.domain = $table_mailbox.domain $where - GROUP BY $table_domain.domain, $table_domain.description, $table_domain.aliases, $table_domain.mailboxes, - $table_domain.maxquota, $table_domain.quota, $table_domain.transport, $table_domain.backupmx, $table_domain.created, - $table_domain.modified, $table_domain.active + GROUP BY $table_domain_fieldlist ORDER BY $table_domain.domain "; $result = db_query($query);