Mail/Storage/Writable/Maildir.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Mail  
Subpackage
Storage  
Version
$Id: Maildir.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Mail_Storage_Writable_Maildir

Package: Zend\Mail\Storage
Implements
\Zend_Mail_Storage_Writable_Interface
Parent(s)
\Zend_Mail_Storage_Folder_Maildir < \Zend_Mail_Storage_Maildir < \Zend_Mail_Storage_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedstring $_currentFolder
inherited
name of current folder
Inherited from: \Zend_Mail_Storage_Folder_Maildir::$$_currentFolder
Details
Type
string
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_currentFolder  
>VPropertyprotectedstring $_delim
inherited
delim char for subfolders
Inherited from: \Zend_Mail_Storage_Folder_Maildir::$$_delim
Details
Type
string
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_delim  
>VPropertyprotectedarray $_files = array()
inherited
data of found message files in maildir dir
Inherited from: \Zend_Mail_Storage_Maildir::$$_files\Zend_Mail_Storage_Folder_Maildir::$$_files
Default valuearray()Details
Type
array
Inherited_from
\Zend_Mail_Storage_Maildir::$$_files  
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_files  
>VPropertyprotectedarray $_has = array('uniqueid' => true, 'delete' => false, 'create' => false, 'top' => false, 'fetchPart' => true, 'flags' => false)
Default valuearray('uniqueid' => true, 'delete' => false, 'create' => false, 'top' => false, 'fetchPart' => true, 'flags' => false)Details
Type
array
Inherited_from
\Zend_Mail_Storage_Abstract::$$_has  
Inherited_from
\Zend_Mail_Storage_Maildir::$$_has  
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_has  
>VPropertyprotectednull|int $_iterationMax = null
Default valuenullDetails
Type
null | int
Inherited_from
\Zend_Mail_Storage_Abstract::$$_iterationMax  
Inherited_from
\Zend_Mail_Storage_Maildir::$$_iterationMax  
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_iterationMax  
>VPropertyprotectedarray $_knownFlags = array('D' => \Zend_Mail_Storage::FLAG_DRAFT, 'F' => \Zend_Mail_Storage::FLAG_FLAGGED, 'P' => \Zend_Mail_Storage::FLAG_PASSED, 'R' => \Zend_Mail_Storage::FLAG_ANSWERED, 'S' => \Zend_Mail_Storage::FLAG_SEEN, 'T' => \Zend_Mail_Storage::FLAG_DELETED)
staticinherited
known flag chars in filenames
Inherited from: \Zend_Mail_Storage_Maildir::$$_knownFlags\Zend_Mail_Storage_Folder_Maildir::$$_knownFlags

This list has to be in alphabetical order for setFlags()

Default valuearray('D' => \Zend_Mail_Storage::FLAG_DRAFT, 'F' => \Zend_Mail_Storage::FLAG_FLAGGED, 'P' => \Zend_Mail_Storage::FLAG_PASSED, 'R' => \Zend_Mail_Storage::FLAG_ANSWERED, 'S' => \Zend_Mail_Storage::FLAG_SEEN, 'T' => \Zend_Mail_Storage::FLAG_DELETED)Details
Type
array
Inherited_from
\Zend_Mail_Storage_Maildir::$$_knownFlags  
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_knownFlags  
>VPropertyprotectedstring $_messageClass = 'Zend_Mail_Message_File'
inherited
used message class, change it in an extened class to extend the returned message class
Inherited from: \Zend_Mail_Storage_Maildir::$$_messageClass\Zend_Mail_Storage_Folder_Maildir::$$_messageClass
Default value'Zend_Mail_Message_File'Details
Type
string
Inherited_from
\Zend_Mail_Storage_Maildir::$$_messageClass  
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_messageClass  
>VPropertyprotectedbool|int $_quota
use quota and size of quota if given
Details
Type
bool | int
>VPropertyprotected\Zend_Mail_Storage_Folder $_rootFolder
inherited
Zend_Mail_Storage_Folder root folder for folder structure
Inherited from: \Zend_Mail_Storage_Folder_Maildir::$$_rootFolder
>VPropertyprotectedstring $_rootdir
inherited
rootdir of folder structure
Inherited from: \Zend_Mail_Storage_Folder_Maildir::$$_rootdir
Details
Type
string
Inherited_from
\Zend_Mail_Storage_Folder_Maildir::$$_rootdir  

