Well, I have created following plugin in order to show number of unread messages. It works fine, but the only problem it has is it doesn't update automatically when new mail arrives. What I want to do is to add a hook like: $this->add_hook('new_messages', array($this, 'notify')) and in the notify function to update the content of the object that I have in the template :. But I don't know how to do that, could you please help me in this problem?
Here is the code for my plugin:
class test extends rcube_plugin{
public $task='mail';
function init(){
$this->register_handler('plugin.unreadmessage',array($this, 'unreadmessage_handler'));
$this->add_hook('new_messages', array($this, 'notify'));
}
function notify(){
// I need to write here the code in order to update the object which is in the template
// Need help please contribute in this work.
}
function unreadmessage_handler(){
$rcmail = rcmail::get_instance();
$count=$rcmail->imap->messagecount('INBOX', 'UNSEEN');
return "You have $count new messages";
}
}
Thank you
You'll need to have a javascript file with a callback so the JS can update the count, for example: Doc_Plugins (http://trac.roundcube.net/wiki/Doc_Plugins#Ajaxrequestsandcallbacks)