Fix vcard for users that don't have a pro address.
authorOlivier Le Floch <olivier.le-floch@polytechnique.org>
Sat, 31 Jan 2009 12:46:15 +0000 (13:46 +0100)
committerOlivier Le Floch <olivier.le-floch@polytechnique.org>
Sat, 31 Jan 2009 12:46:15 +0000 (13:46 +0100)
Signed-off-by: Olivier Le Floch <olivier.le-floch@polytechnique.org>
include/vcard.inc.php

index a755fcd..dfdadaa 100644 (file)
@@ -111,24 +111,26 @@ class VCard extends PlVCard
         }
 
         // Pro
-        foreach ($user['adr_pro'] as $pro) {
-            $street = array($adr['adr1']);
-            if (!empty($pro['adr2'])) {
-                $street[] = $pro['adr2'];
-            }
-            if (!empty($pro['adr3'])) {
-                $street[] = $pro['adr3'];
-            }
-            $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
-                                     $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
-            if (!empty($pro['tel'])) {
-                $entry->addTel($group, $pro['tel']);
-            }
-            if (!empty($pro['fax'])) {
-                $entry->addTel($group, $pro['fax'], true);
-            }
-            if (!empty($pro['email'])) {
-                $entry->addMail($group, $pro['email']);
+        if (!empty($user['adr_pro'])) {
+            foreach ($user['adr_pro'] as $pro) {
+                $street = array($adr['adr1']);
+                if (!empty($pro['adr2'])) {
+                    $street[] = $pro['adr2'];
+                }
+                if (!empty($pro['adr3'])) {
+                    $street[] = $pro['adr3'];
+                }
+                $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
+                                         $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
+                if (!empty($pro['tel'])) {
+                    $entry->addTel($group, $pro['tel']);
+                }
+                if (!empty($pro['fax'])) {
+                    $entry->addTel($group, $pro['fax'], true);
+                }
+                if (!empty($pro['email'])) {
+                    $entry->addMail($group, $pro['email']);
+                }
             }
         }