I want to develop a custom plugin for a company which shall support internal workflows.
When a message in the inbox is selected and previewed I need to have a JS callback, well, called. It should get the message UID as argument or is able to get the UID from the message list's selection.
I found the documention of JavaScript events not very helpful. I successfully tried the init event. But I cannot find an event fired by message selection, load or display. How are these called? The trac wiki page (http://trac.roundcube.net/wiki/Plugin_Events#beforeandafter (http://trac.roundcube.net/wiki/Plugin_Events#beforeandafter)) says I can use after* or before* but I cannot find a reference of commands suitable as replacement for the asterisk. I tried afterload or aftermessage_load without success.
As a workaround I tried to implement a PHP hook on serverside and delegate the event via API to JS on the client. This is what I've written:
// PHP server side
class my_plugin extends rcube_plugin {
// embed javascript file
function init() {
$this->include_script('my_plugin.js');
$this->add_hook('message_read', array($this, 'message_read'));
}
function message_read($args) {
$rcmail = rcmail::get_instance();
$rcmail->output->command('plugin.message_read', $args['uid']);
}
}
// JavaScript side
rcmail.addEventListener('plugin.message_read', function(uid) {
console.log('read message ' + uid);
});
Unfortunately I didn't see any sign that this worked out. So to sum it up:
1. How to get JS code called when a message is opened in preview?
2. How get a log/debug output of events/hooks/commands on server respectively client side?
Kind regards
If I remember correctly the following will get you the uid when a message is clicked:
rcmail.message_list.addEventListener('click', function () {
console.log(rcmail.message_list.get_selection());
});
I succeeded by register an event handler for the select-event of the rcmail.message_list
.
Thank you for the hint to the right point!