[dev] contacts/addAddressbook

Lukas Weiss lukas.weiss at raiffeisen.it
Fri Oct 30 07:42:24 UTC 2015


Am 29.10.2015 um 16:13 schrieb Michael J Rubinsky:
>
> Quoting Lukas Weiss <lukas.weiss at raiffeisen.it>:
>
>> Am 29.10.2015 um 15:31 schrieb Michael J Rubinsky:
>>>
>>> Quoting Lukas Weiss <lukas.weiss at raiffeisen.it>:
>>>
>>>> Am 28.10.2015 um 14:33 schrieb Michael J Rubinsky:
>>>>>
>>>>> Quoting Lukas Weiss <lukas.weiss at raiffeisen.it>:
>>>>>
>>>>>> Am 27.10.2015 um 17:46 schrieb Michael J Rubinsky:
>>>>>>>
>>>>>>> Quoting Lukas Weiss <lukas.weiss at raiffeisen.it>:
>>>>>>>
>>>>>>>> Am 27.10.2015 um 13:50 schrieb Andy Dorman:
>>>>>>>>> On 10/27/2015 02:31 AM, Lukas Weiss wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I wanted to create a new address book with the contacts API.
>>>>>>>>>>
>>>>>>>>>> $registry->call(
>>>>>>>>>>  'contacts/addAddressbook',
>>>>>>>>>>  array(
>>>>>>>>>>      'name' => 'New Addressbook'
>>>>>>>>>>  )
>>>>>>>>>> );
>>>>>>>>>>
>>>>>>>>>> With this call, the address book is created, but unfortunately it
>>>>>>>>>> can't
>>>>>>>>>> be selected by the user.
>>>>>>>>>>
>>>>>>>>>> In  the database, the new address book has no attribute_params
>>>>>>>>>> (NULL).
>>>>>>>>>> The address books created by the user have attribute_params like
>>>>>>>>>> this:
>>>>>>>>>>
>>>>>>>>>> a:2:{s:6:"source";s:8:"localsql";s:4:"name";s:23:"5nR0Q0rhlkzNzGn0KhZ8AeI";}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> By adding this params to the address book created with the
>>>>>>>>>> API, the
>>>>>>>>>> address book can be selected.
>>>>>>>>>>
>>>>>>>>>> Is this a bug or is there anything i forgot to do?
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I may be wrong as I have never used the contacts API, but is it
>>>>>>>>> possible
>>>>>>>>> you still need to set the params in turba's backends.local.php?
>>>>>>>>>
>>>>>>>>> Read the docs and examples in turba's backends.php file to see how
>>>>>>>>> to do
>>>>>>>>> it.
>>>>>>>>>
>>>>>>>>
>>>>>>>> I think the backends.local.php is configured correctly since
>>>>>>>> everything is working fine using the Horde frontend (I can
>>>>>>>> create and
>>>>>>>> remove address books in Turba and add new contacts).
>>>>>>>>
>>>>>>>> In Turba frontend I see also the address books created with the
>>>>>>>> API,
>>>>>>>> but when I select one of these, I am redirected to the default
>>>>>>>> address
>>>>>>>> book.
>>>>>>>>
>>>>>>>> Maybe this info is useful:
>>>>>>>> With the contacts API I get all the address books created in Horde
>>>>>>>> fronted by calling contacts/sources, but I do not receive the ones
>>>>>>>> created with contacts/addAddressbook.
>>>>>>>> However, with contact/listShares i really get all address books
>>>>>>>> (even
>>>>>>>> the ones created by the API call).
>>>>>>>
>>>>>>>
>>>>>>> What version of Horde/Turba? Git/PEAR?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> I am using PEAR
>>>>>>
>>>>>> Horde 5.2.7
>>>>>> Turba 4.2.8
>>>>>
>>>>>
>>>>> I cannot reproduce. Is the user authenticated to Horde when you run
>>>>> the
>>>>> api call?
>>>>>
>>>>>
>>>>>
>>>>
>>>> Just to try I put this code into turba/index.php right after the
>>>> appInit:
>>>>
>>>> $GLOBALS['registry']->call(
>>>>    'contacts/addAddressbook',
>>>>    array(
>>>>        'name' => 'testAddressbook'
>>>>    )
>>>> );
>>>>
>>>> The address book is created and I see it in the list, but I can't
>>>> select or remove it.
>>>
>>> What share backend are you using?
>>>
>>>>
>>>> --
>>>> dev mailing list
>>>> Frequently Asked Questions: http://wiki.horde.org/FAQ
>>>> To unsubscribe, mail: dev-unsubscribe at lists.horde.org
>>>
>>>
>>>
>>>
>>>
>>
>> i am using mysql
>>
>
> Still cannot reproduce. You are going to need to find out why the share
> ids are not being created. Start looking in Turba_Api::addAddressbook
> and look to see why $share_name is not being honored when passed to
> Turba::createShare.
>
>
>
>

In turba/lib/Form/CreateAddressBook.php the new address book is created 
like this:

$params = array(
             'params' => array('source' => 
$GLOBALS['conf']['shares']['source']),
             'name' => $this->_vars->get('name'),
             'desc' => $this->_vars->get('description'),
);
return $driver->createShare(strval(new Horde_Support_Randomid()), $params);


But in Turba_Api::addAddressbook it is created without the params array:

$share = Turba::createShare($share_name, array('name' => $name));

Is there a reason for this? If I add the params part it works properly.



More information about the dev mailing list