From 56721636abf0c5eac652b569ce3b2f5b42c89357 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Tue, 29 Jun 2010 00:00:51 +0200 Subject: [PATCH] Fixes Outlook contacts page broken by change in phones. --- classes/profile.php | 5 ++++- modules/carnet/outlook.inc.php | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index 56e1f5a..ee23cab 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -594,7 +594,10 @@ class Profile private function fetchPhones() { if ($this->phones == null && !$this->fetched(self::FETCH_PHONES)) { - $this->setPhones($this->getProfileField(self::FETCH_PHONES)); + $phones = $this->getProfileField(self::FETCH_PHONES); + if (isset($phones)) { + $this->setPhones($phones); + } } } diff --git a/modules/carnet/outlook.inc.php b/modules/carnet/outlook.inc.php index 7907eb8..03913a8 100644 --- a/modules/carnet/outlook.inc.php +++ b/modules/carnet/outlook.inc.php @@ -31,8 +31,15 @@ class Outlook { $contact['Ville ('.$adr_type.')'] = $adr->locality; $contact['Dép/Région ('.$adr_type.')'] = $adr->administrativeArea; $contact['Pays ('.$adr_type.')'] = $adr->country; - $contact['Téléphone ('.$adr_type.')'] = $adr->fixed_tel; - $contact['Télécopie ('.$adr_type.')'] = $adr->fax_tel; + $phones = $adr->phones(); + foreach ($phones as $p) { + if ($p->hasType(Profile::PHONE_TYPE_FIXED)) { + $contact['Téléphone ('.$adr_type.')'] = $p->display; + } + if ($p->hasType(Profile::PHONE_TYPE_FAX)) { + $contact['Télécopie ('.$adr_type.')'] = $p->display; + } + } } private static function profile_to_contact(&$p) { @@ -105,7 +112,7 @@ class Outlook { return $contact; } - private static function protect($t) { + private static function protect(&$t) { if (empty($t)) { return '""'; } @@ -113,7 +120,7 @@ class Outlook { return '"'.strtr(utf8_decode($t),'"', '\\"').'"'; } - public static function output_profiles(&$profiles, $lang) { + public static function output_profiles($profiles, $lang) { pl_content_headers("text/plain", "iso8859-15"); $fields =& Outlook::$contact_fields[$lang]; foreach ($fields as $i => $k) { @@ -131,7 +138,8 @@ class Outlook { echo Outlook::protect($values[$k]); } else { // HACK to fix fullname - echo Outlook::protect($p->firstName()." ".$p->lastName()); + $fullname = $p->firstName()." ".$p->lastName(); + echo Outlook::protect($fullname); } } echo "\r\n"; -- 2.1.4