From: Florent Bruneau Date: Sun, 17 Feb 2008 17:48:43 +0000 (+0100) Subject: Ensure we always have a 'current' address (Closes #790) X-Git-Tag: xorg/0.9.16~156 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2db7542dfaefedbe9d86b03d60f73b05667976d6;p=platal.git Ensure we always have a 'current' address (Closes #790) Signed-off-by: Florent Bruneau --- diff --git a/ChangeLog b/ChangeLog index fe122be..410d12d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ Bug/Wish: - #742: Sub domain was hidden when editing profile -FRU - #752: Don't show vcard link on profile when the person is dead -FRU - #764: Fix mentoring edition page -FRU + - #790: Ensure we always have a current address -FRU * Search: - #741: Mentor search in advanced search -FRU diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 4c20bb2..2fe7a8d 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -76,15 +76,19 @@ class ProfileAddress extends ProfileGeoloc } } $current = 0; + $success = true; foreach ($value as $key=>&$adr) { if (@$adr['current']) { $current++; } } - if (!$init && $current != 1 && count($value) > 0) { + if ($current == 0 && count($value) > 0) { + foreach ($value as $key=>&$adr) { + $adr['current'] = true; + break; + } + } else if ($current > 1) { $success = false; - } else { - $success = true; } foreach ($value as $key=>&$adr) { $ls = true;