PHP Class IMP_Mailbox, horde

Author: Michael Slusarz ([email protected])
Exibir arquivo Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_mbox string The IMAP mailbox name (UTF-8).

Public Methods

Method Description
__construct ( $mbox ) Constructor.
__get ( $key )
__set ( $key, $value )
__toString ( )
create ( array $opts = [] ) : boolean Create this mailbox on the server.
createMailboxName ( string $new ) : IMP_Mailbox Return the mailbox name to create given a submailbox name.
delete ( array $opts = [] ) : boolean Deletes mailbox.
emptyMailbox ( ) Empties the entire mailbox.
equals ( mixed $mbox ) : boolean Determines if this mailbox is equal to the given mailbox.
expunge ( array $to_expunge = [], array $opts = [] ) : IMP_Indices Expunges all deleted messages.
filter ( ) Runs filters on this mailbox.
filterOnDisplay ( ) : boolean Filters this mailbox if it is the INBOX and the filter on display pref is active.
flagAll ( array $flags, boolean $action = true ) : boolean Adds or removes flag(s) for all messages in the mailbox.
formFrom ( mixed $mbox ) : mixed Converts a mailbox string from a form representation.
formTo ( mixed $mbox ) : mixed Converts a mailbox string to a form representation.
fromBuids ( IMP_Indices | array $buids ) : IMP_Indices Create an indices object from a list of browser-UIDs.
get ( mixed $mbox ) : mixed Shortcut to obtaining mailbox object(s).
getImapMboxOb ( mixed $mbox ) : mixed Shortcut to obtaining Horde_Imap_Client_Mailbox object(s).
getIndicesOb ( mixed $in ) : IMP_Indices Return an indices object for this mailbox.
getPref ( $pref ) : IMP_Mailbox Shortcut to obtaining a mailbox object from a preference name.
getSearchOb ( ) : IMP_Search_Query Return the search query object for this mailbox.
getSort ( boolean $convert = false ) : IMP_Prefs_Sort_Sortpref Return the sorting preference for this mailbox.
getSpecialMailboxes ( ) : array Return the list of special mailboxes.
getSpecialMailboxesSort ( ) : array Return the list of sorted special mailboxes.
hideDeletedMsgs ( boolean $deleted = false ) : boolean Are deleted messages hidden in this mailbox?
prefFrom ( string $mbox ) : string Converts a mailbox name from a value stored in the preferences.
prefTo ( string $mbox ) : string Converts a mailbox name to a value to be stored in a preference.
rename ( string $new_name ) : boolean Rename this mailbox on the server. The subscription status remains the same. All subfolders will also be renamed.
runSearchQuery ( Horde_Imap_Client_Search_Query $query, integer $sortby = null, integer $sortdir = null ) : IMP_Indices Run a search query on this mailbox that is not stored in the current session. Allows custom queries with custom sorts to be used without affecting cached mailboxes.
setHideDeletedMsgs ( boolean $value ) Sets the 'delhide' preference and clears necessary cached data.
setSort ( integer $by = null, integer $dir = null, boolean $delete = false ) Set the sorting preference for this mailbox.
subscribe ( boolean $sub, array $opts = [] ) : boolean Subscribe/unsubscribe to an IMAP mailbox.
toBuids ( IMP_Indices $uids ) : IMP_Indices Create a BUID indices object from a list of UIDs.
url ( string | Horde_Url $page, string $buid = null, boolean $encode = true ) : Horde_Url Generate a URL using the current mailbox.
urlParams ( string $buid = null ) : array Returns list of URL parameters necessary to indicate current mailbox status.

Protected Methods

Method Description
_getCacheID ( boolean $date = false ) : string Returns a unique identifier for this mailbox's status.
_getDisplay ( boolean $notranslate = false ) : string If there is information available to tell us about a prefix in front of mailbox names that shouldn't be displayed to the user, then use it to strip that prefix out. Additionally, translate prefix text if this is a special mailbox.
_getIcon ( ) : object Return icon information.
_onDelete ( array $deleted ) Do the necessary cleanup/cache updates when deleting mailboxes.

Method Details

__construct() public method

Constructor.
public __construct ( $mbox )

__get() public method

public __get ( $key )

__set() public method

public __set ( $key, $value )

__toString() public method

public __toString ( )

_getCacheID() protected method