Methods

methodpublic__construct(array $params) : void

Create instance with parameters Additional parameters are (see parent for more): - create if true a new maildir is create if none exists

Parameters
NameTypeDescription
$paramsarray

mail reader specific parameters

Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublic__destruct() : void
methodpublic__get(string $var) : bool

The standard has properties are: hasFolder, hasUniqueid, hasDelete, hasCreate, hasTop

The valid values for the has-properties are: - true if a feature is supported - false if a feature is not supported - null is it's not yet known or it can't be know if a feature is supported

Parameters
NameTypeDescription
$varstring

property name

Returns
TypeDescription
boolsupported or not
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodprotected_addQuotaEntry( $size,  $count = 1) : void

Parameters
NameTypeDescription
$size
$count
methodprotected_buildFolderTree() : null
inherited

find all subfolders and mbox files for folder structure

Inherited from: \Zend_Mail_Storage_Folder_Maildir::_buildFolderTree()

Result is save in Zend_Mail_Storage_Folder instances with the root in $this->_rootFolder. $parentFolder and $parentGlobalName are only used internally for recursion.

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodprotected_calculateMaildirsize() : void

Details
See
"Calculating maildirsize"  
methodprotected_calculateQuota( $forceRecalc = false) : void

Parameters
NameTypeDescription
$forceRecalc
Details
See
"Calculating the quota for a Maildir++"  
methodprotected_createTmpFile(string $folder = 'INBOX') : array

open a temporary maildir file

makes sure tmp/ exists and create a file with a unique name you should close the returned filehandle!

Parameters
NameTypeDescription
$folderstring

name of current folder without leading .

Returns
TypeDescription
arrayarray('dirname' => dir of maildir folder, 'uniq' => unique id, 'filename' => name of create file 'handle' => file opened for writing)
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodprotected_createUniqueId() : string

create a uniqueid for maildir filename

This is nearly the format defined in the maildir standard. The microtime() call should already create a uniqueid, the pid is for multicore/-cpu machine that manage to call this function at the exact same time, and uname() gives us the hostname for multiple machines accessing the same storage.

If someone disables posix we create a random number of the same size, so this method should also work on Windows - if you manage to get maildir working on Windows. Microtime could also be disabled, altough I've never seen it.

Returns
TypeDescription
stringnew uniqueid
methodprotected_getFileData(int $id, string | null $field = null) : string | array
inherited

Get one or all fields from file structure.

Inherited from: \Zend_Mail_Storage_Maildir::_getFileData()\Zend_Mail_Storage_Folder_Maildir::_getFileData()

Also checks if message is valid

Parameters
NameTypeDescription
$idint

message number

$fieldstring | null

wanted field

Returns
TypeDescription
string | arraywanted field or all fields as array
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodprotected_getInfoString(array $flags) : string

create an info string for filenames with given flags

Parameters
NameTypeDescription
$flagsarray

wanted flags, with the reference you'll get the set flags with correct key (= char for flag)

Returns
TypeDescription
stringinfo string for version 2 filenames including the leading colon
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodprotected_getMaildirFiles(resource $dh, string $dirname, array $default_flags = array()) : null
inherited

find all files in opened dir handle and add to maildir files

Inherited from: \Zend_Mail_Storage_Maildir::_getMaildirFiles()\Zend_Mail_Storage_Folder_Maildir::_getMaildirFiles()
Parameters
NameTypeDescription
$dhresource

dir handle used for search

$dirnamestring

dirname of dir in $dh

$default_flagsarray

default flags for given dir

Returns
TypeDescription
null
methodprotected_isMaildir(string $dirname) : bool
inherited

check if a given dir is a valid maildir

Inherited from: \Zend_Mail_Storage_Maildir::_isMaildir()\Zend_Mail_Storage_Folder_Maildir::_isMaildir()
Parameters
NameTypeDescription
$dirnamestring

name of dir

Returns
TypeDescription
booldir is valid maildir
methodprotected_openMaildir(string $dirname) : null
Parameters
NameTypeDescription
$dirnamestring

name of maildir

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicappendMessage(string | \Zend_Mail_Message | \Zend_Mime_Message $message, null | string | \Zend_Mail_Storage_Folder $folder = null, null | array $flags = null,  $recent = false) : void

append a new message to mail storage

