wiki:Plugin_Hooks

Version 12 (modified by thomasb, 4 years ago) (diff)

--

Available Plugin Hooks

The registered callback function receives a hash array as single argument which contains hook specific data (called Arguments in the following list). It can then alter some of these values (listed as Return values) by returning a hash array containing the modified values.

Global Hooks

startup

When the application is initialized.
This is the place where task and action arguments can be altered.

Arguments:

  • task
  • action

Return values:

  • task
  • action

authenticate

Before the user login on the IMAP server is performed.

Arguments:

  • host
  • user

Return values:

  • host
  • user
  • pass

login_after

Triggered after a user successfully logged in.
This hook allows a plugin to control the redirect after the login form was submitted. Information about the current user can be obtained from the rcube_user object at rcmail::get_instance()->user

Arguments:

  • task

Return values:

  • task
  • action
  • [more url parameters]

login_failed

Triggered if user authentication failed.
Could be useful for logging or to give more detailed feedback to the user why the login failed.

Arguments:

  • host
  • user
  • code

Return values:

none.

create_user

When a somebody logs in the first time and a local user is created.
Return values will also be used to create the default identity for this new user.

Arguments:

  • user
  • user_name
  • user_email

Return values:

  • user_name
  • user_email

list_mailboxes

Triggered whenever a list of the mailboxes is requested from the IMAP class.
If no plugin returns a list, the default list is retrieved.

Arguments:

  • root
  • filter

Return values:

  • folders: Folders list to be used

Task "mail"

imap_init

This hook allows you to configure some IMAP communications options.

Arguments:

  • fetch_headers: String appended to the FETCH HEADER.FIELDS () list

Return values:

  • fetch_headers: String with additional headers to be fetched (separated by space)

message_load

Triggered when a message is loaded from the server, namely when creating a new rcube_message object.
This allows one to analyze the structured message object and find specific attachments, headers or contents for further actions.

Arguments:

  • object: The rcube_message instance

Return values:

none.

message_read

Triggered when a message is loaded and its SEEN flag is set.
The message argument will give you access to all the message headers and its structure.

Arguments:

  • uid
  • mailbox
  • message: The according rcube_message instance

Return values:

none.

message_part_before

Triggered before a message part (text or html) is cleaned/formatted.

Arguments:

  • type
  • body
  • safe
  • plain
  • inline_html

Return values:

  • type
  • body
  • safe
  • plain
  • inline_html

message_part_after

After message text part formatting.

Arguments:

  • type
  • body
  • safe
  • plain
  • inline_html

Return values:

  • body

message_headers_output

Triggered when building the message headers table for display.
If you want to add more headers, you need to fetch them at the imap_init hook.

Arguments:

  • output: Hash array with all the headers to be put into the html table
  • headers: Message headers object

Return values:

  • output: Altered headers array

outgoing_message_headers

Before a mail message is sent, this hooks allows you to set additional mail headers.

Arguments:

  • headers: Hash array with current message headers

Return values:

  • headers

outgoing_message_body

Before a mail message is composed, this hooks is triggered before assing the message body contents.

Arguments:

  • body: The message body to be added
  • type: html|plain|alternative
  • message: Reference to current MailMime? object

Return values:

  • body

Task "addressbook"

address_sources

Triggered when building the list of address sources in the address book view.
Each entry in the sources list needs to hold the following fields: id, name, readonly.

Arguments:

  • sources: Hash array with list of available address books

Return values:

  • sources

get_address_book

This hook is triggered each time an address book object is requested.
The id parameter specifies which address book the application needs. If it's the ID of the plugins' address book, this hooks should return an according instance of a rcube_addressbook implementation.

Arguments:

  • id

Return values:

  • instance: Instance of an address book implementation derived from rcube_addressbook

Task "settings"

manage_folders

Allows a plugin to modify the main table on the manage folders screen

Arguments:

  • table: reference to an html_table object

Return values:

none.

save_preferences

Allows a plugin to inject data into the array of preferences about to be saved

Arguments:

  • prefs: Hash array with prefs to be saved

Return values:

  • prefs

user_preferences_server_settings

Allows a plugin to modify the user preferences server settings table

Arguments:

  • table (reference to an html_table object)

Return values:

none.


Template Hooks

The RoundCube skin retrieves certain parts (e.g. message list, folders list, etc.) from the application with special tags within the HTML templates: <roundcube:object name="someobject" ... />. Template hooks are triggered once a template object is rendered. A plugin can alter or extend the html content of a template object.

The hooks are named template_object_* where * is the name of the object. A list of all available template objects is given in Doc_TemplateObjects?.

Arguments:

  • content
  • [tag attributes]

Return values:

  • content