This cache ID is guaranteed to change if messages are added/deleted from the mailbox. Additionally, if CONDSTORE is available on the remote IMAP server, this ID will change if flag information changes. For search mailboxes, this value never changes (search mailboxes must be forcibly refreshed).
protected _getCacheID ( boolean $date = false ) : string
$date boolean If true, adds date information to ID.
return string The cache ID string, which will change when the composition of this mailbox changes.

_getDisplay() protected method

If there is information available to tell us about a prefix in front of mailbox names that shouldn't be displayed to the user, then use it to strip that prefix out. Additionally, translate prefix text if this is a special mailbox.
protected _getDisplay ( boolean $notranslate = false ) : string
$notranslate boolean Don't translate the mailbox prefix?
return string The mailbox, with any prefix gone/translated.

_getIcon() protected method

Return icon information.
protected _getIcon ( ) : object
return object Object with the following properties: - alt - class - icon - iconopen - user_icon

_onDelete() protected method

Do the necessary cleanup/cache updates when deleting mailboxes.
protected _onDelete ( array $deleted )
$deleted array The list of deleted mailboxes.

create() public method

Create this mailbox on the server.
public create ( array $opts = [] ) : boolean
$opts array Additional options: - special_use: (array) An array of special-use attributes to attempt to add to the mailbox. DEFAULT: NONE - subscribe: (boolean) Override preference value of subscribe.
return boolean True on success.

createMailboxName() public method

Return the mailbox name to create given a submailbox name.
public createMailboxName ( string $new ) : IMP_Mailbox
$new string The submailbox name (UTF-8).
return IMP_Mailbox The mailbox to create.

delete() public method

Deletes mailbox.
public delete ( array $opts = [] ) : boolean
$opts array Addtional options: - subfolders: (boolean) Delete all subfolders? DEFAULT: false - subfolders_only: (boolean) If deleting subfolders, delete only subfolders (not current mailbox)? DEFAULT: false
return boolean True on success.

emptyMailbox() public method

Empties the entire mailbox.
public emptyMailbox ( )

equals() public method

Needed because directly comparing two mailbox objects may fail (the member variables may be different).
public equals ( mixed $mbox ) : boolean
$mbox mixed The mailbox to compare to.
return boolean True if the mailboxes are the same.

expunge() public method

Expunges all deleted messages.
public expunge ( array $to_expunge = [], array $opts = [] ) : IMP_Indices
$to_expunge array An optional array of indices to delete. If empty, all messages flagged as deleted in the mailbox will be deleted.
$opts array Additional options:
  - list: (boolean) Return a list of messages expunged.
          DEFAULT: false
return IMP_Indices If 'list' option is true, an indices object containing the messages that have been expunged.

filter() public method

Runs filters on this mailbox.
public filter ( )

filterOnDisplay() public method

Filters this mailbox if it is the INBOX and the filter on display pref is active.
public filterOnDisplay ( ) : boolean
return boolean True if filter() was called.

flagAll() public method

This function works with IMAP only, not POP3.
public flagAll ( array $flags, boolean $action = true ) : boolean
$flags array The IMAP flag(s) to add or remove.
$action boolean If true, add the flag(s); otherwise, remove the flag(s).
return boolean True if successful, false if not.

formFrom() public static method

Needed because null characters (used for various internal non-IMAP mailbox representations) will not work in form elements.
public static formFrom ( mixed $mbox ) : mixed
$mbox mixed The mailbox name(s).
return mixed The mailbox object(s).

formTo() public static method

Needed because null characters (used for various internal non-IMAP mailbox representations) will not work in form elements.
public static formTo ( mixed $mbox ) : mixed
$mbox mixed The mailbox name(s).
return mixed The converted mailbox string(s).

fromBuids() public method

Create an indices object from a list of browser-UIDs.
public fromBuids ( IMP_Indices | array $buids ) : IMP_Indices
$buids IMP_Indices | array Browser-UIDs.
return IMP_Indices An indices object.

get() public static method

Shortcut to obtaining mailbox object(s).
public static get ( mixed $mbox ) : mixed
$mbox mixed The full IMAP mailbox name(s).
return mixed The IMP_Mailbox object(s).

getImapMboxOb() public static method

Shortcut to obtaining Horde_Imap_Client_Mailbox object(s).
public static getImapMboxOb ( mixed $mbox ) : mixed
$mbox mixed The full IMAP mailbox name(s).
return mixed The Horde_Imap_Client_Mailbox object(s).

getIndicesOb() public method

