I am trying to build a plugin to show a predefined message, only once, as a popup to the user just after he access his account.
After searching through documentation and other plugins i figured out it would be a simple task, like a "hello world".
Unfortunatelly i was wrong and could not make it work.
I have tried to hook with different events such as 'login_after', 'ready' and 'startup'.
My javascript code define a function that simple calls the alert function and add this code as an eventListener to rcmail object.
At my php code i call the eventListener with the message text if action = login.
After some debug i can see that the eventListener is actually called but no popup appears. I also observed that if i call the listener at other moments (just commenting the action = login conditional) the message popup appears. But at the wrong time, and lots of times, of course.
Is there something i am not seeing? Does Roundcube impose some kind of grephic limitation to plugins during some special actions?
Thanks in advance!
Here is the simplified code:
advices.js
function show_advice(message)
{
alert(message);
}
if (rcmail)
{
rcmail.addEventListener('plugin.ShowAdvice', show_advice);
}
advices.php
class advices extends rcube_plugin
{
function init()
{
$this->include_script('advices.js');
$this->add_hook('startup', array($this, 'Advice'));
}
function Advice($args)
{
$RCMAIL = rcmail::get_instance();
if ($args['action'] == 'login')
{
$RCMAIL->output->command("plugin.ShowAdvice", 'This is an advice!');
}
return $args;
}
}
I think the problem your running into is the login action has no visible page, take a look at the new_user_dialog plugin which does a very similar function to what you want to do.