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
Where are you trying to output it?
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
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
Can you post the code in the plugin?
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
}
}
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.
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
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
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)
If the folder name is getunread the class name also needs to be getunread.
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.
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.