[imp] Marking forwards, categories?

Simon Detheridge simon at widgit.com
Thu Jun 9 14:52:25 PDT 2005


Quoting Chuck Hagenbuch <chuck at horde.org>:

> Quoting Simon Detheridge <simon at widgit.com>:
>
>> It seems like this should be trivial. Is there an option I'm 
>> missing, or do I
>> need to modify a php file somewhere?
>
> You'd have to implement it. On large mailboxes it'll be quite slow.

I had a bash at it. I've attached a patch that provides the icon and 
works on my
system. I expect all the seasoned developers will be horrified with the 
way it's
done, as I've not had a stab at playing with horde code before. ;-)

It *will* stop my users asking for it however.

There are problems with reading fhe 'forwarded' state from the history, for
example you can't "mark as" forwarded, or similarly unmark... Not 
without doing
some history-mangling, which seems incredibly unwise.

I'm thinking that a hack like this could be used to add category 
information...
By adding it to the maillog for the message in question. There'd be no way to
search on it though. It'd probably need a separate table...

-- 
Simon Detheridge
SEN Developer, Widgit Software




This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
-------------- next part --------------
diff --unified --recursive imp-h3-4.0.3/lib/IMP.php imp-hacked/lib/IMP.php
--- imp-h3-4.0.3/lib/IMP.php	2005-03-26 00:18:01.000000000 +0000
+++ imp-hacked/lib/IMP.php	2005-06-09 22:28:57.000000000 +0100
@@ -71,6 +71,12 @@
  */
 define('IMP_PERSONAL', 32);
 
+/**
+ * SIMON:
+ * An email is forwarded.
+ */
+define('IMP_FORWARDED', 64);
+
 // IMAP Sorting Constant
 /**
  * Sort By Thread.
diff --unified --recursive imp-h3-4.0.3/lib/Mailbox.php imp-hacked/lib/Mailbox.php
--- imp-h3-4.0.3/lib/Mailbox.php	2005-03-23 04:34:13.000000000 +0000
+++ imp-hacked/lib/Mailbox.php	2005-06-09 22:38:39.000000000 +0100
@@ -1,5 +1,8 @@
 <?php
 
+//SIMON: we need maillog to know if mails are forwarded
+require_once('Maillog.php');
+
 define('IMP_MAILBOX_MOVE', 1);
 define('IMP_MAILBOX_COPY', 2);
 define('IMP_MAILBOX_DELETE', 3);
@@ -139,6 +142,14 @@
     var $_previews = array();
 
     /**
+     *
+     * SIMON: Do we want to use the maillog for extra mail information?
+     *
+     * @var boolean $_usemaillog
+     */
+    var $_usemaillog = false;
+
+    /**
      * Constructor.
      *
      * @access public
@@ -152,6 +163,9 @@
     {
         global $imp, $prefs;
 
+        //SIMON: This should be loaded from prefs but I don't know yet...
+        $this->_usemaillog = true;
+
         if (!is_null($index)) {
             $this->setNewIndex($index);
         }
@@ -331,6 +345,21 @@
                     $overview[$key]['structure'] = ($conf['mailbox']['show_attachments']) ? @imap_fetchstructure($imp['stream'], $header->uid, FT_UID) : null;
                     $overview[$key]['preview'] = null;
                 }
+                //SIMON: retrieve the history and check for forwards
+                $overview[$key]['forwarded'] = false ;
+                if ($this->_usemaillog) {
+                    if (preg_match("/Message-ID:(.*)\n/", $hdr, $msg_id)) {
+                        $msg_id = trim($msg_id[1]);
+                    }
+                    $hist = IMP_Maillog::getLog($msg_id);
+                    if(!is_a($hist, 'PEAR_Error')) {
+                        foreach ($hist->getData() as $entry) {
+                            if ($entry['action'] == 'forward') {
+                                $overview[$key]['forwarded'] = true ;
+                            }
+                        }
+                    }
+                }
             }
         }
 
diff --unified --recursive imp-h3-4.0.3/mailbox.php imp-hacked/mailbox.php
--- imp-h3-4.0.3/mailbox.php	2005-03-23 04:56:28.000000000 +0000
+++ imp-hacked/mailbox.php	2005-06-09 22:28:45.000000000 +0100
@@ -702,6 +702,12 @@
             $style[] = 'strike';
             $msg['bg'] = 'deleted';
         }
+	//SIMON: forwarded flags
+        if ($message['forwarded']) {
+            $flagbits |= IMP_FORWARDED;
+            $msg['status'] .= Horde::img('forward.png', _("Forwarded"));
+            //$msg['bg'] = 'answered'; 
+        }
         $flags[] = $flagbits;
     } else {
         $flags[] = 0;


More information about the imp mailing list