Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: ehprivacy on August 08, 2020, 10:28:01 AM

Title: How to alter core addressbook functionality via a plugin
Post by: ehprivacy on August 08, 2020, 10:28:01 AM
I understand how to use a plugin to alter classes in program/lib/Roundcube/, but I'm not sure where to start in changing functionality present in locations such as program/steps/addressbook/func.inc.  Can someone point me in the right direction?

For more context, I'm starting with the sql_global_addressbooks plugin (from https://github.com/t3chguy/Roundcube-SQL-Global-Address-Books) but I need to add additional contact fields that aren't part of the original spec (this is for a medical practice, so I need to add fields like "responsible party, insurer, etc" that I'll be pulling from the DB.  Those field definitions seem to be in func.inc.

I also need to change how those fields display on the contact form, and that seems to be handled by program/steps/addressbook/show.inc; I need to alter a) the items present in "contacthead" that gets called by the skin, and b) add labels like "Insurer:" before the actual insurer. 

Any guidance would be greatly appreciated!  If there are plugins doing similar alterations already, having those examples would be wonderful as well.

Thanks!
Title: Re: How to alter core addressbook functionality via a plugin
Post by: JohnDoh on August 09, 2020, 06:24:28 AM
you could use render_page hook to add custom fields into the contents form and the i guess the contact_create and contact_update hooks to do the saving
Title: Re: How to alter core addressbook functionality via a plugin
Post by: ehprivacy on August 09, 2020, 02:10:44 PM
Thanks for the idea for the render_page hook; I'll look into that for formatting.

I actually ended up stumbling over the line:

$plugin = $RCMAIL->plugins->exec_hook('contact_form', array(
        'form' => $form, 'record' => $record, 'head_fields' => $head_fields));

in func.inc, and that looked like exactly what I needed.  I googled for something using the "contact_form" hook, and found the kolab address book plugin (at https://gitlab.awesome-it.de/kolab/roundcube-plugins/-/tree/feature_caldav/plugins/kolab_addressbook) and it showed me how to get my additional custom fields in and it's going well, other than the formatting which "render_page" looks like it might help with.

Thank you!
Title: Re: How to alter core addressbook functionality via a plugin
Post by: Warapado on August 15, 2020, 03:14:51 PM
For more context, I'm starting with the sql_global_addressbooks plugin (from https://github.com/t3chguy/Roundcube-SQL-Global-Address-Books) but I need to add additional contact fields that aren't part of the original spec (this is for a medical practice, so I need to add fields like "responsible party, insurer, etc" that I'll be pulling from the DB.  Those field definitions seem to be in func.inc.

I correctly understood that you need a specific example of a ready-made plugin in use, or if you take the proposed method of displaying it in the contact form, the classes will not change?