Author Topic: How to get number of new mails from template or plugin?  (Read 2896 times)

Offline bakhtiyor

  • Jr. Member
  • **
  • Posts: 22
How to get number of new mails from template or plugin?
« on: November 02, 2011, 06:17:23 AM »
I have created a new skin and need to show in the header a text saying "You have 3 new mails" for instance. How can I do that from the template, or from the plugin if I need to create one?

Thank you.

Offline bakhtiyor

  • Jr. Member
  • **
  • Posts: 22
How to get number of new mails from template or plugin?
« Reply #1 on: November 02, 2011, 08:38:37 AM »
Well, I have found myself the solution and wanted to share in a case if somebody else will need it. So I have created a plugin and here is the bunch of the code of the plugin needed to extract number of unread message:

class test extends rcube_plugin{
    public 
$task='mail';

    function 
init(){     
       
$this->register_handler('plugin.unreadmessage',array($this'unreadmessage_handler'));
    }
    function 
unreadmessage_handler(){
       
$rcmail rcmail::get_instance();        
       
$count=$rcmail->imap->messagecount('INBOX''UNSEEN');
       return 
$count    
    
}
}


Use it for your use!
« Last Edit: November 11, 2011, 07:24:35 AM by bakhtiyor »