Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

Copyright 2008-2017 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Copyright: 2008-2017 Horde LLC
License: http://www.horde.org/licenses/lgpl21 LGPL 2.1
File Size: 4096 lines (149 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Horde_Imap_Client_Base:: (82 methods):
  __construct()
  _getEncryptKey()
  _initOb()
  shutdown()
  __clone()
  update()
  serialize()
  unserialize()
  __serialize()
  __unserialize()
  __get()
  _setInit()
  _initCache()
  getParam()
  setParam()
  getCache()
  getIdsOb()
  queryCapability()
  capability()
  _capability()
  noop()
  getNamespaces()
  isSecureConnection()
  alerts()
  login()
  logout()
  sendID()
  getID()
  setLanguage()
  getLanguage()
  openMailbox()
  _changeSelected()
  _mailboxOb()
  currentMailbox()
  createMailbox()
  deleteMailbox()
  _deleteMailboxPost()
  renameMailbox()
  subscribeMailbox()
  listMailboxes()
  status()
  statusMultiple()
  append()
  check()
  close()
  expunge()
  search()
  setComparator()
  getComparator()
  thread()
  fetch()
  _fetchWrapper()
  vanished()
  store()
  copy()
  setQuota()
  getQuota()
  getQuotaRoot()
  getACL()
  setACL()
  deleteACL()
  listACLRights()
  getMyACLRights()
  allAclRights()
  getMetadata()
  setMetadata()
  getCacheId()
  parseCacheId()
  resolveIds()
  validSearchCharset()
  getSyncToken()
  sync()
  _updateCache()
  _moveCache()
  _deleteMsgs()
  _getSearchCache()
  _setSearchCache()
  _updateModSeq()
  _condstoreSync()
  _cacheFields()
  _syncStatus()
  _getUidByMessageId()


Class: Horde_Imap_Client_Base  - X-Ref

An abstracted API interface to IMAP backends supporting the IMAP4rev1
protocol (RFC 3501).

__construct(array $params = array()   X-Ref
Constructor.

param: array $params   Configuration parameters:

_getEncryptKey()   X-Ref
Get encryption key.

return: string  The encryption key.

_initOb()   X-Ref
Do initialization tasks.


shutdown()   X-Ref
Shutdown actions.


__clone()   X-Ref
This object can not be cloned.


update(SplSubject $subject)   X-Ref
No description

serialize()   X-Ref
No description

unserialize($data)   X-Ref
No description

__serialize()   X-Ref

return: array

__unserialize(array $data)   X-Ref
No description

__get($name)   X-Ref
No description

_setInit($key = null, $val = null)   X-Ref
Set an initialization value.

param: string $key  The initialization key. If null, resets all keys.
param: mixed $val   The cached value. If null, removes the key.

_initCache($current = false)   X-Ref
Initialize the Horde_Imap_Client_Cache object, if necessary.

param: boolean $current  If true, we are going to update the currently
return: boolean  Returns true if caching is enabled.

getParam($key)   X-Ref
Returns a value from the internal params array.

param: string $key  The param key.
return: mixed  The param value, or null if not found.

setParam($key, $val)   X-Ref
Sets a configuration parameter value.

param: string $key  The param key.
param: mixed $val   The param value.

getCache()   X-Ref
Returns the Horde_Imap_Client_Cache object used, if available.

return: mixed  Either the cache object or null.

getIdsOb($ids = null, $sequence = false)   X-Ref
Returns the correct IDs object for use with this driver.

param: mixed $ids  Either self::ALL, self::SEARCH_RES, self::LARGEST,
param: boolean $sequence  Are $ids message sequence numbers?
return: Horde_Imap_Client_Ids  The IDs object.

queryCapability($capability)   X-Ref
Returns whether the IMAP server supports the given capability
(See RFC 3501 [6.1.1]).

param: string $capability  The capability string to query.
return: mixed  True if the server supports the queried capability,

capability()   X-Ref
Get CAPABILITY information from the IMAP server.

return: array  The capability array.

_capability()   X-Ref
Query server capability.

Required because internal code can't call capability via magic method
directly - it may not exist yet, the creation code may call capability
recursively, and __get() doesn't allow recursive calls to the same
property (chicken/egg issue).

return: mixed  The capability object if no arguments provided. If

noop()   X-Ref
Send a NOOP command (RFC 3501 [6.1.2]).


getNamespaces(array $additional = array()   X-Ref
Get the NAMESPACE information from the IMAP server (RFC 2342).

param: array $additional  If the server supports namespaces, any
param: array $opts        Additional options:
return: mixed  A Horde_Imap_Client_Namespace_List object if

isSecureConnection()   X-Ref
Display if connection to the server has been secured via TLS or SSL.

return: boolean  True if the IMAP connection is secured.

alerts()   X-Ref
Return a list of alerts that MUST be presented to the user (RFC 3501
[7.1]).

return: array  An array of alert messages.

login()   X-Ref
Login to the IMAP server.


logout()   X-Ref
Logout from the IMAP server (see RFC 3501 [6.1.3]).


sendID($info = null)   X-Ref
Send ID information to the IMAP server (RFC 2971).

param: array $info  Overrides the value of the 'id' param and sends

getID()   X-Ref
Return ID information from the IMAP server (RFC 2971).

return: array  An array of information returned, with the keys as the

setLanguage($langs = null)   X-Ref
Sets the preferred language for server response messages (RFC 5255).

param: array $langs  Overrides the value of the 'lang' param and sends
return: string  The language accepted by the server, or null if the

getLanguage($list = false)   X-Ref
Gets the preferred language for server response messages (RFC 5255).

param: array $list  If true, return the list of available languages.
return: mixed  If $list is true, the list of languages available on the

openMailbox($mailbox, $mode = Horde_Imap_Client::OPEN_AUTO)   X-Ref
Open a mailbox.

param: mixed $mailbox  The mailbox to open. Either a
param: integer $mode   The access mode. Either

_changeSelected($mailbox = null, $mode = null)   X-Ref
Called when the selected mailbox is changed.

param: mixed $mailbox  The selected mailbox or null.
param: integer $mode   The access mode.

_mailboxOb($mailbox = null)   X-Ref
Return the Horde_Imap_Client_Base_Mailbox object.

param: string $mailbox  The mailbox name. Defaults to currently
return: Horde_Imap_Client_Base_Mailbox  Mailbox object.

currentMailbox()   X-Ref
Return the currently opened mailbox and access mode.

return: mixed  Null if no mailbox selected, or an array with two

createMailbox($mailbox, array $opts = array()   X-Ref
Create a mailbox.

param: mixed $mailbox  The mailbox to create. Either a
param: array $opts     Additional options:

deleteMailbox($mailbox)   X-Ref
Delete a mailbox.

param: mixed $mailbox  The mailbox to delete. Either a

_deleteMailboxPost(Horde_Imap_Client_Mailbox $mailbox)   X-Ref
Actions to perform after a mailbox delete.

param: Horde_Imap_Client_Mailbox $mailbox  The deleted mailbox.

renameMailbox($old, $new)   X-Ref
Rename a mailbox.

param: mixed $old  The old mailbox name. Either a
param: mixed $new  The new mailbox name. Either a

subscribeMailbox($mailbox, $subscribe = true)   X-Ref
Manage subscription status for a mailbox.

param: mixed $mailbox      The mailbox to [un]subscribe to. Either a
param: boolean $subscribe  True to subscribe, false to unsubscribe.

listMailboxes($pattern,$mode = Horde_Imap_Client::MBOX_ALL,array $options = array()   X-Ref
Obtain a list of mailboxes matching a pattern.

param: mixed $pattern   The mailbox search pattern(s) (see RFC 3501
param: integer $mode    Which mailboxes to return.  Either:
param: array $options   Additional options:
return: array  If 'flat' option is true, the array values are a list

status($mailbox, $flags = Horde_Imap_Client::STATUS_ALL,array $opts = array()   X-Ref
Obtain status information for a mailbox.

param: mixed $mailbox  The mailbox(es) to query. Either a
param: integer $flags  A bitmask of information requested from the
param: array $opts     Additional options:
return: array  If $mailbox contains multiple mailboxes, an array with

statusMultiple($mailboxes,$flags = Horde_Imap_Client::STATUS_ALL,array $opts = array()   X-Ref
Perform a STATUS call on multiple mailboxes at the same time.

This method leverages the LIST-EXTENDED and LIST-STATUS extensions on
the IMAP server to improve the efficiency of this operation.

param: array $mailboxes  The mailboxes to query. Either
param: integer $flags    See status().
param: array $opts       Additional options:
return: array  An array with the keys as the mailbox names (UTF-8) and

append($mailbox, $data, array $options = array()   X-Ref
Append message(s) to a mailbox.

param: mixed $mailbox  The mailbox to append the message(s) to. Either
param: array $data     The message data to append, along with
param: array $options  Additonal options:
return: Horde_Imap_Client_Ids  The UIDs of the appended messages.

check()   X-Ref
Request a checkpoint of the currently selected mailbox (RFC 3501
[6.4.1]).


close(array $options = array()   X-Ref
Close the connection to the currently selected mailbox, optionally
expunging all deleted messages (RFC 3501 [6.4.2]).

param: array $options  Additional options:

expunge($mailbox, array $options = array()   X-Ref
Expunge deleted messages from the given mailbox.

param: mixed $mailbox  The mailbox to expunge. Either a
param: array $options  Additional options:
return: Horde_Imap_Client_Ids  If 'list' option is true, returns the

search($mailbox, $query = null, array $options = array()   X-Ref
Search a mailbox.

param: mixed $mailbox                         The mailbox to search.
param: Horde_Imap_Client_Search_Query $query  The search query.
param: array $options                         Additional options:
return: array  An array with the following keys:

setComparator($comparator = null)   X-Ref
Set the comparator to use for searching/sorting (RFC 5255).

param: string $comparator  The comparator string (see RFC 4790 [3.1] -

getComparator()   X-Ref
Get the comparator used for searching/sorting (RFC 5255).

return: mixed  Null if the default comparator is being used, or an

thread($mailbox, array $options = array()   X-Ref
Thread sort a given list of messages (RFC 5256).

param: mixed $mailbox  The mailbox to query. Either a
param: array $options  Additional options:
return: Horde_Imap_Client_Data_Thread  A thread data object.

fetch($mailbox, $query, array $options = array()   X-Ref
Fetch message data (see RFC 3501 [6.4.5]).

param: mixed $mailbox                        The mailbox to search.
param: Horde_Imap_Client_Fetch_Query $query  Fetch query object.
param: array $options                        Additional options:
return: Horde_Imap_Client_Fetch_Results  A results object.

_fetchWrapper($mailbox, $query, $options)   X-Ref
Wrapper for fetch() to allow internal state to be reset on exception.


vanished($mailbox, $modseq, array $opts = array()   X-Ref
Get the list of vanished messages (UIDs that have been expunged since a
given mod-sequence value).

param: mixed $mailbox   The mailbox to query. Either a
param: integer $modseq  Search for expunged messages after this
param: array $opts      Additional options:
return: Horde_Imap_Client_Ids  List of UIDs that have vanished.

store($mailbox, array $options = array()   X-Ref
Store message flag data (see RFC 3501 [6.4.6]).

param: mixed $mailbox  The mailbox containing the messages to modify.
param: array $options  Additional options:
return: Horde_Imap_Client_Ids  A Horde_Imap_Client_Ids object

copy($source, $dest, array $options = array()   X-Ref
Copy messages to another mailbox.

param: mixed $source   The source mailbox. Either a
param: mixed $dest     The destination mailbox. Either a
param: array $options  Additional options:
return: mixed  An array mapping old UIDs (keys) to new UIDs (values) on

setQuota($root, array $resources = array()   X-Ref
Set quota limits. The server must support the IMAP QUOTA extension
(RFC 2087).

param: mixed $root       The quota root. Either a
param: array $resources  The resource values to set. Keys are the

getQuota($root)   X-Ref
Get quota limits. The server must support the IMAP QUOTA extension
(RFC 2087).

param: mixed $root  The quota root. Either a Horde_Imap_Client_Mailbox
return: mixed  An array with resource keys. Each key holds an array

getQuotaRoot($mailbox)   X-Ref
Get quota limits for a mailbox. The server must support the IMAP QUOTA
extension (RFC 2087).

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
return: mixed  An array with the keys being the quota roots. Each key

getACL($mailbox)   X-Ref
Get the ACL rights for a given mailbox. The server must support the
IMAP ACL extension (RFC 2086/4314).

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
return: array  An array with identifiers as the keys and

setACL($mailbox, $identifier, $options)   X-Ref
Set ACL rights for a given mailbox/identifier.

param: mixed $mailbox      A mailbox. Either a Horde_Imap_Client_Mailbox
param: string $identifier  The identifier to alter (UTF-8).
param: array $options      Additional options:

deleteACL($mailbox, $identifier)   X-Ref
Deletes ACL rights for a given mailbox/identifier.

param: mixed $mailbox      A mailbox. Either a Horde_Imap_Client_Mailbox
param: string $identifier  The identifier to delete (UTF-8).

listACLRights($mailbox, $identifier)   X-Ref
List the ACL rights for a given mailbox/identifier. The server must
support the IMAP ACL extension (RFC 2086/4314).

param: mixed $mailbox      A mailbox. Either a Horde_Imap_Client_Mailbox
param: string $identifier  The identifier to query (UTF-8).
return: Horde_Imap_Client_Data_AclRights  An ACL data rights object.

getMyACLRights($mailbox)   X-Ref
Get the ACL rights for the current user for a given mailbox. The
server must support the IMAP ACL extension (RFC 2086/4314).

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
return: Horde_Imap_Client_Data_Acl  An ACL data object.

allAclRights()   X-Ref
Return master list of ACL rights available on the server.

return: array  A list of ACL rights.

getMetadata($mailbox, $entries, array $options = array()   X-Ref
Get metadata for a given mailbox. The server must support either the
IMAP METADATA extension (RFC 5464) or the ANNOTATEMORE extension
(http://ietfreport.isoc.org/idref/draft-daboo-imap-annotatemore/).

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
param: array $entries  The entries to fetch (UTF-8 strings).
param: array $options  Additional options:
return: array  An array with metadata names as the keys and metadata

setMetadata($mailbox, $data)   X-Ref
Set metadata for a given mailbox/identifier.

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
param: array $data     A set of data values. The metadata values

getCacheId($mailbox, array $addl = array()   X-Ref
Returns a unique identifier for the current mailbox status.

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
param: array $addl     Additional cache info to add to the cache ID
return: string  The cache ID string, which will change when the

parseCacheId($id)   X-Ref
Parses a cacheID created by getCacheId().

param: string $id  The cache ID.
return: array  An array with the following information:

resolveIds(Horde_Imap_Client_Mailbox $mailbox,Horde_Imap_Client_Ids $ids, $convert = 0)   X-Ref
Resolves an IDs object into a list of IDs.

param: Horde_Imap_Client_Mailbox $mailbox  The mailbox.
param: Horde_Imap_Client_Ids $ids          The Ids object.
param: integer $convert                    Convert to UIDs?
return: Horde_Imap_Client_Ids  The list of IDs.

validSearchCharset($charset)   X-Ref
Determines if the given charset is valid for search-related queries.
This check pertains just to the basic IMAP SEARCH command.

param: string $charset  The query charset.
return: boolean  True if server supports this charset.

getSyncToken($mailbox)   X-Ref
Returns a unique token for the current mailbox synchronization status.

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
return: string  The sync token.

sync($mailbox, $token, array $opts = array()   X-Ref
Synchronize a mailbox from a sync token.

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
param: string $token   A sync token generated by getSyncToken().
param: array $opts     Additional options:
return: Horde_Imap_Client_Data_Sync  A sync object.

_updateCache(Horde_Imap_Client_Fetch_Results $data)   X-Ref
Store FETCH data in cache.

param: Horde_Imap_Client_Fetch_Results $data  The fetch results.

_moveCache(Horde_Imap_Client_Mailbox $to, $map,$uidvalid)   X-Ref
Moves cache entries from the current mailbox to another mailbox.

param: Horde_Imap_Client_Mailbox $to  The destination mailbox.
param: array $map                     Mapping of source UIDs (keys) to
param: string $uidvalid               UIDVALIDITY of destination

_deleteMsgs(Horde_Imap_Client_Mailbox $mailbox,Horde_Imap_Client_Ids $ids,array $opts = array()   X-Ref
Delete messages in the cache.

param: Horde_Imap_Client_Mailbox $mailbox  The mailbox.
param: Horde_Imap_Client_Ids $ids          The list of IDs to delete in
param: array $opts                         Additional options (not used
return: Horde_Imap_Client_Ids  UIDs that were deleted.

_getSearchCache($type, $options)   X-Ref
Retrieve data from the search cache.

param: string $type    The cache type ('search' or 'thread').
param: array $options  The options array of the calling function.
return: mixed  Returns search cache metadata. If search was retrieved,

_setSearchCache($data, $sdata)   X-Ref
Set data in the search cache.

param: mixed $data    The cache data to store.
param: string $sdata  The search data returned from _getSearchCache().

_updateModSeq($modseq)   X-Ref
Updates the cached MODSEQ value.

param: integer $modseq  MODSEQ value to store.
return: mixed  The MODSEQ of the old value if it was replaced (or false

_condstoreSync()   X-Ref
Synchronizes the current mailbox cache with the server (using CONDSTORE
or QRESYNC).


_cacheFields()   X-Ref
Provide the list of available caching fields.

return: array  The list of available caching fields (fields are in the

_syncStatus($mailbox)   X-Ref
Return the current mailbox synchronization status.

param: mixed $mailbox  A mailbox. Either a Horde_Imap_Client_Mailbox
return: array  An array with status data. (This data is not guaranteed

_getUidByMessageId($mailbox, $msgid)   X-Ref
Get a message UID by the Message-ID. Returns the last message in a
mailbox that matches.

param: Horde_Imap_Client_Mailbox $mailbox  The mailbox to search
param: string $msgid                       Message-ID.
return: string  UID (null if not found).