See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 /** 3 * Copyright 2011-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file LICENSE 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-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Imap_Client 12 */ 13 14 /** 15 * An object that provides a way to switch between UTF7-IMAP and 16 * human-readable representations of a mailbox name. 17 * 18 * @author Michael Slusarz <slusarz@horde.org> 19 * @category Horde 20 * @copyright 2011-2017 Horde LLC 21 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 * @package Imap_Client 23 * 24 * @property-read string $list_escape Escapes mailbox for use in LIST 25 * command (UTF-8). 26 * @property-read string $utf7imap Mailbox in UTF7-IMAP. 27 * @property-read string $utf8 Mailbox in UTF-8. 28 */ 29 class Horde_Imap_Client_Mailbox implements Serializable 30 { 31 /** 32 * UTF7-IMAP representation of mailbox. 33 * If boolean true, it is identical to UTF-8 representation. 34 * 35 * @var mixed 36 */ 37 protected $_utf7imap; 38 39 /** 40 * UTF8 representation of mailbox. 41 * 42 * @var string 43 */ 44 protected $_utf8; 45 46 /** 47 * Shortcut to obtaining mailbox object. 48 * 49 * @param string $mbox The mailbox name. 50 * @param boolean $utf7imap Is mailbox UTF7-IMAP encoded? Otherwise, 51 * mailbox is assumed to be UTF-8. 52 * 53 * @return Horde_Imap_Client_Mailbox A mailbox object. 54 */ 55 public static function get($mbox, $utf7imap = false) 56 { 57 return ($mbox instanceof Horde_Imap_Client_Mailbox) 58 ? $mbox 59 : new Horde_Imap_Client_Mailbox($mbox, $utf7imap); 60 } 61 62 /** 63 * Constructor. 64 * 65 * @param string $mbox The mailbox name. 66 * @param boolean $utf7imap Is mailbox UTF7-IMAP encoded (true). 67 * Otherwise, mailbox is assumed to be UTF-8 68 * encoded. 69 */ 70 public function __construct($mbox, $utf7imap = false) 71 { 72 if (strcasecmp($mbox, 'INBOX') === 0) { 73 $mbox = 'INBOX'; 74 } 75 76 if ($utf7imap) { 77 $this->_utf7imap = $mbox; 78 } else { 79 $this->_utf8 = $mbox; 80 } 81 } 82 83 /** 84 */ 85 public function __get($name) 86 { 87 switch ($name) { 88 case 'list_escape': 89 return preg_replace("/\*+/", '%', $this->utf8); 90 91 case 'utf7imap': 92 if (!isset($this->_utf7imap)) { 93 $n = Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($this->_utf8); 94 $this->_utf7imap = ($n == $this->_utf8) 95 ? true 96 : $n; 97 } 98 99 return ($this->_utf7imap === true) 100 ? $this->_utf8 101 : $this->_utf7imap; 102 103 case 'utf8': 104 if (!isset($this->_utf8)) { 105 $this->_utf8 = Horde_Imap_Client_Utf7imap::Utf7ImapToUtf8($this->_utf7imap); 106 if ($this->_utf8 == $this->_utf7imap) { 107 $this->_utf7imap = true; 108 } 109 } 110 return (string)$this->_utf8; 111 } 112 } 113 114 /** 115 */ 116 public function __toString() 117 { 118 return $this->utf8; 119 } 120 121 /** 122 * Compares this mailbox to another mailbox string. 123 * 124 * @return boolean True if the items are equal. 125 */ 126 public function equals($mbox) 127 { 128 return ($this->utf8 == $mbox); 129 } 130 131 /* Serializable methods. */ 132 133 /** 134 */ 135 public function serialize() 136 { 137 return serialize($this->__serialize()); 138 } 139 140 /** 141 */ 142 public function unserialize($data) 143 { 144 $data = @unserialize($data); 145 if (!is_array($data)) { 146 throw new Exception('Cache value changed.'); 147 } 148 $this->__unserialize($data); 149 } 150 151 /** 152 * @return array 153 */ 154 public function __serialize() 155 { 156 return [$this->_utf7imap, $this->_utf8]; 157 } 158 159 public function __unserialize(array $data) 160 { 161 list($this->_utf7imap, $this->_utf8) = $data; 162 } 163 164 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body