summaryrefslogtreecommitdiff
path: root/program/include/rcube_message_header.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2012-04-13 08:52:02 +0000
committeralecpl <alec@alec.pl>2012-04-13 08:52:02 +0000
commit0c259682f65eaaf23ea4ccb56a706d6baf3007e4 (patch)
treef1491f39189c8a970e7612b9dcc20f9409d7361e /program/include/rcube_message_header.php
parentce64332e7a9bf2468eabdb4b789270aebb3e7dc7 (diff)
- Merge devel-framework branch, resolved conflicts
Diffstat (limited to 'program/include/rcube_message_header.php')
-rw-r--r--program/include/rcube_message_header.php238
1 files changed, 238 insertions, 0 deletions
diff --git a/program/include/rcube_message_header.php b/program/include/rcube_message_header.php
new file mode 100644
index 000000000..ee7e1e34b
--- /dev/null
+++ b/program/include/rcube_message_header.php
@@ -0,0 +1,238 @@
+<?php
+
+/**
+ +-----------------------------------------------------------------------+
+ | program/include/rcube_message_header.php |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2005-2012, The Roundcube Dev Team |
+ | Copyright (C) 2011-2012, Kolab Systems AG |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | E-mail message headers representation |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+/**
+ * Struct representing an e-mail message header
+ *
+ * @package Mail
+ * @author Aleksander Machniak <alec@alec.pl>
+ */
+class rcube_message_header
+{
+ /**
+ * Message sequence number
+ *
+ * @var int
+ */
+ public $id;
+
+ /**
+ * Message unique identifier
+ *
+ * @var int
+ */
+ public $uid;
+
+ /**
+ * Message subject
+ *
+ * @var string
+ */
+ public $subject;
+
+ /**
+ * Message sender (From)
+ *
+ * @var string
+ */
+ public $from;
+
+ /**
+ * Message recipient (To)
+ *
+ * @var string
+ */
+ public $to;
+
+ /**
+ * Message additional recipients (Cc)
+ *
+ * @var string
+ */
+ public $cc;
+
+ /**
+ * Message Reply-To header
+ *
+ * @var string
+ */
+ public $replyto;
+
+ /**
+ * Message In-Reply-To header
+ *
+ * @var string
+ */
+ public $in_reply_to;
+
+ /**
+ * Message date (Date)
+ *
+ * @var string
+ */
+ public $date;
+
+ /**
+ * Message identifier (Message-ID)
+ *
+ * @var string
+ */
+ public $messageID;
+
+ /**
+ * Message size
+ *
+ * @var int
+ */
+ public $size;
+
+ /**
+ * Message encoding
+ *
+ * @var string
+ */
+ public $encoding;
+
+ /**
+ * Message charset
+ *
+ * @var string
+ */
+ public $charset;
+
+ /**
+ * Message Content-type
+ *
+ * @var string
+ */
+ public $ctype;
+
+ /**
+ * Message timestamp (based on message date)
+ *
+ * @var int
+ */
+ public $timestamp;
+
+ /**
+ * IMAP bodystructure string
+ *
+ * @var string
+ */
+ public $bodystructure;
+
+ /**
+ * IMAP internal date
+ *
+ * @var string
+ */
+ public $internaldate;
+
+ /**
+ * Message References header
+ *
+ * @var string
+ */
+ public $references;
+
+ /**
+ * Message priority (X-Priority)
+ *
+ * @var int
+ */
+ public $priority;
+
+ /**
+ * Message receipt recipient
+ *
+ * @var string
+ */
+ public $mdn_to;
+
+ /**
+ * Other message headers
+ *
+ * @var array
+ */
+ public $others = array();
+
+ /**
+ * Message flags
+ *
+ * @var array
+ */
+ public $flags = array();
+}
+
+
+/**
+ * Class for sorting an array of rcube_message_header objects in a predetermined order.
+ *
+ * @package Mail
+ * @author Aleksander Machniak <alec@alec.pl>
+ */
+class rcube_message_header_sorter
+{
+ private $uids = array();
+
+
+ /**
+ * Set the predetermined sort order.
+ *
+ * @param array $index Numerically indexed array of IMAP UIDs
+ */
+ function set_index($index)
+ {
+ $index = array_flip($index);
+
+ $this->uids = $index;
+ }
+
+ /**
+ * Sort the array of header objects
+ *
+ * @param array $headers Array of rcube_message_header objects indexed by UID
+ */
+ function sort_headers(&$headers)
+ {
+ uksort($headers, array($this, "compare_uids"));
+ }
+
+ /**
+ * Sort method called by uksort()
+ *
+ * @param int $a Array key (UID)
+ * @param int $b Array key (UID)
+ */
+ function compare_uids($a, $b)
+ {
+ // then find each sequence number in my ordered list
+ $posa = isset($this->uids[$a]) ? intval($this->uids[$a]) : -1;
+ $posb = isset($this->uids[$b]) ? intval($this->uids[$b]) : -1;
+
+ // return the relative position as the comparison value
+ return $posa - $posb;
+ }
+}