← All changes
|
back/Libraries/Imap2/Roundcube/MessageHeader.php
+0
-278
11.0.2
→
11.1.1
View file →
| @@ -1,278 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * +-----------------------------------------------------------------------+ | |
| 5 | - * | This file is part of the Roundcube Webmail client | | |
| 6 | - * | | | |
| 7 | - * | Copyright (C) The Roundcube Dev Team | | |
| 8 | - * | Copyright (C) Kolab Systems AG | | |
| 9 | - * | | | |
| 10 | - * | Licensed under the GNU General Public License version 3 or | | |
| 11 | - * | any later version with exceptions for skins & plugins. | | |
| 12 | - * | See the README file for a full license statement. | | |
| 13 | - * | | | |
| 14 | - * | PURPOSE: | | |
| 15 | - * | E-mail message headers representation | | |
| 16 | - * +-----------------------------------------------------------------------+ | |
| 17 | - * | Author: Aleksander Machniak <[email protected]> | | |
| 18 | - * +-----------------------------------------------------------------------+ | |
| 19 | - */ | |
| 20 | - | |
| 21 | -namespace AcyMailing\Libraries\Imap2\Roundcube; | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * Struct representing an e-mail message header | |
| 25 | - * | |
| 26 | - * @package Framework | |
| 27 | - * @subpackage Storage | |
| 28 | - */ | |
| 29 | -class MessageHeader | |
| 30 | -{ | |
| 31 | - /** | |
| 32 | - * Message sequence number | |
| 33 | - * | |
| 34 | - * @var int | |
| 35 | - */ | |
| 36 | - public $id; | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Message unique identifier | |
| 40 | - * | |
| 41 | - * @var int | |
| 42 | - */ | |
| 43 | - public $uid; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Message subject | |
| 47 | - * | |
| 48 | - * @var string | |
| 49 | - */ | |
| 50 | - public $subject; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Message sender (From) | |
| 54 | - * | |
| 55 | - * @var string | |
| 56 | - */ | |
| 57 | - public $from; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Message recipient (To) | |
| 61 | - * | |
| 62 | - * @var string | |
| 63 | - */ | |
| 64 | - public $to; | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Message additional recipients (Cc) | |
| 68 | - * | |
| 69 | - * @var string | |
| 70 | - */ | |
| 71 | - public $cc; | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * Message Reply-To header | |
| 75 | - * | |
| 76 | - * @var string | |
| 77 | - */ | |
| 78 | - public $replyto; | |
| 79 | - | |
| 80 | - /** | |
| 81 | - * Message In-Reply-To header | |
| 82 | - * | |
| 83 | - * @var string | |
| 84 | - */ | |
| 85 | - public $in_reply_to; | |
| 86 | - | |
| 87 | - /** | |
| 88 | - * Message date (Date) | |
| 89 | - * | |
| 90 | - * @var string | |
| 91 | - */ | |
| 92 | - public $date; | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * Message identifier (Message-ID) | |
| 96 | - * | |
| 97 | - * @var string | |
| 98 | - */ | |
| 99 | - public $messageID; | |
| 100 | - | |
| 101 | - /** | |
| 102 | - * Message size | |
| 103 | - * | |
| 104 | - * @var int | |
| 105 | - */ | |
| 106 | - public $size; | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * Message encoding | |
| 110 | - * | |
| 111 | - * @var string | |
| 112 | - */ | |
| 113 | - public $encoding; | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * Message charset | |
| 117 | - * | |
| 118 | - * @var string | |
| 119 | - */ | |
| 120 | - public $charset; | |
| 121 | - | |
| 122 | - /** | |
| 123 | - * Message Content-type | |
| 124 | - * | |
| 125 | - * @var string | |
| 126 | - */ | |
| 127 | - public $ctype; | |
| 128 | - | |
| 129 | - /** | |
| 130 | - * Message timestamp (based on message date) | |
| 131 | - * | |
| 132 | - * @var int | |
| 133 | - */ | |
| 134 | - public $timestamp; | |
| 135 | - | |
| 136 | - /** | |
| 137 | - * IMAP bodystructure string | |
| 138 | - * | |
| 139 | - * @var string | |
| 140 | - */ | |
| 141 | - public $bodystructure; | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * IMAP internal date | |
| 145 | - * | |
| 146 | - * @var string | |
| 147 | - */ | |
| 148 | - public $internaldate; | |
| 149 | - | |
| 150 | - /** | |
| 151 | - * Message References header | |
| 152 | - * | |
| 153 | - * @var string | |
| 154 | - */ | |
| 155 | - public $references; | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * Message priority (X-Priority) | |
| 159 | - * | |
| 160 | - * @var int | |
| 161 | - */ | |
| 162 | - public $priority; | |
| 163 | - | |
| 164 | - /** | |
| 165 | - * Message receipt recipient | |
| 166 | - * | |
| 167 | - * @var string | |
| 168 | - */ | |
| 169 | - public $mdn_to; | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * IMAP folder this message is stored in | |
| 173 | - * | |
| 174 | - * @var string | |
| 175 | - */ | |
| 176 | - public $folder; | |
| 177 | - | |
| 178 | - /** | |
| 179 | - * Other message headers | |
| 180 | - * | |
| 181 | - * @var array | |
| 182 | - */ | |
| 183 | - public $others = []; | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * Message flags | |
| 187 | - * | |
| 188 | - * @var array | |
| 189 | - */ | |
| 190 | - public $flags = []; | |
| 191 | - | |
| 192 | - public $envelope; | |
| 193 | - public array $bodypart = []; | |
| 194 | - | |
| 195 | - // map header to MessageHeader object property | |
| 196 | - private $obj_headers = [ | |
| 197 | - 'date' => 'date', | |
| 198 | - 'from' => 'from', | |
| 199 | - 'to' => 'to', | |
| 200 | - 'subject' => 'subject', | |
| 201 | - 'reply-to' => 'replyto', | |
| 202 | - 'cc' => 'cc', | |
| 203 | - 'bcc' => 'bcc', | |
| 204 | - 'mbox' => 'folder', | |
| 205 | - 'folder' => 'folder', | |
| 206 | - 'content-transfer-encoding' => 'encoding', | |
| 207 | - 'in-reply-to' => 'in_reply_to', | |
| 208 | - 'content-type' => 'ctype', | |
| 209 | - 'charset' => 'charset', | |
| 210 | - 'references' => 'references', | |
| 211 | - 'return-receipt-to' => 'mdn_to', | |
| 212 | - 'disposition-notification-to' => 'mdn_to', | |
| 213 | - 'x-confirm-reading-to' => 'mdn_to', | |
| 214 | - 'message-id' => 'messageID', | |
| 215 | - 'x-priority' => 'priority', | |
| 216 | - ]; | |
| 217 | - | |
| 218 | - /** | |
| 219 | - * Returns header value | |
| 220 | - */ | |
| 221 | - public function get($name, $decode = true) | |
| 222 | - { | |
| 223 | - $name = strtolower($name); | |
| 224 | - | |
| 225 | - if (isset($this->obj_headers[$name])) { | |
| 226 | - $value = $this->{$this->obj_headers[$name]}; | |
| 227 | - } else { | |
| 228 | - $value = $this->others[$name]; | |
| 229 | - } | |
| 230 | - | |
| 231 | - if ($decode) { | |
| 232 | - if (is_array($value)) { | |
| 233 | - foreach ($value as $key => $val) { | |
| 234 | - $val = Mime::decode_header($val, $this->charset); | |
| 235 | - $value[$key] = Charset::clean($val); | |
| 236 | - } | |
| 237 | - } else { | |
| 238 | - $value = Mime::decode_header($value, $this->charset); | |
| 239 | - $value = Charset::clean($value); | |
| 240 | - } | |
| 241 | - } | |
| 242 | - | |
| 243 | - return $value; | |
| 244 | - } | |
| 245 | - | |
| 246 | - /** | |
| 247 | - * Sets header value | |
| 248 | - */ | |
| 249 | - public function set($name, $value) | |
| 250 | - { | |
| 251 | - $name = strtolower($name); | |
| 252 | - | |
| 253 | - if (isset($this->obj_headers[$name])) { | |
| 254 | - $this->{$this->obj_headers[$name]} = $value; | |
| 255 | - } else { | |
| 256 | - $this->others[$name] = $value; | |
| 257 | - } | |
| 258 | - } | |
| 259 | - | |
| 260 | - | |
| 261 | - /** | |
| 262 | - * Factory method to instantiate headers from a data array | |
| 263 | - * | |
| 264 | - * @param array Hash array with header values | |
| 265 | - * | |
| 266 | - * @return object MessageHeader instance filled with headers values | |
| 267 | - */ | |
| 268 | - public static function from_array($arr) | |
| 269 | - { | |
| 270 | - $obj = new MessageHeader; | |
| 271 | - foreach ($arr as $k => $v) { | |
| 272 | - $obj->set($k, $v); | |
| 273 | - } | |
| 274 | - | |
| 275 | - return $obj; | |
| 276 | - } | |
| 277 | -} | |
| 278 | - | |