[dev] [cvs] commit: turba/lib Driver.php

Jan Schneider jan at horde.org
Thu Mar 20 14:18:58 UTC 2008


Zitat von Gunnar Wrobel <wrobel at pardus.de>:

> Jan Schneider <jan at horde.org> writes:
>
>> Zitat von Gunnar Wrobel <p at rdus.de>:
>>
>>> wrobel      2008-03-20 08:29:22 EDT
>>>
>>>   Modified files:
>>>     lib                  Driver.php
>>>   Log:
>>>   Removed possible notice. We cannot be certain here that all the
>>> fields are set in the hash.
>>>
>>>   Revision  Changes    Path
>>>   1.189     +6 -2      turba/lib/Driver.php
>>>
>>>   Chora Links:
>>>   http://cvs.horde.org/diff.php/turba/lib/Driver.php?r1=1.188&r2=1.189&ty=u
>>
>> That doesn't make sense. If a field doesn't exist, it shouldn't be in
>> the 'map/fields' array.
>
> I get the notice I was trying to fix when importing a vCard into
> Turba.
>
>
> $vcardtxt = 'BEGIN:VCARD
> VERSION:2.1
> N:test3;test3;;;
> FN:test3 test3
> END:VCARD';
>
> $iCal = new Horde_iCalendar();
> $vcard = Horde_iCalendar::newComponent('vcard', $iCal);
> $vcard->parsevCalendar($vcardtxt);
> $iCal->addComponent($vcard);
> $content = $iCal->getComponent(0);
> $turba = Turba_Driver::singleton('wrobel at dev.pardus.de');
> var_dump($turba->toHash($content));
>
> array(3) {
>   ["lastname"]=>
>   string(5) "test3"
>   ["firstname"]=>
>   string(5) "test3"
>   ["name"]=>
>   string(30) "firstname middlenames lastname"
> }
>
> As far as I can tell _turba_import() in api.php converts a vCard to a
> hash using $driver->toHash(). This function does not guarantee that
> all possible turba attributes are set in the hash (in this case the
> vCard does not provide "middlenames").
>
> When _turba_import() calls $driver->add() with the hash it will be
> used with toDriverKeys($hash).
>
> For Kolab 'name' is defined as
>
>             'name' => array('fields' => array('firstname',  
> 'middlenames', 'lastname'),
>                             'format' => '%s %s %s',
>                             'attribute' => 'full-name'),
>
> but middlenames is not provides by the hash so I get a notice.
>
> I'm probably missing something and need to fix the Kolab
> driver. Should the Kolab driver somehow override the toHash() function
> and ensure that all required Turba attributes are set in the Hash?

This code section in toDriverKeys() actually doesn't make much sense  
to me. AFAICS this is what's happening:

- we have a composite field in the hash (name)
- we have an 'attribute' entry that tells us to save the composite  
field in the specified field (full-name)
- but instead of simply using the value from the name composite field,  
we now go through all fields that make up that field an re-create the  
composite value

Does anybody see any sense in that?

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the dev mailing list