Roundcube Community Forum

 

Simple question

Started by Aven3000, June 17, 2013, 07:46:58 PM

Previous topic - Next topic

Aven3000

Hello all,

It's a very simple question but I can't find the answer anywhere. I found a plugin that returns the number of unread messages. It is located in plugins/getunread/getunread.php. My question is how do I output it? I just wanted a file that outputs that number, that's it.

Thank you

SKaero

Where are you trying to output it?

Aven3000

The plugin returns the number of unread messages.

So I'm trying to output the number of unread messages. So in other words, how do I get the plugin results? where do I 'echo' the results?

Thank you

Aven3000

Sorry I misread your message.

I'd prefer to output it in just its own separate page. A blank white page. 

But if that's not possible then at least on the main Email page.

Thank you

SKaero

Can you post the code in the plugin?

Aven3000

Here it is:


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   
    }
}

Aven3000

Btw this is an issue that I've been trying to figure out for at least 12 hours now. I just want to get that number, that's it. Preferably displayed in a file by itself.

SKaero

The following code should work:

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

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


The URL would be <RC URL>?_task=mail&_action=plugin.unreadmessage

Aven3000

Okay thank you I think we're close. However, when I go to that page, it says "SERVICE CURRENTLY NOT AVAILABLE!"

I have three questions:

1) The plugin folder is called 'getunread' so in my plugins/main.inc.php, I have this code:
$rcmail_config['plugins'] = array('getunread');

And without it, the mail page goes blank, it breaks.  So I'm guessing I'm on the right track if I leave the code there correct?

2) The die() makes the mail page die as well. I'm guessing because I put the plugin as part of 'mail' task?

3) If I remove die() and just replace it with return or echo, it still gives "SERVICE CURRENTLY NOT AVAILABLE!" and I used the URL http://websiteURL/roundcube/?_task=mail&_action=plugin.unreadmessage

Thank you

Aven3000

And here's error in the log:


[19-Jun-2013 09:34:06 -0700]: PHP Error: No handler found for action plugin.unreadmessage in /var/www/roundcube/program/include/rcube_plugin_api.php on line 324 (GET /roundcube/?_task=mail&_action=plugin.unreadmessage)

SKaero

If the folder name is getunread the class name also needs to be getunread.

Aven3000

Okay thank you that fixed most of the problems.

This is my code:
class getunread extends rcube_plugin{
    public $task='mail';

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


However, the page is just blank. And it didn't break the page because I was able to write some stuff after.

SKaero

Then if I had to guess the code to get the number of unread messages is wrong, I haven't played with it before so I can't say for sure.