From 9860732a5b6de1cdf71e1f55a1f5773ce95fa67b Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 27 Oct 2011 14:24:36 +0200 Subject: [PATCH] Retrieves postal addresses in the following order among mail addresses: current, primary, job, secondary. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/userset.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/userset.inc.php b/include/userset.inc.php index ca097b3..5d1e9d2 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -432,13 +432,15 @@ class AddressesView implements PlView if (!empty($pids)) { $res = XDB::query("SELECT pd.promo, p.title, pd.short_name, UPPER(pje.name), pa.postalText, p.email_directory - FROM profile_addresses AS pa + FROM (SELECT pid, postalText + FROM profile_addresses + WHERE pub IN ('public', 'ax') AND FIND_IN_SET('mail', flags) AND pid IN {?} + ORDER BY pid, NOT FIND_IN_SET('current', flags), + FIND_IN_SET('secondary', flags), type = 'job') AS pa INNER JOIN profiles AS p ON (pa.pid = p.pid) INNER JOIN profile_display AS pd ON (pd.pid = pa.pid) LEFT JOIN profile_job AS pj ON (pj.pid = pa.pid) LEFT JOIN profile_job_enum AS pje ON (pj.jobid = pje.id) - WHERE pa.type = 'home' AND pa.pub IN ('public', 'ax') AND FIND_IN_SET('mail', pa.flags) - AND pa.pid IN {?} GROUP BY pa.pid", $pids); foreach ($res->fetchAllAssoc() as $item) { fputcsv($csv, array_map('utf8_decode', $item), ';'); -- 2.1.4