[turba] Address book contents delete
Harvey
mail at harveybraun.com
Tue Mar 18 08:45:39 UTC 2014
Quoting Jan Schneider <jan at horde.org>:
> Zitat von Harvey <mail at harveybraun.com>:
>
>> Quoting Jan Schneider <jan at horde.org>:
>>
>>> Zitat von Harvey <mail at harveybraun.com>:
>>>
>>>> Requesting some help on a script I'm trying to complete for syncing an
>>>> addressbook with external vcard data without going through the webmail
>>>> interface, ie using the cli.
>>>>
>>>> I am using the "turba-import-vcards" script which adds the vcard
list
>>>> provided to the required addressbook without any problems. The problem
>>>> I am
>>>> having is to sync the addressbook I need to clear its contents first.
>>>> At
>>>> least this is how it is done through the web interface. I do need to
>>
>> keep
>>>> the addressbook share info as well so it remains synced as required
>>
>> using
>>>> activesync. I have found adding the new info without deleting the
>>>> original
>>>> contacts creates duplicates even if none of the information has
changed
>>>> in
>>>> the vcard list. The duplicates happen whether I use the web interface
>>>> or
>>>> the turba-import-vcards to add the vcard list.
>>>>
>>>> I am not a php programmer, and have not made enough sense out of the
>>>> delete
>>>> options of the Api.php to add a line that will accomplish this. Is it
>>>> possible to get some examples of how I could add the option of
deleting
>>>> the
>>>> contents of an addressbook first before adding the new/updated vcard
>>>> info?
>>>>
>>>> Cheers
>>>> Harvey
>>>
>>> Just call deleteAll() on the Turba_Driver instance.
>>> --
>>> Jan Schneider
>>> The Horde Project
>>> http://www.horde.org/
>>> https://www.facebook.com/hordeproject
>>>
>>> --
>>> turba mailing list
>>> Frequently Asked Questions: http://wiki.horde.org/FAQTo unsubscribe,
>>> mail: turba-unsubscribe at lists.horde.org
>>
>> Thanks Jan
>>
>> Unfortunately I can't expand on your comment above to the extent that I
>> can
>> make anything work. Although using the origonal turba-import-vcard
script
>> may have me looking in the wrong place.
>>
>> In the current script the following line imports the vcard list to the
>> address book based on variables allready provided;
>>
>> $result = $registry->call('contacts/import', array($vcard,
>> 'text/x-vcard',
>> $source));
>>
>> Calling the following (and numerous variations of it) doesn't prevent
the
>> script from running but also doesn't do anything;
>>
>> $result = $registry->call('contacts/delete', deleteAll(), $source);
>>
>> Can the addressbook contents be deleted as simply as that or should I be
>> looking at this as a bigger scripting issue?? No doubt I am asking the
>> obvious but with no scripting examples that I have been able to find to
>> compare my needs to I am shooting in the dark...
>>
>> Cheers
>> Harvey
>
> No, you have to do this differently. The import script uses an API
> method because there happens to be one which already does all the bulk
> of importing vCards. Very handy. This also means that the backend driver
> and any import logic is completely hidden from the actual script.
> Thus you need to explicitly instantiate a driver object in the import
> script and call deleteAll() on *that* one. The following code should
> work:
>
>
$injector->getInstance('Turba_Factory_Driver')->create($source)->deleteAll();
>
> This has to be added immediately before the contacts/import registry
call.
> --
> Jan Schneider
> The Horde Project
> http://www.horde.org/
> https://www.facebook.com/hordeproject
>
> --
> turba mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQTo unsubscribe,
> mail: turba-unsubscribe at lists.horde.org
Very good Jan!!
I have been reading through the data.php and the web page script to try and
work out how it instigated the addressbook purge...
Your line works correctly and works like a charm. Its not much to sync a
vcard list created from a mysql database using your web page Import/Export
layout but when it needs to be done each day thats why we have cron jobs...
:)
Thank you heaps Jan.
Cheers
Harvey
More information about the turba
mailing list