Fix address<->phone association on profile.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 14 Oct 2010 11:57:01 +0000 (13:57 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 14 Oct 2010 11:57:01 +0000 (13:57 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/profilefields.inc.php

index e841c16..cc8b73b 100644 (file)
@@ -539,8 +539,13 @@ class ProfileAddresses extends ProfileField
     {
         $p = $phones->get(Profile::PHONE_LINK_ADDRESS | Profile::PHONE_TYPE_ANY);
         foreach ($p as $phone) {
-            if ($phone->linkType() == Phone::LINK_ADDRESS && array_key_exists($phone->linkId(), $this->addresses)) {
-                $this->addresses[$phone->linkId()]->addPhone($phone);
+            /* We must iterate on the addresses because id is not uniq thus,
+             * $this->addresse[$phone->linkId()] is invalid.
+             */
+            foreach ($this->addresses as $address) {
+                if ($address->type == Address::LINK_PROFILE && $address->id == $phone->linkId()) {
+                    $address->addPhone($phone);
+                }
             }
         }
     }