Parameters
NameTypeDescription
$messagestring | \Zend_Mail_Message | \Zend_Mime_Message

message as string or instance of message class

$foldernull | string | \Zend_Mail_Storage_Folder

folder for new message, else current folder is taken

$flagsnull | array

set flags for new message, else a default set is used

$recent
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpubliccheckQuota(bool $detailedResponse = false,  $forceRecalc = false) : bool | array

check if storage is currently over quota

Parameters
NameTypeDescription
$detailedResponsebool

return known data of quota and current size and message count @see _calculateQuota()

$forceRecalc
Returns
TypeDescription
bool | arrayover quota state or detailed response
methodpublicclose() : void
inherited

Close resource for mail lib.

Inherited from: \Zend_Mail_Storage_Maildir::close()\Zend_Mail_Storage_Folder_Maildir::close()

If you need to control, when the resource is closed. Otherwise the destructor would call this.

methodpubliccopyMessage(int $id, string | \Zend_Mail_Storage_Folder $folder) : null

copy an existing message

Parameters
NameTypeDescription
$idint

number of message

$folderstring | \Zend_Mail_Storage_Folder

name or instance of targer folder

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpubliccount() : int
Returns
TypeDescription
int
methodpubliccountMessages( $flags = null) : int
inherited

Count messages all messages in current box

Inherited from: \Zend_Mail_Storage_Maildir::countMessages()\Zend_Mail_Storage_Folder_Maildir::countMessages()
Parameters
NameTypeDescription
$flags
Returns
TypeDescription
intnumber of messages
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpubliccreateFolder(string $name, string | \Zend_Mail_Storage_Folder $parentFolder = null) : string

create a new folder

This method also creates parent folders if necessary. Some mail storages may restrict, which folder may be used as parent or which chars may be used in the folder name

Parameters
NameTypeDescription
$namestring

global name of folder, local name if $parentFolder is set

$parentFolderstring | \Zend_Mail_Storage_Folder

parent folder for new folder, else root folder is parent

Returns
TypeDescription
stringonly used internally (new created maildir)
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetCapabilities() : array
inherited

Get a full list of features supported by the specific mail lib and the server

Inherited from: \Zend_Mail_Storage_Abstract::getCapabilities()\Zend_Mail_Storage_Maildir::getCapabilities()\Zend_Mail_Storage_Folder_Maildir::getCapabilities()
Returns
TypeDescription
arraylist of features as array(featurename => true|false[|null])
methodpublicgetCurrentFolder() : \Zend_Mail_Storage_Folder
inherited

get Zend_Mail_Storage_Folder instance for current folder

Inherited from: \Zend_Mail_Storage_Folder_Maildir::getCurrentFolder()
Returns
TypeDescription
\Zend_Mail_Storage_Folderinstance of current folder
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetFolders(string $rootFolder = null) : \Zend_Mail_Storage_Folder
inherited

get root folder or given folder

Inherited from: \Zend_Mail_Storage_Folder_Maildir::getFolders()
Parameters
NameTypeDescription
$rootFolderstring

get folder structure for given folder, else root

Returns
TypeDescription
\Zend_Mail_Storage_Folderroot or wanted folder
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetMessage(int $id) : \Zend_Mail_Message_File
Parameters
NameTypeDescription
$idint

number of message

Returns
TypeDescription
\Zend_Mail_Message_File
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetNumberByUniqueId(string $id) : int

I.e. if you have a webmailer that supports deleting messages you should use unique ids as parameter and use this method to translate it to message number right before calling removeMessage()

Parameters
NameTypeDescription
$idstring

unique id

Returns
TypeDescription
intmessage number
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetQuota( $fromStorage = false) : bool | array

get currently set quota

Parameters
NameTypeDescription
$fromStorage
Returns
TypeDescription
bool | array
Details
See
\Zend_Mail_Storage_Writable_Maildir::setQuota()  
methodpublicgetRawContent(int $id, null | array | string $part = null) : string
Parameters
NameTypeDescription
$idint

number of message

$partnull | array | string

path to part or null for messsage content

Returns
TypeDescription
stringraw content
methodpublicgetRawHeader(int $id, null | array | string $part = null, int $topLines = 0) : string
Parameters
NameTypeDescription
$idint

number of message

$partnull | array | string

path to part or null for messsage header

$topLinesint

include this many lines with header (after an empty line)

