/usr/share/php/Horde/Imap/Client/Fetch/Query.php is in php-horde-imap-client 2.25.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | <?php
/**
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2011-2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
/**
* Fetch query object for use with Horde_Imap_Client_Base#fetch().
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2011-2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Fetch_Query implements ArrayAccess, Countable, Iterator
{
/**
* Internal data array.
*
* @var array
*/
protected $_data = array();
/**
* Get the full text of the message.
*
* @param array $opts The following options are available:
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function fullText(array $opts = array())
{
$this->_data[Horde_Imap_Client::FETCH_FULLMSG] = $opts;
}
/**
* Return header text.
*
* Header text is defined only for the base RFC 2822 message or
* message/rfc822 parts.
*
* @param array $opts The following options are available:
* - id: (string) The MIME ID to obtain the header text for.
* DEFAULT: The header text for the base message will be
* returned.
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function headerText(array $opts = array())
{
$id = isset($opts['id'])
? $opts['id']
: 0;
$this->_data[Horde_Imap_Client::FETCH_HEADERTEXT][$id] = $opts;
}
/**
* Return body text.
*
* Body text is defined only for the base RFC 2822 message or
* message/rfc822 parts.
*
* @param array $opts The following options are available:
* - id: (string) The MIME ID to obtain the body text for.
* DEFAULT: The body text for the entire message will be
* returned.
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function bodyText(array $opts = array())
{
$id = isset($opts['id'])
? $opts['id']
: 0;
$this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] = $opts;
}
/**
* Return MIME header text.
*
* MIME header text is defined only for non-RFC 2822 messages and
* non-message/rfc822 parts.
*
* @param string $id The MIME ID to obtain the MIME header text for.
* @param array $opts The following options are available:
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function mimeHeader($id, array $opts = array())
{
$this->_data[Horde_Imap_Client::FETCH_MIMEHEADER][$id] = $opts;
}
/**
* Return the body part data for a MIME ID.
*
* @param string $id The MIME ID to obtain the body part text for.
* @param array $opts The following options are available:
* - decode: (boolean) Attempt to server-side decode the bodypart data
* if it is MIME transfer encoded.
* DEFAULT: false
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function bodyPart($id, array $opts = array())
{
$this->_data[Horde_Imap_Client::FETCH_BODYPART][$id] = $opts;
}
/**
* Returns the decoded body part size for a MIME ID.
*
* @param string $id The MIME ID to obtain the decoded body part size
* for.
*/
public function bodyPartSize($id)
{
$this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] = true;
}
/**
* Returns RFC 2822 header text that matches a search string.
*
* This header search work only with the base RFC 2822 message or
* message/rfc822 parts.
*
* @param string $label A unique label associated with this particular
* search. This is how the results are stored.
* @param array $search The search string(s) (case-insensitive).
* @param array $opts The following options are available:
* - cache: (boolean) If true, and 'peek' is also true, will cache
* the result of this call.
* DEFAULT: false
* - id: (string) The MIME ID to search.
* DEFAULT: The base message part
* - length: (integer) The length of the substring to return.
* DEFAULT: The entire text is returned.
* - notsearch: (boolean) Do a 'NOT' search on the headers.
* DEFAULT: false
* - peek: (boolean) If set, does not set the '\Seen' flag on the
* message.
* DEFAULT: The seen flag is set.
* - start: (integer) If a portion of the full text is desired to be
* returned, the starting position is identified here.
* DEFAULT: The entire text is returned.
*/
public function headers($label, $search, array $opts = array())
{
$this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = array_merge($opts, array(
'headers' => $search
));
}
/**
* Return MIME structure information.
*/
public function structure()
{
$this->_data[Horde_Imap_Client::FETCH_STRUCTURE] = true;
}
/**
* Return envelope header data.
*/
public function envelope()
{
$this->_data[Horde_Imap_Client::FETCH_ENVELOPE] = true;
}
/**
* Return flags set for the message.
*/
public function flags()
{
$this->_data[Horde_Imap_Client::FETCH_FLAGS] = true;
}
/**
* Return the internal (IMAP) date of the message.
*/
public function imapDate()
{
$this->_data[Horde_Imap_Client::FETCH_IMAPDATE] = true;
}
/**
* Return the size (in bytes) of the message.
*/
public function size()
{
$this->_data[Horde_Imap_Client::FETCH_SIZE] = true;
}
/**
* Return the unique ID of the message.
*/
public function uid()
{
$this->_data[Horde_Imap_Client::FETCH_UID] = true;
}
/**
* Return the sequence number of the message.
*/
public function seq()
{
$this->_data[Horde_Imap_Client::FETCH_SEQ] = true;
}
/**
* Return the mod-sequence value for the message.
*
* The server must support the CONDSTORE IMAP extension, and the mailbox
* must support mod-sequences.
*/
public function modseq()
{
$this->_data[Horde_Imap_Client::FETCH_MODSEQ] = true;
}
/**
* Does the query contain the given criteria?
*
* @param integer $criteria The criteria to remove.
*
* @return boolean True if the query contains the given criteria.
*/
public function contains($criteria)
{
return isset($this->_data[$criteria]);
}
/**
* Remove an entry under a given criteria.
*
* @param integer $criteria Criteria ID.
* @param string $key The key to remove.
*/
public function remove($criteria, $key)
{
if (isset($this->_data[$criteria]) &&
is_array($this->_data[$criteria])) {
unset($this->_data[$criteria][$key]);
if (empty($this->_data[$criteria])) {
unset($this->_data[$criteria]);
}
}
}
/**
* Returns a hash of the current query object.
*
* @return string Hash.
*/
public function hash()
{
return hash(
(PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
serialize($this)
);
}
/* ArrayAccess methods. */
/**
*/
public function offsetExists($offset)
{
return isset($this->_data[$offset]);
}
/**
*/
public function offsetGet($offset)
{
return isset($this->_data[$offset])
? $this->_data[$offset]
: null;
}
/**
*/
public function offsetSet($offset, $value)
{
$this->_data[$offset] = $value;
}
/**
*/
public function offsetUnset($offset)
{
unset($this->_data[$offset]);
}
/* Countable methods. */
/**
*/
public function count()
{
return count($this->_data);
}
/* Iterator methods. */
/**
*/
public function current()
{
$opts = current($this->_data);
return (!empty($opts) && ($this->key() == Horde_Imap_Client::FETCH_BODYPARTSIZE))
? array_keys($opts)
: $opts;
}
/**
*/
public function key()
{
return key($this->_data);
}
/**
*/
public function next()
{
next($this->_data);
}
/**
*/
public function rewind()
{
reset($this->_data);
}
/**
*/
public function valid()
{
return !is_null($this->key());
}
}
|