Roundcube Community Forum

 

How to alter core addressbook functionality via a plugin

Started by ehprivacy, August 08, 2020, 10:28:01 AM

Previous topic - Next topic

ehprivacy

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!

JohnDoh

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
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

ehprivacy

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!

Warapado

Quote from: ehprivacy on August 08, 2020, 10:28:01 AM
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?