Return an indices object for this mailbox.
public getIndicesOb ( mixed $in ) : IMP_Indices
$in mixed Either a single UID, array of UIDs, or a Horde_Imap_Client_Ids object.
return IMP_Indices An indices object.

getPref() public static method

Shortcut to obtaining a mailbox object from a preference name.
public static getPref ( $pref ) : IMP_Mailbox
return IMP_Mailbox The IMP_Mailbox object.

getSearchOb() public method

Return the search query object for this mailbox.
public getSearchOb ( ) : IMP_Search_Query
return IMP_Search_Query The search query object.

getSort() public method

Return the sorting preference for this mailbox.
public getSort ( boolean $convert = false ) : IMP_Prefs_Sort_Sortpref
$convert boolean Convert 'by' to a Horde_Imap_Client constant?
return IMP_Prefs_Sort_Sortpref Sortpref object.

getSpecialMailboxes() public static method

Return the list of special mailboxes.
public static getSpecialMailboxes ( ) : array
return array A list of mailboxes, with the self::SPECIAL_* constants as keys and values containing the IMP_Mailbox objects or null if the mailbox doesn't exist (self::SPECIAL_SENT contains an array of objects).

getSpecialMailboxesSort() public static method

Return the list of sorted special mailboxes.
public static getSpecialMailboxesSort ( ) : array
return array The list of sorted special mailboxes (IMP_Mailbox objects).

hideDeletedMsgs() public method

Are deleted messages hidden in this mailbox?
public hideDeletedMsgs ( boolean $deleted = false ) : boolean
$deleted boolean Return value is what should be done with deleted messages in general, as opposed to any deleted message in the mailbox.
return boolean True if deleted messages should be hidden.

prefFrom() public static method

Converts a mailbox name from a value stored in the preferences.
public static prefFrom ( string $mbox ) : string
$mbox string The mailbox name as stored in a preference.
return string The full IMAP mailbox name (UTF-8).

prefTo() public static method

Converts a mailbox name to a value to be stored in a preference.
public static prefTo ( string $mbox ) : string
$mbox string The full IMAP mailbox name (UTF-8).
return string The value to store in a preference.

rename() public method

Rename this mailbox on the server. The subscription status remains the same. All subfolders will also be renamed.
public rename ( string $new_name ) : boolean
$new_name string The new mailbox name (UTF-8).
return boolean True on success

runSearchQuery() public method

Run a search query on this mailbox that is not stored in the current session. Allows custom queries with custom sorts to be used without affecting cached mailboxes.
public runSearchQuery ( Horde_Imap_Client_Search_Query $query, integer $sortby = null, integer $sortdir = null ) : IMP_Indices
$query Horde_Imap_Client_Search_Query The search query object.
$sortby integer The sort criteria.
$sortdir integer The sort directory.
return IMP_Indices An indices object.

setHideDeletedMsgs() public method

Sets the 'delhide' preference and clears necessary cached data.
public setHideDeletedMsgs ( boolean $value )
$value boolean The value to set 'delhide' to.

setSort() public method

Set the sorting preference for this mailbox.
public setSort ( integer $by = null, integer $dir = null, boolean $delete = false )
$by integer The sort type.
$dir integer The sort direction.
$delete boolean Delete the entry?

subscribe() public method

Subscribe/unsubscribe to an IMAP mailbox.
public subscribe ( boolean $sub, array $opts = [] ) : boolean
$sub boolean True to subscribe, false to unsubscribe.
$opts array Additional options: - subfolders: (boolean) If true, applies actions to all subfolders.
return boolean True on success.

toBuids() public method

Create a BUID indices object from a list of UIDs.
public toBuids ( IMP_Indices $uids ) : IMP_Indices
$uids IMP_Indices UIDs.
return IMP_Indices An indices object.

url() public method

Generate a URL using the current mailbox.
public url ( string | Horde_Url $page, string $buid = null, boolean $encode = true ) : Horde_Url
$page string | Horde_Url Page name to link to.
$buid string The BUID to use on the linked page.
$encode boolean Encode the argument separator?
return Horde_Url URL to $page with any necessary mailbox information added to the parameter list of the URL.

urlParams() public method

Returns list of URL parameters necessary to indicate current mailbox status.
public urlParams ( string $buid = null ) : array
$buid string The BUID to use on the linked page.
return array The list of parameters needed to indicate the current mailbox status.

Property Details

$_mbox protected_oe property

The IMAP mailbox name (UTF-8).
protected string $_mbox
return string