* lang - (array) A list of languages (in priority order) to be used to
* display human readable messages.
* DEFAULT: Messages output in IMAP server default language
+ * log - (array) A callback to a function that receives a single
+ * parameter: a Horde_Imap_Client_Exception object. This callback
+ * function MUST be static.
+ * DEFAULT: No logging
* port - (integer) The server port to which we will connect.
* DEFAULT: 143 (imap or imap w/TLS) or 993 (imaps)
* secure - (string) Use SSL or TLS to connect.
$params = array_merge(array(
'encryptKey' => null,
'hostspec' => 'localhost',
+ 'log' => null,
'port' => ((isset($params['secure']) && ($params['secure'] == 'ssl')) ? 993 : 143),
'secure' => false,
'timeout' => 30
return call_user_func($this->_params['encryptKey']);
}
- throw new Horde_Imap_Client_Exception('encryptKey parameter is not a valid callback.');
+ $this->_exception('encryptKey parameter is not a valid callback.');
+ }
+
+ /**
+ * Exception wrapper - logs an error message before throwing exception.
+ *
+ * @param string $msg Error message.
+ * @param integer|string $code Error code. If string, will convert from
+ * the Exception constant of the same name.
+ *
+ * @throws Horde_Imap_Client_Exception
+ */
+ protected function _exception($msg, $code = 0)
+ {
+ if (!is_integer($code)) {
+ $code = constant('Horde_Imap_Client_Exception::' . $code);
+ }
+
+ $e = new Horde_Imap_Client_Exception($msg, $code);
+
+ if (is_callable($this->_params['log'])) {
+ call_user_func($this->_params['log'], $e);
+ }
+
+ throw $e;
}
/**
public function sendID($info = null)
{
if (!$this->queryCapability('ID')) {
- throw new Horde_Imap_Client_Exception('The IMAP server does not support the ID extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('The IMAP server does not support the ID extension.', 'NOSUPPORTIMAPEXT');
}
$this->_sendID(is_null($info) ? (empty($this->_params['id']) ? array() : $this->_params['id']) : $info);
public function getID()
{
if (!$this->queryCapability('ID')) {
- throw new Horde_Imap_Client_Exception('The IMAP server does not support the ID extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('The IMAP server does not support the ID extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_getID();
$i18n = $this->queryCapability('I18NLEVEL');
if (empty($i18n) || (max($i18n) < 2)) {
- throw new Horde_Imap_Client_Exception('The IMAP server does not support changing SEARCH/SORT comparators.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('The IMAP server does not support changing SEARCH/SORT comparators.', 'NOSUPPORTIMAPEXT');
}
$this->_setComparator($comp);
(!$qresync ||
$seq ||
empty($options['changedsince']))) {
- throw new Horde_Imap_Client_Exception('The vanished FETCH modifier is missing a pre-requisite.');
+ $this->_exception('The vanished FETCH modifier is missing a pre-requisite.');
}
$this->openMailbox($mailbox, Horde_Imap_Client::OPEN_AUTO);
if (!empty($options['unchangedsince']) &&
!isset($this->_init['enabled']['CONDSTORE'])) {
- throw new Horde_Imap_Client_Exception('Server does not support the CONDSTORE extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the CONDSTORE extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_store($options);
public function setQuota($root, $options = array())
{
if (!$this->queryCapability('QUOTA')) {
- throw new Horde_Imap_Client_Exception('Server does not support the QUOTA extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the QUOTA extension.', 'NOSUPPORTIMAPEXT');
}
if (isset($options['messages']) || isset($options['storage'])) {
public function getQuota($root)
{
if (!$this->queryCapability('QUOTA')) {
- throw new Horde_Imap_Client_Exception('Server does not support the QUOTA extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the QUOTA extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_getQuota(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($root));
public function getQuotaRoot($mailbox)
{
if (!$this->queryCapability('QUOTA')) {
- throw new Horde_Imap_Client_Exception('Server does not support the QUOTA extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the QUOTA extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_getQuotaRoot(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox));
public function setACL($mailbox, $identifier, $options)
{
if (!$this->queryCapability('ACL')) {
- throw new Horde_Imap_Client_Exception('Server does not support the ACL extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the ACL extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_setACL(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox), Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($identifier), $options);
public function listACLRights($mailbox, $identifier)
{
if (!$this->queryCapability('ACL')) {
- throw new Horde_Imap_Client_Exception('Server does not support the ACL extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the ACL extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_listACLRights(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox), Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($identifier));
public function getMyACLRights($mailbox)
{
if (!$this->queryCapability('ACL')) {
- throw new Horde_Imap_Client_Exception('Server does not support the ACL extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the ACL extension.', 'NOSUPPORTIMAPEXT');
}
return $this->_getMyACLRights(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox));
}
if (is_null($part)) {
- throw new Horde_Imap_Client_Exception('Bad IMAP URL given in CATENATE data.', Horde_Imap_Client_Exception::CATENATE_BADURL);
+ $this->_exception('Bad IMAP URL given in CATENATE data.', 'CATENATE_BADURL');
} else {
$this->_prepareAppendData($part, $stream);
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Received error from IMAP server when sending a NOOP command: ' . imap_last_error());
+ $this->_exception('Received error from IMAP server when sending a NOOP command: ' . imap_last_error());
}
}
$res = false;
if (!empty($this->_params['secure']) && !extension_loaded('openssl')) {
- throw new Horde_Imap_Client_Exception('Secure connections require the PHP openssl extension: http://php.net/openssl.');
+ $this->_exception('Secure connections require the PHP openssl extension: http://php.net/openssl.');
}
$mask = ($this->_service == 'pop3') ? 0 : OP_HALFOPEN;
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not authenticate to IMAP server: ' . imap_last_error());
+ $this->_exception('Could not authenticate to IMAP server: ' . imap_last_error());
}
$this->_stream = $res;
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not open mailbox "' . $mailbox . '": ' . imap_last_error());
+ $this->_exception('Could not open mailbox "' . $mailbox . '": ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not create mailbox "' . $mailbox . '": ' . imap_last_error());
+ $this->_exception('Could not create mailbox "' . $mailbox . '": ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not delete mailbox "' . $mailbox . '": ' . imap_last_error());
+ $this->_exception('Could not delete mailbox "' . $mailbox . '": ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not rename mailbox "' . $old . '": ' . imap_last_error());
+ $this->_exception('Could not rename mailbox "' . $old . '": ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Could not ' . ($subscribe ? 'subscribe' : 'unsubscribe') . ' to mailbox "' . $mailbox . '": ' . imap_last_error());
+ $this->_exception('Could not ' . ($subscribe ? 'subscribe' : 'unsubscribe') . ' to mailbox "' . $mailbox . '": ' . imap_last_error());
}
}
unset($options['create']);
return $this->_append($mailbox, $data, $options);
}
- throw new Horde_Imap_Client_Exception('Could not append message to IMAP server: ' . imap_last_error());
+ $this->_exception('Could not append message to IMAP server: ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Received error from IMAP server when sending a CHECK command: ' . imap_last_error());
+ $this->_exception('Received error from IMAP server when sending a CHECK command: ' . imap_last_error());
}
}
} else {
$label = 'bodypart';
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a MIME ID when retrieving a MIME body part.');
+ $this->_exception('Need a MIME ID when retrieving a MIME body part.');
}
$body_key = $val['id'];
}
error_reporting($old_error);
if ($err) {
- throw new Horde_Imap_Client_Exception('Error when fetching messages: ' . imap_last_error());
+ $this->_exception('Error when fetching messages: ' . imap_last_error());
}
return $ret;
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when flagging messages: ' . imap_last_error());
+ $this->_exception('Error when flagging messages: ' . imap_last_error());
}
return array();
unset($options['create']);
return $this->copy($dest, $options);
}
- throw new Horde_Imap_Client_Exception('Error when copying/moving messages: ' . imap_last_error());
+ $this->_exception('Error when copying/moving messages: ' . imap_last_error());
}
return true;
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when setting quota: ' . imap_last_error());
+ $this->_exception('Error when setting quota: ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when retrieving quota: ' . imap_last_error());
+ $this->_exception('Error when retrieving quota: ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when retrieving quotaroot: ' . imap_last_error());
+ $this->_exception('Error when retrieving quotaroot: ' . imap_last_error());
}
return array($mailbox => $ret);
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when setting ACL: ' . imap_last_error());
+ $this->_exception('Error when setting ACL: ' . imap_last_error());
}
}
error_reporting($old_error);
if ($res === false) {
- throw new Horde_Imap_Client_Exception('Error when retrieving ACLs: ' . imap_last_error());
+ $this->_exception('Error when retrieving ACLs: ' . imap_last_error());
}
foreach ($res as $id => $rights) {
*/
protected function _capability()
{
- throw new Horde_Imap_Client_Exception('CAPABILITY command not supported in this POP3 driver.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('CAPABILITY command not supported in this POP3 driver.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getNamespaces()
{
- throw new Horde_Imap_Client_Exception('IMAP namespaces not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP namespaces not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _sendID($info)
{
- throw new Horde_Imap_Client_Exception('IMAP ID command not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ID command not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getID()
{
- throw new Horde_Imap_Client_Exception('IMAP ID command not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ID command not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setLanguage($langs)
{
- throw new Horde_Imap_Client_Exception('IMAP LANGUAGE extension not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP LANGUAGE extension not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getLanguage($list)
{
- throw new Horde_Imap_Client_Exception('IMAP LANGUAGE extension not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP LANGUAGE extension not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
protected function _openMailbox($mailbox, $mode)
{
if (strcasecmp($mailbox, 'INBOX') !== 0) {
- throw new Horde_Imap_Client_Exception('Mailboxes other than INBOX not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Mailboxes other than INBOX not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
}
*/
protected function _createMailbox($mailbox, $opts)
{
- throw new Horde_Imap_Client_Exception('Creating mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Creating mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _deleteMailbox($mailbox)
{
- throw new Horde_Imap_Client_Exception('Deleting mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Deleting mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _renameMailbox($old, $new)
{
- throw new Horde_Imap_Client_Exception('Renaming mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Renaming mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _subscribeMailbox($mailbox, $subscribe)
{
- throw new Horde_Imap_Client_Exception('Mailboxes other than INBOX not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Mailboxes other than INBOX not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
($flags & Horde_Imap_Client::STATUS_PERMFLAGS) ||
($flags & Horde_Imap_Client::STATUS_HIGHESTMODSEQ) ||
($flags & Horde_Imap_Client::STATUS_UIDNOTSTICKY)) {
- throw new Horde_Imap_Client_Exception('Improper status request on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Improper status request on POP3 server.', 'POP3_NOTSUPPORTED');
}
return parent::_status($mailbox, $flags);
in_array(Horde_Imap_Client::SORT_REVERSE, $options['sort']) ||
in_array(Horde_Imap_Client::SORT_DISPLAYFROM, $options['sort']) ||
in_array(Horde_Imap_Client::SORT_DISPLAYTO, $options['sort'])))) {
- throw new Horde_Imap_Client_Exception('Unsupported search criteria on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Unsupported search criteria on POP3 server.', 'POP3_NOTSUPPORTED');
}
return parent::_search($query, $options);
*/
protected function _setComparator($comparator)
{
- throw new Horde_Imap_Client_Exception('Search comparators not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Search comparators not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getComparator()
{
- throw new Horde_Imap_Client_Exception('Search comparators not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Search comparators not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
/**
if (!empty($options['search']) ||
(!empty($options['criteria']) &&
$options['criteria'] != Horde_Imap_Client::THREAD_REFERENCES)) {
- throw new Horde_Imap_Client_Exception('Unsupported threading criteria on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Unsupported threading criteria on POP3 server.', 'POP3_NOTSUPPORTED');
}
return parent::_thread($options);
*/
protected function _append($mailbox, $data, $options)
{
- throw new Horde_Imap_Client_Exception('Appending messages not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Appending messages not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
reset($criteria);
while (list($val,) = each($criteria)) {
if (in_array($val, $nosupport)) {
- throw new Horde_Imap_Client_Exception('Fetch criteria provided not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Fetch criteria provided not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
}
*/
protected function _copy($dest, $options)
{
- throw new Horde_Imap_Client_Exception('Copying messages not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Copying messages not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setQuota($root, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getQuota($root)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getQuotaRoot($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setACL($mailbox, $identifier, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getACL($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _listACLRights($mailbox, $identifier)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getMyACLRights($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getMetadata($mailbox, $entries, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP metadata not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP metadata not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setMetadata($mailbox, $data)
{
- throw new Horde_Imap_Client_Exception('IMAP metadata not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP metadata not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
}
// Login requires privacy.
const LOGIN_PRIVACYREQUIRED = 21;
- /**
- * Define a callback function used to log the exception. Will be passed
- * a single parameter - a copy of this object.
- *
- * @var callback
- */
- static public $logCallback = null;
-
- /**
- * Constructor.
- */
- public function __construct($message = null, $code = 0)
- {
- parent::__construct($message, $code);
-
- /* Call log function. */
- if (!is_null(self::$logCallback)) {
- call_user_func(self::$logCallback, $this);
- }
- }
-
}
*/
protected function _noop()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getNamespaces()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
public function alerts()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _logout()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _sendID($info)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getID()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _setLanguage($langs)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getLanguage($list)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
{
$folder = $this->_parseFolder($mailbox);
if (!isset(self::$storage[$folder])) {
- throw new Horde_Imap_Client_Exception(sprintf("IMAP folder %s does not exist!",
- $folder));
+ $this->_exception(sprintf("IMAP folder %s does not exist!", $folder));
}
return $folder;
}
{
$mailbox = $this->_parseFolder($mailbox);
if (isset(self::$storage[$mailbox])) {
- throw new Horde_Imap_Client_Exception(sprintf("IMAP folder %s already exists!",
- $mailbox));
+ $this->_exception(sprintf("IMAP folder %s already exists!", $mailbox));
}
self::$storage[$mailbox] = array(
'status' => array(
{
$folder = $this->_parseFolder($mailbox);
if (!isset(self::$storage[$folder])) {
- throw new Horde_Imap_Client_Exception(sprintf("IMAP folder %s does not exist!",
- $folder));
+ $this->_exception(sprintf("IMAP folder %s does not exist!", $folder));
}
unset(self::$storage[$folder]);
return true;
$new = $this->_parseFolder($new);
if (!isset(self::$storage[$old])) {
- throw new Horde_Imap_Client_Exception(sprintf("IMAP folder %s does not exist!",
- $old));
+ $this->_exception(sprintf("IMAP folder %s does not exist!", $old));
}
if (isset(self::$storage[$new])) {
- throw new Horde_Imap_Client_Exception(sprintf("IMAP folder %s already exists!",
- $new));
+ $this->_exception(sprintf("IMAP folder %s already exists!", $new));
}
self::$storage[$new] = self::$storage[$old];
unset(self::$storage[$old]);
*/
protected function _subscribeMailbox($mailbox, $subscribe)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _check()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _close($options)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
}
break;
default:
- throw new Horde_Imap_Client_Exception(sprintf('Search command %s not implemented!',
- $cmd));
+ $this->_exception(sprintf('Search command %s not implemented!', $cmd));
}
}
return array('match' => $uids, 'count' => count($uids));
*/
protected function _setComparator($comparator)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getComparator()
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _thread($options)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
switch ($type) {
case Horde_Imap_Client::FETCH_HEADERTEXT:
if (!isset($this->_mbox['mails'][$uid])) {
- throw new Horde_Imap_Client_Exception(sprintf("No IMAP message %s!", $uid));
+ $this->_exception(sprintf("No IMAP message %s!", $uid));
}
$result['headertext'][$uid] = $this->_mbox['mails'][$uid]['header'];
break;
case Horde_Imap_Client::FETCH_BODYTEXT:
if (!isset($this->_mbox['mails'][$uid])) {
- throw new Horde_Imap_Client_Exception(sprintf("No IMAP message %s!", $uid));
+ $this->_exception(sprintf("No IMAP message %s!", $uid));
}
$result['bodytext'][$uid] = $this->_mbox['mails'][$uid]['body'];
break;
case Horde_Imap_Client::FETCH_UID:
case Horde_Imap_Client::FETCH_SEQ:
case Horde_Imap_Client::FETCH_MODSEQ:
- throw new Horde_Imap_Client_Exception('Not supported!');
+ $this->_exception('Not supported!');
}
}
return $result;
foreach ($options['ids'] as $uid) {
if (!isset($this->_mbox['mails'][$uid])) {
- throw new Horde_Imap_Client_Exception(sprintf("No IMAP message %s!", $uid));
+ $this->_exception(sprintf("No IMAP message %s!", $uid));
}
foreach ($options['add'] as $flag) {
$flag = strtoupper($flag);
$this->_mbox['mails'][$uid]['flags'] |= self::FLAG_DELETED;
break;
default:
- throw new Horde_Imap_Client_Exception(sprintf('Flag %s not implemented!',
- $flag));
+ $this->_exception(sprintf('Flag %s not implemented!', $flag));
}
}
}
foreach ($options['ids'] as $uid) {
if (!isset($this->_mbox['mails'][$uid])) {
- throw new Horde_Imap_Client_Exception(sprintf("No IMAP message %s!", $uid));
+ $this->_exception(sprintf("No IMAP message %s!", $uid));
}
$mail = $this->_mbox['mails'][$uid];
if (!empty($options['move'])) {
*/
protected function _setQuota($root, $options)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getQuota($root)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _getQuotaRoot($mailbox)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
*/
protected function _listACLRights($mailbox, $identifier)
{
- throw new Horde_Imap_Client_Exception('not implemented');
+ $this->_exception('not implemented');
}
/**
if (!$this->queryCapability('STARTTLS')) {
// We should never hit this - STARTTLS is required pursuant
// to RFC 3501 [6.2.1].
- throw new Horde_Imap_Client_Exception('Server does not support TLS connections.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support TLS connections.', 'NOSUPPORTIMAPEXT');
}
// Switch over to a TLS connection.
if (!$res) {
$this->logout();
- throw new Horde_Imap_Client_Exception('Could not open secure TLS connection to the IMAP server.', Horde_Imap_Client_Exception::LOGIN_TLSFAILURE);
+ $this->_exception('Could not open secure TLS connection to the IMAP server.', 'LOGIN_TLSFAILURE');
}
// Expire cached CAPABILITY information (RFC 3501 [6.2.1])
}
if (empty($imap_auth_mech)) {
- throw new Horde_Imap_Client_Exception('No supported IMAP authentication method could be found.', Horde_Imap_Client_Exception::LOGIN_NOAUTHMETHOD);
+ $this->_exception('No supported IMAP authentication method could be found.', 'LOGIN_NOAUTHMETHOD');
}
/* Use MD5 authentication first, if available. But no need to use
}
/* Default to AUTHENTICATIONFAILED error (see RFC 5530[3]). */
- $t['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED;
+ $t['loginerr'] = 'LOGIN_AUTHENTICATIONFAILED';
foreach ($imap_auth_mech as $method) {
$t['referral'] = null;
}
}
- throw new Horde_Imap_Client_Exception('IMAP server denied authentication.', $t['loginerr']);
+ $this->_exception('IMAP server denied authentication.', $t['loginerr']);
}
/**
}
if (!empty($this->_params['secure']) && !extension_loaded('openssl')) {
- throw new Horde_Imap_Client_Exception('Secure connections require the PHP openssl extension.', Horde_Imap_Client_Exception::SERVER_CONNECT);
+ $this->_exception('Secure connections require the PHP openssl extension.', 'SERVER_CONNECT');
}
switch ($this->_params['secure']) {
if ($this->_stream === false) {
$this->_stream = null;
$this->_isSecure = false;
- throw new Horde_Imap_Client_Exception('Error connecting to IMAP server: [' . $error_number . '] ' . $error_string, Horde_Imap_Client_Exception::SERVER_CONNECT);
+ $this->_exception('Error connecting to IMAP server: [' . $error_number . '] ' . $error_string, 'SERVER_CONNECT');
}
stream_set_timeout($this->_stream, $this->_params['timeout']);
switch ($ob['response']) {
case 'BAD':
// Server is rejecting our connection.
- throw new Horde_Imap_Client_Exception('Server rejected connection: ' . $ob['line'], Horde_Imap_Client_Exception::SERVER_CONNECT);
+ $this->_exception('Server rejected connection: ' . $ob['line'], 'SERVER_CONNECT');
case 'PREAUTH':
// The user was pre-authenticated.
// Check for IMAP4rev1 support
if (!$this->queryCapability('IMAP4REV1')) {
- throw new Horde_Imap_Client_Exception('This server does not support IMAP4rev1 (RFC 3501).', Horde_Imap_Client_Exception::SERVER_CONNECT);
+ $this->_exception('This server does not support IMAP4rev1 (RFC 3501).', 'SERVER_CONNECT');
}
// Set language if not using imapproxy
case 'CRAM-MD5':
// RFC 2195
if (!class_exists('Auth_SASL')) {
- throw new Horde_Imap_Client_Exception('The Auth_SASL package is required for CRAM-MD5 authentication');
+ $this->_exception('The Auth_SASL package is required for CRAM-MD5 authentication');
}
$auth_sasl = Auth_SASL::factory('crammd5');
$response = base64_encode($auth_sasl->getResponse($this->_params['username'], $this->getParam('password'), base64_decode($ob['line'])));
case 'DIGEST-MD5':
if (!class_exists('Auth_SASL')) {
- throw new Horde_Imap_Client_Exception('The Auth_SASL package is required for DIGEST-MD5 authentication');
+ $this->_exception('The Auth_SASL package is required for DIGEST-MD5 authentication');
}
$auth_sasl = Auth_SASL::factory('digestmd5');
$response = base64_encode($auth_sasl->getResponse($this->_params['username'], $this->getParam('password'), base64_decode($ob['line']), $this->_params['hostspec'], 'imap'));
));
$response = base64_decode($ob['line']);
if (strpos($response, 'rspauth=') === false) {
- throw new Horde_Imap_Client_Exception('Unexpected response from server to Digest-MD5 response.');
+ $this->_exception('Unexpected response from server to Digest-MD5 response.');
}
$this->_sendLine('', array(
'notag' => true
* an exception. */
if (in_array('CONDSTORE', $options['_query']['exts']) &&
empty($this->_temp['mailbox']['highestmodseq'])) {
- throw new Horde_Imap_Client_Exception('Mailbox does not support mod-sequences.', Horde_Imap_Client_Exception::MBOXNOMODSEQ);
+ $this->_exception('Mailbox does not support mod-sequences.', 'MBOXNOMODSEQ');
}
$cmd = array();
case 'REFERENCES':
case 'REFS':
- throw new Horde_Imap_Client_Exception('Server does not support ' . $tsort . ' thread sort.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support ' . $tsort . ' thread sort.', 'NOSUPPORTIMAPEXT');
}
}
case Horde_Imap_Client::FETCH_MIMEHEADER:
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a non-zero MIME ID when retrieving a MIME header.');
+ $this->_exception('Need a non-zero MIME ID when retrieving a MIME header.');
}
$cmd .= 'MIME';
break;
case Horde_Imap_Client::FETCH_BODYPART:
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a non-zero MIME ID when retrieving a MIME body part.');
+ $this->_exception('Need a non-zero MIME ID when retrieving a MIME body part.');
}
if (!empty($val['stream'])) {
case Horde_Imap_Client::FETCH_HEADERS:
if (empty($val['label'])) {
- throw new Horde_Imap_Client_Exception('Need a unique label when doing a headers field search.');
+ $this->_exception('Need a unique label when doing a headers field search.');
} elseif (empty($val['headers'])) {
- throw new Horde_Imap_Client_Exception('Need headers to query when doing a headers field search.');
+ $this->_exception('Need headers to query when doing a headers field search.');
}
$fp['parseheaders'] = !empty($val['parse']);
case Horde_Imap_Client::FETCH_BODYPARTSIZE:
foreach ($c_val as $val) {
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a non-zero MIME ID when retrieving unencoded MIME body part size.');
+ $this->_exception('Need a non-zero MIME ID when retrieving unencoded MIME body part size.');
}
$fetch[] = 'BINARY.SIZE[' . $val['id'] . ']';
}
* mailbox that doesn't support it will return BAD. Catch that
* here and throw an exception. */
if (empty($this->_temp['mailbox']['highestmodseq'])) {
- throw new Horde_Imap_Client_Exception('Mailbox does not support mod-sequences.', Horde_Imap_Client_Exception::MBOXNOMODSEQ);
+ $this->_exception('Mailbox does not support mod-sequences.', 'MBOXNOMODSEQ');
}
$fetch[] = 'MODSEQ';
break;
if (!empty($options['changedsince'])) {
if (empty($this->_temp['mailbox']['highestmodseq'])) {
- throw new Horde_Imap_Client_Exception('Mailbox does not support mod-sequences.', Horde_Imap_Client_Exception::MBOXNOMODSEQ);
+ $this->_exception('Mailbox does not support mod-sequences.', 'MBOXNOMODSEQ');
}
$cmd[] = array(
'CHANGEDSINCE',
/* RFC 4551 [3.1] - trying to do a UNCHANGEDSINCE STORE on a
* mailbox that doesn't support it will return BAD. Catch that
* here and throw an exception. */
- throw new Horde_Imap_Client_Exception('Mailbox does not support mod-sequences.', Horde_Imap_Client_Exception::MBOXNOMODSEQ);
+ $this->_exception('Mailbox does not support mod-sequences.', 'MBOXNOMODSEQ');
}
} else {
if (!empty($options['unchangedsince'])) {
if (!$this->queryCapability('ANNOTATEMORE') &&
!$this->queryCapability('ANNOTATEMORE2')) {
- throw new Horde_Imap_Client_Exception('Server does not support the METADATA extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the METADATA extension.', 'NOSUPPORTIMAPEXT');
}
$queries = array();
return array(substr($name, 8), 'value.priv');
}
- throw new Horde_Imap_Client_Exception('Invalid METADATA entry: ' . $name);
+ $this->_exception('Invalid METADATA entry: ' . $name);
}
/**
if (!$this->queryCapability('ANNOTATEMORE') &&
!$this->queryCapability('ANNOTATEMORE2')) {
- throw new Horde_Imap_Client_Exception('Server does not support the METADATA extension.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Server does not support the METADATA extension.', 'NOSUPPORTIMAPEXT');
}
foreach ($data as $md_entry => $value) {
break;
default:
- throw new Horde_Imap_Client_Exception('Invalid METADATA value type ' . $type);
+ $this->_exception('Invalid METADATA value type ' . $type);
}
}
break;
/* RFC 3516 - Send literal8 if we have binary data. */
if (!empty($options['binary'])) {
if (!$this->queryCapability('BINARY')) {
- throw new Horde_Imap_Client_Exception('Can not send binary data to server that does not support it.', Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT);
+ $this->_exception('Can not send binary data to server that does not support it.', 'NOSUPPORTIMAPEXT');
}
$out .= '~';
}
if (!empty($options['literal'])) {
$ob = $this->_getLine();
if ($ob['type'] != 'continuation') {
- throw new Horde_Imap_Client_Exception('Unexpected response from IMAP server while waiting for a continuation request: ' . $ob['line']);
+ $this->_exception('Unexpected response from IMAP server while waiting for a continuation request: ' . $ob['line']);
}
} elseif (empty($options['noparse'])) {
$this->_parseResponse($this->_tag, !empty($options['errignore']));
} else {
$this->_temp['logout'] = true;
$this->logout();
- throw new Horde_Imap_Client_Exception('IMAP Server closed the connection: ' . implode(' ', array_slice($read, 1)), Horde_Imap_Client_Exception::DISCONNECT);
+ $this->_exception('IMAP Server closed the connection: ' . implode(' ', array_slice($read, 1)), 'DISCONNECT');
}
}
if ($this->_debug) {
fwrite($this->_debug, "[ERROR: IMAP server closed the connection.]\n");
}
- throw new Horde_Imap_Client_Exception('IMAP server closed the connection unexpectedly.', Horde_Imap_Client_Exception::DISCONNECT);
+ $this->_exception('IMAP server closed the connection unexpectedly.', 'DISCONNECT');
}
$data = '';
fwrite($this->_debug, "[ERROR: IMAP read/timeout error.]\n");
}
$this->logout();
- throw new Horde_Imap_Client_Exception('IMAP read error or IMAP connection timed out.', Horde_Imap_Client_Exception::SERVER_READERROR);
+ $this->_exception('IMAP read error or IMAP connection timed out.', 'SERVER_READERROR');
}
if ($this->_debug) {
$this->_temp['parseresperr'] = $ob;
if ($ob['response'] == 'BAD') {
- throw new Horde_Imap_Client_Exception('Bad IMAP request: ' . $errstr, $errcode);
+ $this->_exception('Bad IMAP request: ' . $errstr, $errcode);
}
- throw new Horde_Imap_Client_Exception('IMAP error: ' . $errstr, $errcode);
+ $this->_exception('IMAP error: ' . $errstr, $errcode);
}
/* Update the cache, if needed. */
/* @todo Store the list of search charsets supported by the server
* (this is a MAY response, not a MUST response) */
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::BADCHARSET,
+ 'BADCHARSET',
substr($ob['line'], $end_pos + 2)
);
break;
case 'PARSE':
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::PARSEERROR,
+ 'PARSEERROR',
substr($ob['line'], $end_pos + 2)
);
break;
case 'UNKNOWN-CTE':
// Defined by RFC 3516
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::UNKNOWNCTE,
+ 'UNKNOWNCTE',
substr($ob['line'], $end_pos + 2)
);
break;
case 'BADURL':
// Defined by RFC 4469 [4.1]
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::CATENATE_BADURL,
+ 'CATENATE_BADURL',
substr($ob['line'], $end_pos + 2)
);
break;
case 'TOOBIG':
// Defined by RFC 4469 [4.2]
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::CATENATE_TOOBIG,
+ 'CATENATE_TOOBIG',
substr($ob['line'], $end_pos + 2)
);
break;
case 'BADCOMPARATOR':
// Defined by RFC 5255 [4.9]
$this->_temp['parsestatuserr'] = array(
- Horde_Imap_Client_Exception::BADCOMPARATOR,
+ 'BADCOMPARATOR',
substr($ob['line'], $end_pos + 2)
);
break;
case 'UNAVAILABLE':
// Defined by RFC 5530 [3]
- $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_UNAVAILABLE;
+ $this->_temp['loginerr'] = 'LOGIN_UNAVAILABLE';
break;
case 'AUTHENTICATIONFAILED':
// Defined by RFC 5530 [3]
- $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED;
+ $this->_temp['loginerr'] = 'LOGIN_AUTHENTICATIONFAILED';
break;
case 'AUTHORIZATIONFAILED':
// Defined by RFC 5530 [3]
- $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHORIZATIONFAILED;
+ $this->_temp['loginerr'] = 'LOGIN_AUTHORIZATIONFAILED';
break;
case 'EXPIRED':
// Defined by RFC 5530 [3]
- $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_EXPIRED;
+ $this->_temp['loginerr'] = 'LOGIN_EXPIRED';
break;
case 'PRIVACYREQUIRED':
// Defined by RFC 5530 [3]
- $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_PRIVACYREQUIRED;
+ $this->_temp['loginerr'] = 'LOGIN_PRIVACYREQUIRED';
break;
case 'NOPERM':
*/
protected function _getNamespaces()
{
- throw new Horde_Imap_Client_Exception('IMAP namespaces not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP namespaces not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
($this->_params['secure'] == 'tls')) {
// Switch over to a TLS connection.
if (!$this->queryCapability('STLS')) {
- throw new Horde_Imap_Client_Exception('Could not open secure TLS connection to the POP3 server - server does not support TLS.');
+ $this->_exception('Could not open secure TLS connection to the POP3 server - server does not support TLS.');
}
$this->_sendLine('STLS');
if (!$res) {
$this->logout();
- throw new Horde_Imap_Client_Exception('Could not open secure TLS connection to the POP3 server.');
+ $this->_exception('Could not open secure TLS connection to the POP3 server.');
}
// Expire cached CAPABILITY information
}
}
- throw new Horde_Imap_Client_Exception('POP3 server denied authentication.');
+ $this->_exception('POP3 server denied authentication.');
}
/**
}
if (!empty($this->_params['secure']) && !extension_loaded('openssl')) {
- throw new Horde_Imap_Client_Exception('Secure connections require the PHP openssl extension.');
+ $this->_exception('Secure connections require the PHP openssl extension.');
}
switch ($this->_params['secure']) {
if ($this->_stream === false) {
$this->_stream = null;
$this->_isSecure = false;
- throw new Horde_Imap_Client_Exception('Error connecting to POP3 server: [' . $error_number . '] ' . $error_string, Horde_Imap_Client_Exception::SERVER_CONNECT);
+ $this->_exception('Error connecting to POP3 server: [' . $error_number . '] ' . $error_string, 'SERVER_CONNECT');
}
stream_set_timeout($this->_stream, $this->_params['timeout']);
case 'CRAM-MD5':
// RFC 5034
if (!class_exists('Auth_SASL')) {
- throw new Horde_Imap_Client_Exception('The Auth_SASL package is required for CRAM-MD5 authentication');
+ $this->_exception('The Auth_SASL package is required for CRAM-MD5 authentication');
}
$challenge = $this->_sendLine('AUTH CRAM-MD5');
case 'DIGEST-MD5':
// RFC 5034
if (!class_exists('Auth_SASL')) {
- throw new Horde_Imap_Client_Exception('The Auth_SASL package is required for DIGEST-MD5 authentication');
+ $this->_exception('The Auth_SASL package is required for DIGEST-MD5 authentication');
}
$challenge = $this->_sendLine('AUTH DIGEST-MD5');
$sresponse = $this->_sendLine($response, array('debug' => '[DIGEST-MD5 Response]'));
if (stripos(base64_decode(substr($sresponse['line'], 2)), 'rspauth=') === false) {
- throw new Horde_Imap_Client_Exception('Unexpected response from server to Digest-MD5 response.');
+ $this->_exception('Unexpected response from server to Digest-MD5 response.');
}
/* POP3 doesn't use protocol's third step. */
*/
protected function _sendID($info)
{
- throw new Horde_Imap_Client_Exception('IMAP ID command not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ID command not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setLanguage($langs)
{
- throw new Horde_Imap_Client_Exception('IMAP LANGUAGE extension not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP LANGUAGE extension not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getLanguage($list)
{
- throw new Horde_Imap_Client_Exception('IMAP LANGUAGE extension not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP LANGUAGE extension not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
protected function _openMailbox($mailbox, $mode)
{
if (strcasecmp($mailbox, 'INBOX') !== 0) {
- throw new Horde_Imap_Client_Exception('Mailboxes other than INBOX not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Mailboxes other than INBOX not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
$this->login();
*/
protected function _createMailbox($mailbox, $opts)
{
- throw new Horde_Imap_Client_Exception('Creating mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Creating mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _deleteMailbox($mailbox)
{
- throw new Horde_Imap_Client_Exception('Deleting mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Deleting mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _renameMailbox($old, $new)
{
- throw new Horde_Imap_Client_Exception('Renaming mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Renaming mailboxes not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _subscribeMailbox($mailbox, $subscribe)
{
- throw new Horde_Imap_Client_Exception('Mailboxes other than INBOX not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Mailboxes other than INBOX not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
($flags & Horde_Imap_Client::STATUS_PERMFLAGS) ||
($flags & Horde_Imap_Client::STATUS_HIGHESTMODSEQ) ||
($flags & Horde_Imap_Client::STATUS_UIDNOTSTICKY)) {
- throw new Horde_Imap_Client_Exception('Improper status request on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Improper status request on POP3 server.', 'POP3_NOTSUPPORTED');
}
$ret = array();
*/
protected function _append($mailbox, $data, $options)
{
- throw new Horde_Imap_Client_Exception('Appending messages not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Appending messages not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
($sort &&
((count($options['sort']) > 1) ||
($sort != Horde_Imap_Client::SORT_SEQUENCE)))) {
- throw new Horde_Imap_Client_Exception('Server search not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Server search not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
$status = $this->status($this->_selected, Horde_Imap_Client::STATUS_MESSAGES);
*/
protected function _setComparator($comparator)
{
- throw new Horde_Imap_Client_Exception('Search comparators not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Search comparators not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getComparator()
{
- throw new Horde_Imap_Client_Exception('Search comparators not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Search comparators not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _thread($options)
{
- throw new Horde_Imap_Client_Exception('Server threading not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Server threading not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
/**
if (!empty($options['changedsince']) ||
!empty($options['vanished']) ||
(reset($options['ids']) == Horde_Imap_Client::USE_SEARCHRES)) {
- throw new Horde_Imap_Client_Exception('Fetch options not supported on POP3 server.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Fetch options not supported on POP3 server.', 'POP3_NOTSUPPORTED');
}
// Ignore 'sequence' - IDs will always be the message number.
$rawtype = 'header';
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a non-zero MIME ID when retrieving a MIME header.');
+ $this->_exception('Need a non-zero MIME ID when retrieving a MIME header.');
}
break;
$rawtype = 'body';
if (empty($val['id'])) {
- throw new Horde_Imap_Client_Exception('Need a non-zero MIME ID when retrieving a MIME body part.');
+ $this->_exception('Need a non-zero MIME ID when retrieving a MIME body part.');
}
break;
}
$tmp = $ob;
if (empty($val['label'])) {
- throw new Horde_Imap_Client_Exception('Need a unique label when doing a headers field search.');
+ $this->_exception('Need a unique label when doing a headers field search.');
} elseif (empty($val['headers'])) {
- throw new Horde_Imap_Client_Exception('Need headers to query when doing a headers field search.');
+ $this->_exception('Need headers to query when doing a headers field search.');
}
if (empty($val['notsearch'])) {
*/
protected function _copy($dest, $options)
{
- throw new Horde_Imap_Client_Exception('Copying messages not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('Copying messages not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setQuota($root, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getQuota($root)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getQuotaRoot($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP quotas not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP quotas not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setACL($mailbox, $identifier, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getACL($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _listACLRights($mailbox, $identifier)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getMyACLRights($mailbox)
{
- throw new Horde_Imap_Client_Exception('IMAP ACLs not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP ACLs not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _getMetadata($mailbox, $entries, $options)
{
- throw new Horde_Imap_Client_Exception('IMAP metadata not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP metadata not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/**
*/
protected function _setMetadata($mailbox, $data)
{
- throw new Horde_Imap_Client_Exception('IMAP metadata not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED);
+ $this->_exception('IMAP metadata not supported on POP3 servers.', 'POP3_NOTSUPPORTED');
}
/* Internal functions. */
if (feof($this->_stream)) {
$this->logout();
- throw new Horde_Imap_Client_Exception('POP3 Server closed the connection unexpectedly.', Horde_Imap_Client_Exception::DISCONNECT);
+ $this->_exception('POP3 Server closed the connection unexpectedly.', 'DISCONNECT');
}
$read = rtrim(fgets($this->_stream));
break;
case '-ERR':
- throw new Horde_Imap_Client_Exception('POP3 Error: ' . isset($prefix[1]) ? $prefix[1] : 'no error message');
+ $this->_exception('POP3 Error: ' . isset($prefix[1]) ? $prefix[1] : 'no error message');
case '.':
$ob['response'] = 'END';
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Improved login error reporting (Request #9211).
+ <notes>* Remove static logCallback variable in Horde_Imap_Client_Exception.
+ * Improved login error reporting (Request #9211).
* Add support for special-use mailboxes (draft-ietf-morg-list-specialuse-02).
* Add Horde_Imap_Client_Base::validSearchCharset().
* Add Horde_Imap_Client_Base::fetchFromSectionString().
{
$this->_serverkey = $serverkey;
- /* Register the logging callback. */
- Horde_Imap_Client_Exception::$logCallback = array($this, 'logException');
-
/* Rebuild the Horde_Imap_Client object. */
$this->_loadImapObject();
'hostspec' => isset($server['hostspec']) ? $server['hostspec'] : null,
'id' => empty($server['id']) ? false : $server['id'],
'lang' => empty($server['lang']) ? false : $server['lang'],
+ 'log' => array(__CLASS__, 'logError'),
'password' => $password,
'port' => isset($server['port']) ? $server['port'] : null,
'secure' => isset($server['secure']) ? $server['secure'] : false,
}
/**
- * Logs an exception from Horde_Imap_Client.
- *
- * @param object Horde_Imap_Client_Exception $e The exception object.
- */
- public function logException($e)
- {
- Horde::logMessage($e, 'ERR');
- }
-
- /**
* Get the namespace list.
*
* @return array An array of namespace information.
return $GLOBALS['injector']->getInstance('Horde_Secret')->getKey('imp');
}
+ public function logError($e)
+ {
+ Horde::logMessage($e, 'ERR');
+ }
+
}