Returns
TypeDescription
stringraw header
methodpublicgetSize(int | null $id = null) : int | array
inherited

Get a list of messages with number and size

Inherited from: \Zend_Mail_Storage_Maildir::getSize()\Zend_Mail_Storage_Folder_Maildir::getSize()
Parameters
NameTypeDescription
$idint | null

number of message or null for all messages

Returns
TypeDescription
int | arraysize of given message of list with all messages as array(num => size)
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicgetUniqueId(int | null $id = null) : array | string
inherited

get unique id for one or all messages

Inherited from: \Zend_Mail_Storage_Maildir::getUniqueId()\Zend_Mail_Storage_Folder_Maildir::getUniqueId()

if storage does not support unique ids it's the same as the message number

Parameters
NameTypeDescription
$idint | null

message number

Returns
TypeDescription
array | stringmessage number for given message or all messages as array
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicinitMaildir(string $dir) : null
static

create a new maildir

If the given dir is already a valid maildir this will not fail.

Parameters
NameTypeDescription
$dirstring

directory for the new maildir (may already exist)

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublickey() : int
Returns
TypeDescription
intid of current position
methodpublicmoveMessage(int $id, string | \Zend_Mail_Storage_Folder $folder) : null

move an existing message

Parameters
NameTypeDescription
$idint

number of message

$folderstring | \Zend_Mail_Storage_Folder

name or instance of targer folder

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicnoop() : void
inherited

Waste some CPU cycles doing nothing.

Inherited from: \Zend_Mail_Storage_Maildir::noop()\Zend_Mail_Storage_Folder_Maildir::noop()
methodpublicoffsetExists(int $id) : boolean
Parameters
NameTypeDescription
$idint
Returns
TypeDescription
boolean
methodpublicoffsetGet(int $id) : \Zend_Mail_Message
Parameters
NameTypeDescription
$idint
Returns
TypeDescription
\Zend_Mail_Messagemessage object
methodpublicoffsetSet(\id $id, mixed $value) : void
Parameters
NameTypeDescription
$id\id
$valuemixed
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicoffsetUnset(int $id) : boolean
Parameters
NameTypeDescription
$idint
Returns
TypeDescription
booleansuccess
methodpublicremoveFolder(string | \Zend_Mail_Storage_Folder $name) : null

remove a folder

Parameters
NameTypeDescription
$namestring | \Zend_Mail_Storage_Folder

name or instance of folder

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicremoveMessage( $id) : null

stub for not supported message deletion

Parameters
NameTypeDescription
$id
Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicrenameFolder(string | \Zend_Mail_Storage_Folder $oldName, string $newName) : null

rename and/or move folder

The new name has the same restrictions as in createFolder()

Parameters
NameTypeDescription
$oldNamestring | \Zend_Mail_Storage_Folder

name or instance of folder

$newNamestring

new global name of folder

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicrewind() : void

Rewind always gets the new count from the storage. Thus if you use the interfaces and your scripts take long you should use reset() from time to time.

methodpublicseek(int $pos) : void
Parameters
NameTypeDescription
$posint
Throws
ExceptionDescription
\OutOfBoundsException
methodpublicselectFolder(\Zend_Mail_Storage_Folder | string $globalName) : null
inherited

select given folder

Inherited from: \Zend_Mail_Storage_Folder_Maildir::selectFolder()

folder must be selectable!

Parameters
NameTypeDescription
$globalName\Zend_Mail_Storage_Folder | string

global name of folder or instance for subfolder

Returns
TypeDescription
null
Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicsetFlags(int $id, array $flags) : void

set flags for message

NOTE: this method can't set the recent flag.

Parameters
NameTypeDescription
$idint

number of message

$flagsarray

new flags for message

Throws
ExceptionDescription
\Zend_Mail_Storage_Exception
methodpublicsetQuota(bool | array $value) : null

enable/disable quota and set a quota value if wanted or needed

You can enable/disable quota with true/false. If you don't have a MDA or want to enforce a quota value you can also set this value here. Use array('size' => SIZE_QUOTA, 'count' => MAX_MESSAGE) do define your quota. Order of these fields does matter!

Parameters
NameTypeDescription
$valuebool | array

new quota value

Returns
TypeDescription
null
methodpublicvalid() : boolean
Returns
TypeDescription
boolean
Documentation was generated by phpDocumentor 2.0.0a12.