From b0ffc8817742b44a6cf0f02cdcd885ea7b154625 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 21 Oct 2010 21:52:29 +0200 Subject: [PATCH] Try to detect real, current location of users in minifiche. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Previous behaviour for 'getMainAddress' was to fetch the first among all current/home addresses, even if that address was a secondary / temporary address. Signed-off-by: Raphaël Barrois --- classes/profile.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index 304ca7b..8eb66bb 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -538,11 +538,15 @@ class Profile public function getMainAddress() { - $addr = $this->getAddresses(self::ADDRESS_PERSO | self::ADDRESS_MAIN); - if (count($addr) == 0) { - return null; + $main = $this->getAddresses(self::ADDRESS_MAIN); + $perso = $this->getAddresses(self::ADDRESS_PERSO); + + if (count($main)) { + return array_pop($main); + } else if (count($perso)) { + return array_pop($perso); } else { - return array_pop($addr); + return null; } } -- 2.1.4