From: Raphaël Barrois Date: Thu, 21 Oct 2010 19:52:29 +0000 (+0200) Subject: Try to detect real, current location of users in minifiche. X-Git-Tag: xorg/1.0.1~21 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b0ffc8817742b44a6cf0f02cdcd885ea7b154625;p=platal.git Try to detect real, current location of users in minifiche. 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 --- 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; } }