[sync] An extra ";" in Company after syncing to PPC contact
Naoyuki Tai
ntai at smartfruit.com
Thu Mar 1 16:12:53 PST 2007
Jan Schneider wrote:
>> Jan,
>> Thanks.
>>
>> I checked out the horde and framework and installed, and
>> I did the sync.
>> Now, empty "Company" field looks like:
>>
>> ;;;;;;
>>
>> (six semicolons)
>>
>> And, if the entry has a home address, the "Company" shows:
>>
>> ;;1 Post office road Boston, MA; United States;;;;United States
>>
>> Jan, could you please tell me where in the CVS tree to look at,
>> so that I can tinker until it works.
>
>
> turba/lib/Driver.php, Turba_Driver::tovCard().
>
> Jan.
>
At line 836 of rev. 1.124 of Driver.php, $a is not correctly set when
it calls $vcard->setAttribute();
However, it does not explain the original problem of ";".
Note, I do know very little about php, about a couple of hours while
trying to set up horde.
It looks like implode() is interested in canonical array expansion which
is not suited for the purpose.
string_join() is more careful about glueing pieces.
I'll try the syncing later.
Index: Driver.php
===================================================================
RCS file: /repository/turba/lib/Driver.php,v
retrieving revision 1.124
diff -c -r1.124 Driver.php
*** Driver.php 1 Mar 2007 10:05:12 -0000 1.124
--- Driver.php 2 Mar 2007 00:12:30 -0000
***************
*** 1,4 ****
--- 1,16 ----
<?php
+
+ function string_join($glue, $array)
+ {
+ $output = '';
+ foreach($array AS $key => $value) {
+ if (isset($value) and $value and $value != '') {
+ $output = ($output == '') ? $value : $output . $glue . $value;
+ }
+ }
+ return $output;
+ }
+
/**
* The Turba_Driver:: class provides a common abstracted interface to the
* various directory search drivers. It includes functions for searching,
***************
*** 829,839 ****
$vcard->setAttribute('ADR', implode(';', $a), array('TYPE'
=> 'HOME'), true, $a);
}
! $org = isset($hash['company']) ? $hash['company'] : '';
! if (isset($hash['department'])) {
! $org .= ';' . $hash['department'];
! }
! $vcard->setAttribute('ORG', $org, array(), false, $a);
if (isset($hash['workAddress']) && !isset($hash['workStreet'])) {
$hash['workStreet'] = $hash['workAddress'];
--- 841,849 ----
$vcard->setAttribute('ADR', implode(';', $a), array('TYPE'
=> 'HOME'), true, $a);
}
! $a = array(0 => isset($hash['company']) ? $hash['company'] : null,
! 1 => isset($hash['department']) ?
$hash['department'] : null);
! $vcard->setAttribute('ORG', string_join(';', $a), array(),
false, $a);
if (isset($hash['workAddress']) && !isset($hash['workStreet'])) {
$hash['workStreet'] = $hash['workAddress'];
--
+--+--+ | | --+-- -- Peace on Earth
| | | -+--+- +-+ ---
+--+--+ --+--+-- | |=| /
| | | | | | +-+ / Naoyuki "Tai" Tai
+--+--+ _| +----- ------ ntai a t smartfruit d o t com
More information about the sync
mailing list