Hi there,
I'm quite new to roundcube, because a customer of mine needs a little function I had to programm for him. So I did with the current release of RC and it just works fine. But now there is a problem: My customer uses v1.0.3 and is not going to update within the next time and recommends to get the plugin compatible to this version. I had some trouble till now to find the issue but I'm noch able to do so.
It seems to be a problem with the output: my script waits for JSON-data but gets the hole page. Here a snippet of the relevant code:
$(document).ready(function() {
rcmail.addEventListener('plugin.myaction', myaction);
rcmail.http_post('plugin.myaction');
});
function myaction(response)
{
// do some stuff
}
This code-snipped is somewhat simple but should show what I want to do. The JS is only included if there is a defined condition so there will be no communication otherwise.
If the JS is loaded it sends a POST-request to the server to start the action which runs as expected, but there is no JSON-output as expected like in v1.1.3. I hope someone can help me out, I donÄt know where to look at and the changelogs doesn't help to find the relevant difference within v1.0.3 and 1.1.3...
class myplugin extends rcube_plugin
{
// [...]
public function init()
{
// register hook
$this->add_hook('myhook', array($this, 'mycheck'));
// register action
$this->register_action('plugin.myaction', array($this, 'myaction'));
}
public function myaction()
{
// send ajax-response back to client
$rcmail = rcmail::get_instance();
$rcmail->output->command('plugin.myaction', array('_mycontent' => 'content'));
}
public function mycheck($p)
{
// [...] do some stuff
if ($foo == $bar) {
// include js/css
$this->include_script('myplugin.js');
}
// return the object as expected by api
return $p;
}
}