Roundcube Community Forum

 

Extend contact object

Started by diablo81, January 13, 2014, 02:17:13 PM

Previous topic - Next topic

diablo81

Hi all,
I'm working on integration between roundcube and civiCRM and I need to extend the contact object in roundcube in order to add a custom field. I tried to search in this forum but I didnt find an answer to my question.
The integration I want to realize is create/edit contact in roundcube that will result in a create/edit contact in civiCRM. For the edit function of a civiCRM contact I need its ID (I'm using REST api of civiCRM). So my need is to save somewhere in roundcube the civiCRM contact id when I create a contact in roundcube/civiCRM. Another way could be search for contact in civiCRM using contact fields saved in roundcube (using again the REST api of civiCRM), but that could result in data integrity loss, because in roundcube you can save more than one contact with the same name, surname and email.
So I'm thinking about the better way to do that and my concept of better way is try to do all in the plugin code, no patch for roundcube neither custom table into the DB.

Unfortunately I wasnt able to find that kind of solution: the less invasive idea I had was to use the hook in the plugin (contact_create) and then save the civiCRM id and roundcube id in a custom table.

Do you have any better idea?

Ps. sorry for my english

Thank you all.

SKaero

It sounds like you want to an address book of contacts from civiCRM. Take a look at the example_addressbook plugin (comes with RoundCube) for an example of how you can create a full wrapper to pull contacts from an external source to show/edit them in RoundCube.

diablo81

Quote from: SKaero on January 13, 2014, 02:49:19 PM
It sounds like you want to an address book of contacts from civiCRM. Take a look at the example_addressbook plugin (comes with RoundCube) for an example of how you can create a full wrapper to pull contacts from an external source to show/edit them in RoundCube.

Thank you for your answer SKaero.
I'm not sure I completely understood what you are saying: you suggest to wrap the civiCRM addressbook by extending the rcube_addressbook object. So for example I have to rewrite the list_records method in order to get all civiCRM contact and so on. Right?

That way it's for sure the best, I'm agree with you: I will have a single addressbook "completely synchronized" (both system will use the same addressbook). Anyway I think it's really a big work! For example to get a list of records I have to use rest api from civiCRM (I cannot interact directly with civiCRM backend) in order to construct on that result the rcube addressbook.

Did I understand fine your idea?

SKaero

Yes that is correct, that way there is only one source for the contact (civiCRM) and it would be consistent UI for the user.