[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Copyright 2012-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 2012-2014 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Imap_Client 12 */ 13 14 /** 15 * An object allowing management of mailbox state within a 16 * Horde_Imap_Client_Base object. 17 * 18 * NOTE: This class is NOT intended to be accessed outside of a Base object. 19 * There is NO guarantees that the API of this class will not change across 20 * versions. 21 * 22 * @author Michael Slusarz <slusarz@horde.org> 23 * @category Horde 24 * @copyright 2012-2014 Horde LLC 25 * @internal 26 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 27 * @package Imap_Client 28 */ 29 class Horde_Imap_Client_Base_Mailbox 30 { 31 /** 32 * Mapping object. 33 * 34 * @var Horde_Imap_Client_Ids_Map 35 */ 36 public $map; 37 38 /** 39 * Is mailbox opened? 40 * 41 * @var boolean 42 */ 43 public $open; 44 45 /** 46 * Is mailbox sync'd with remote server (via CONDSTORE/QRESYNC)? 47 * 48 * @var boolean 49 */ 50 public $sync; 51 52 /** 53 * Status information. 54 * 55 * @var array 56 */ 57 protected $_status = array(); 58 59 /** 60 * Constructor. 61 */ 62 public function __construct() 63 { 64 $this->reset(); 65 } 66 67 /** 68 * Get status information for the mailbox. 69 * 70 * @param integer $entry STATUS_* constant. 71 * 72 * @return mixed Status information. 73 */ 74 public function getStatus($entry) 75 { 76 if (isset($this->_status[$entry])) { 77 return $this->_status[$entry]; 78 } 79 80 switch ($entry) { 81 case Horde_Imap_Client::STATUS_FIRSTUNSEEN: 82 /* If we know there are no messages in the current mailbox, we 83 * know there are no unseen messages. */ 84 return empty($this->_status[Horde_Imap_Client::STATUS_MESSAGES]) 85 ? false 86 : null; 87 88 case Horde_Imap_Client::STATUS_RECENT_TOTAL: 89 case Horde_Imap_Client::STATUS_SYNCMODSEQ: 90 return 0; 91 92 case Horde_Imap_Client::STATUS_SYNCFLAGUIDS: 93 case Horde_Imap_Client::STATUS_SYNCVANISHED: 94 return array(); 95 96 case Horde_Imap_Client::STATUS_PERMFLAGS: 97 /* If PERMFLAGS is not returned by server, must assume that all 98 * flags can be change permanently (RFC 3501 [6.3.1]). */ 99 $flags = isset($this->_status[Horde_Imap_Client::STATUS_FLAGS]) 100 ? $this->_status[Horde_Imap_Client::STATUS_FLAGS] 101 : array(); 102 $flags[] = "\\*"; 103 return $flags; 104 105 case Horde_Imap_Client::STATUS_UIDNOTSTICKY: 106 /* In the absence of explicit uidnotsticky identification, assume 107 * that UIDs are sticky. */ 108 return false; 109 110 case Horde_Imap_Client::STATUS_UNSEEN: 111 /* If we know there are no messages in the current mailbox, we 112 * know there are no unseen messages . */ 113 return empty($this->_status[Horde_Imap_Client::STATUS_MESSAGES]) 114 ? 0 115 : null; 116 117 default: 118 return null; 119 } 120 } 121 122 /** 123 * Set status information for the mailbox. 124 * 125 * @param integer $entry STATUS_* constant. 126 * @param mixed $value Status information. 127 */ 128 public function setStatus($entry, $value) 129 { 130 switch ($entry) { 131 case Horde_Imap_Client::STATUS_FIRSTUNSEEN: 132 case Horde_Imap_Client::STATUS_HIGHESTMODSEQ: 133 case Horde_Imap_Client::STATUS_MESSAGES: 134 case Horde_Imap_Client::STATUS_UNSEEN: 135 case Horde_Imap_Client::STATUS_UIDNEXT: 136 case Horde_Imap_Client::STATUS_UIDVALIDITY: 137 $value = intval($value); 138 break; 139 140 case Horde_Imap_Client::STATUS_RECENT: 141 /* Keep track of RECENT_TOTAL information. */ 142 $this->_status[Horde_Imap_Client::STATUS_RECENT_TOTAL] = isset($this->_status[Horde_Imap_Client::STATUS_RECENT_TOTAL]) 143 ? ($this->_status[Horde_Imap_Client::STATUS_RECENT_TOTAL] + $value) 144 : intval($value); 145 break; 146 147 case Horde_Imap_Client::STATUS_SYNCMODSEQ: 148 /* This is only set once per access. */ 149 if (isset($this->_status[$entry])) { 150 return; 151 } 152 $value = intval($value); 153 break; 154 155 case Horde_Imap_Client::STATUS_SYNCFLAGUIDS: 156 case Horde_Imap_Client::STATUS_SYNCVANISHED: 157 if (!isset($this->_status[$entry])) { 158 $this->_status[$entry] = array(); 159 } 160 $this->_status[$entry] = array_merge($this->_status[$entry], $value); 161 return; 162 } 163 164 $this->_status[$entry] = $value; 165 } 166 167 /** 168 * Reset the mailbox information. 169 */ 170 public function reset() 171 { 172 $keep = array( 173 Horde_Imap_Client::STATUS_SYNCFLAGUIDS, 174 Horde_Imap_Client::STATUS_SYNCMODSEQ, 175 Horde_Imap_Client::STATUS_SYNCVANISHED 176 ); 177 178 foreach (array_diff(array_keys($this->_status), $keep) as $val) { 179 unset($this->_status[$val]); 180 } 181 182 $this->map = new Horde_Imap_Client_Ids_Map(); 183 $this->open = $this->sync = false; 184 } 185 186 }
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 |