Author Topic: AutoReply Plugin  (Read 9272 times)

Offline roundfan88

  • Newbie
  • *
  • Posts: 2
AutoReply Plugin
« on: July 11, 2008, 04:45:11 PM »
For the AutoReply Plugin does not work with me, I want to create an own plugin, hence fore I have a few questions:

1) I need to know WHERE in the code can I influence what happens if the users clicks the "Get Email Button" on the startpage of RoundCube?

2) How am I able to determine if an email, RoundCube received is read or unread?
    Is there a way to check the database? I didn't find any marker to determine if the email is
    unread/read.



Thanks for your time and your answers

greets from Toby

Offline roundfan88

  • Newbie
  • *
  • Posts: 2
AutoReply Plugin
« Reply #1 on: July 12, 2008, 07:37:57 AM »
And I need to determine if a new email has arrived!
Please help me!
Thx

Offline Adbie

  • Newbie
  • *
  • Posts: 1
AutoReply Plugin
« Reply #2 on: July 14, 2008, 02:26:13 PM »
req too.
auto filter would also be very useful

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
AutoReply Plugin
« Reply #3 on: July 14, 2008, 11:07:21 PM »
1.) Search the source (or follow the request) through using the "checkmail" as the command.  If you go to /skins/default/templates/mail.html you can see on line 102 the following:

So starting from the top:
  • We see in the template mail.html we have an "checkmail" action.
  • We then look in the JS to see if there's somethign going on with that and we see it's an "enabled_command"
  • The enabled_command means it's useable, so we continue scrolling to see what command it executes: check_for_recent()
  • check_for_recent() then sends a request to index.php using "check-recent" as the action.
  • Index.php receives this request and sees the task as being "mail" and the action as "check-recent" so it includes /program/steps/mail/check_recent.inc
So there you have it.  You can impact it by looking in that include file.

2.) According to the javascript there is an "unread" array key which is either true for unread, or false for read.  So I guess you could put in your code:
if($rcmail_message[$message_id]['unread'])
{
    
// The message is "new" or marked as unread
}
else
{
    
// The message is "old" or marked as read
}


Now, that's not to take into account that it may in fact be marked for deletion.

Just to double-check me, try using var_dump() on the roundcube message object in /program/steps/mail/func.inc to see what's in it.  Here's an example:
Code: [Select]
object(iilBasicHeader)#17 (29) {
  ["id]=>
  string(1) "2"
  ["uid"]=>
  string(2) "74"
  ["subject"]=>
  string(20) "Re: Some Website"
  ["from"]=>
  string(38) &quot;&quot;Some Name.&quot; <prof@school.edu>&quot;
  [&quot;to&quot;]=>
  string(21) &quot;user@domain.com&quot;
  [&quot;cc&quot;]=>
  NULL
  [&quot;replyto&quot;]=>
  string(13) &quot;user@prof.edu&quot;
  [&quot;in_reply_to&quot;]=>
  string(32) &quot;487A2A34.1040305@domain.com&quot;
  [&quot;date&quot;]=>
  string(37) &quot;Mon, 14 Jul 2008 18:56:19 -0400 (EDT)&quot;
  [&quot;messageID&quot;]=>
  string(57) &quot;<1111.11.111.11.222.1234567890.squirrel@webmail.school.edu>&quot;
  [&quot;size&quot;]=>
  string(4) &quot;2523&quot;
  [&quot;encoding&quot;]=>
  string(4) &quot;8bit&quot;
  [&quot;charset&quot;]=>
  string(10) &quot;iso-8859-1&quot;
  [&quot;ctype&quot;]=>
  string(10) &quot;text/plain&quot;
  [&quot;flags&quot;]=>
  array(1) {
    [0]=>
    string(4) &quot;Seen&quot;
  }
  [&quot;timestamp&quot;]=>
  int(1216076179)
  [&quot;f&quot;]=>
  NULL
  [&quot;internaldate&quot;]=>
  string(20) &quot;14-Jul-2008 15:49:13&quot;
  [&quot;references&quot;]=>
  string(34) &quot;<487A2A34.1040305@domain.com>&quot;
  [&quot;priority&quot;]=>
  int(3)
  [&quot;mdn_to&quot;]=>
  NULL
  [&quot;mdn_sent&quot;]=>
  bool(false)
  [&quot;is_reply&quot;]=>
  bool(false)
  [&quot;seen&quot;]=>
  bool(true)
  [&quot;deleted&quot;]=>
  bool(false)
  [&quot;recent&quot;]=>
  bool(false)
  [&quot;answered&quot;]=>
  bool(false)
  [&quot;junk&quot;]=>
  bool(false)
  [&quot;structure&quot;]=>
  NULL
}

Now, in your code you could do something like:
// $message is our "message" object
if($message->headers->flags['Seen'])
    {
    
// Message is "old" or read
    
}
else
    {
    
// Message is "new" or unread
    
}


Hope that helps.
 
  

Offline krasko

  • Newbie
  • *
  • Posts: 2
AutoReply Plugin
« Reply #4 on: July 18, 2008, 06:16:31 AM »
For autoreply is, I think, better to use eg dovecot as deliver and sieve plugin.

It will reply after accept message, but round cube will reply after login to webmail.