[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Copyright 2011-2014 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2011-2014 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Imap_Client 12 */ 13 14 /** 15 * Envelope data as returned by the IMAP FETCH command (RFC 3501 [7.4.2]). 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @category Horde 19 * @copyright 2011-2014 Horde LLC 20 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 * @package Imap_Client 22 * 23 * @property Horde_Mail_Rfc822_List $bcc Bcc address(es). 24 * @property Horde_Mail_Rfc822_List $cc Cc address(es). 25 * @property Horde_Imap_Client_DateTime $date IMAP internal date. 26 * @property Horde_Mail_Rfc822_List $from From address(es). 27 * @property string $in_reply_to Message-ID of the message replied to. 28 * @property string $message_id Message-ID of the message. 29 * @property Horde_Mail_Rfc822_List $reply_to Reply-to address(es). 30 * @property Horde_Mail_Rfc822_List $sender Sender address. 31 * @property string $subject Subject. 32 * @property Horde_Mail_Rfc822_List $to To address(es). 33 */ 34 class Horde_Imap_Client_Data_Envelope implements Serializable 35 { 36 /** Serializable version. */ 37 const VERSION = 2; 38 39 /** 40 * Data object. 41 * 42 * @var Horde_Mime_Headers 43 */ 44 protected $_data; 45 46 /** 47 * Constructor. 48 * 49 * @var array $data An array of property names (keys) and values to set 50 * in this object. 51 */ 52 public function __construct(array $data = array()) 53 { 54 $this->_data = new Horde_Mime_Headers(); 55 56 foreach ($data as $key => $val) { 57 $this->$key = $val; 58 } 59 } 60 61 /** 62 */ 63 public function __get($name) 64 { 65 switch ($name) { 66 case 'reply_to': 67 $name = 'reply-to'; 68 // Fall-through 69 70 case 'bcc': 71 case 'cc': 72 case 'from': 73 case 'sender': 74 case 'to': 75 if (($ob = $this->_data->getOb($name)) !== null) { 76 return $ob; 77 } 78 79 if (in_array($name, array('sender', 'reply-to'))) { 80 return $this->from; 81 } 82 break; 83 84 case 'date': 85 if (($val = $this->_data->getValue($name)) !== null) { 86 return new Horde_Imap_Client_DateTime($val); 87 } 88 break; 89 90 case 'in_reply_to': 91 case 'message_id': 92 case 'subject': 93 if (($val = $this->_data->getValue($name)) !== null) { 94 return $val; 95 } 96 break; 97 } 98 99 // Default values. 100 switch ($name) { 101 case 'bcc': 102 case 'cc': 103 case 'from': 104 case 'to': 105 return new Horde_Mail_Rfc822_List(); 106 107 case 'date': 108 return new Horde_Imap_Client_DateTime(); 109 110 case 'in_reply_to': 111 case 'message_id': 112 case 'subject': 113 return ''; 114 } 115 116 return null; 117 } 118 119 /** 120 */ 121 public function __set($name, $value) 122 { 123 if (!strlen($value)) { 124 return; 125 } 126 127 switch ($name) { 128 case 'bcc': 129 case 'cc': 130 case 'date': 131 case 'from': 132 case 'in_reply_to': 133 case 'message_id': 134 case 'reply_to': 135 case 'sender': 136 case 'subject': 137 case 'to': 138 switch ($name) { 139 case 'from': 140 foreach (array('reply_to', 'sender') as $val) { 141 if ($this->$val->match($value)) { 142 $this->_data->removeHeader($val); 143 } 144 } 145 break; 146 147 case 'reply_to': 148 case 'sender': 149 if ($this->from->match($value)) { 150 $this->_data->removeHeader($name); 151 return; 152 } 153 154 /* Convert reply-to name. */ 155 if ($name == 'reply_to') { 156 $name = 'reply-to'; 157 } 158 break; 159 } 160 161 $this->_data->addHeader($name, $value, array( 162 'sanity_check' => true 163 )); 164 break; 165 } 166 } 167 168 /** 169 */ 170 public function __isset($name) 171 { 172 switch ($name) { 173 case 'reply_to': 174 $name = 'reply-to'; 175 // Fall-through 176 177 case 'sender': 178 if ($this->_data->getValue($name) !== null) { 179 return true; 180 } 181 $name = 'from'; 182 break; 183 } 184 185 return ($this->_data->getValue($name) !== null); 186 } 187 188 /* Serializable methods. */ 189 190 /** 191 */ 192 public function serialize() 193 { 194 return serialize(array( 195 'd' => $this->_data, 196 'v' => self::VERSION 197 )); 198 } 199 200 /** 201 */ 202 public function unserialize($data) 203 { 204 $data = @unserialize($data); 205 if (empty($data['v']) || ($data['v'] != self::VERSION)) { 206 throw new Exception('Cache version change'); 207 } 208 209 $this->_data = $data['d']; 210 } 211 212 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |