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). |
/** * All other calls to this class are routed to the underlying * Horde_Imap_Client_Base object. * * @param string $method Method name. * @param array $params Method parameters. * * @return mixed The return from the requested method. * @throws BadMethodCallException * @throws IMP_Imap_Exception */ public function __call($method, $params) { global $injector; if (!$this->init) { /* Fallback for these methods. */ switch ($method) { case 'getIdsOb': $ob = new Horde_Imap_Client_Ids(); call_user_func_array(array($ob, 'add'), $params); return $ob; } throw new Horde_Exception_AuthenticationFailure('IMP is marked as authenticated, but no credentials can be found in the session.', Horde_Auth::REASON_SESSION); } switch ($method) { case 'append': case 'createMailbox': case 'deleteMailbox': case 'expunge': case 'fetch': case 'getACL': case 'getMetadata': case 'getMyACLRights': case 'getQuota': case 'getQuotaRoot': case 'getSyncToken': case 'setMetadata': case 'setQuota': case 'store': case 'subscribeMailbox': case 'sync': case 'thread': // Horde_Imap_Client_Mailbox: these calls all have the mailbox as // their first parameter. $params[0] = IMP_Mailbox::getImapMboxOb($params[0]); break; case 'copy': case 'renameMailbox': // These calls may hit multiple servers. $source = IMP_Mailbox::get($params[0]); $dest = IMP_Mailbox::get($params[1]); if ($source->remote_account != $dest->remote_account) { return call_user_func_array(array($this, '_' . $method), $params); } // Horde_Imap_Client_Mailbox: these calls all have the mailbox as // their first two parameters. $params[0] = $source->imap_mbox_ob; $params[1] = $dest->imap_mbox_ob; break; case 'getNamespaces': if (isset($this->_temp['ns'])) { return $this->_temp['ns']; } $nsconfig = $this->config->namespace; $params[0] = is_null($nsconfig) ? array() : $nsconfig; $params[1] = array('ob_return' => true); break; case 'impStatus': /* Internal method: allows status call with array of mailboxes, * guaranteeing they are all on this server. */ $params[0] = IMP_Mailbox::getImapMboxOb($params[0]); $method = 'status'; break; case 'openMailbox': $mbox = IMP_Mailbox::get($params[0]); if ($mbox->search) { /* Can't open a search mailbox. */ return; } $params[0] = $mbox->imap_mbox_ob; break; case 'search': $params = call_user_func_array(array($this, '_search'), $params); break; case 'status': if (is_array($params[0])) { return $this->_status($params); } $params[0] = IMP_Mailbox::getImapMboxOb($params[0]); break; default: if (!method_exists($this->_ob, $method)) { throw new BadMethodCallException(sprintf('%s: Invalid method call "%s".', __CLASS__, $method)); } break; } try { $result = call_user_func_array(array($this->_ob, $method), $params); } catch (Horde_Imap_Client_Exception $e) { switch ($method) { case 'getNamespaces': return new Horde_Imap_Client_Namespace_List(); } Horde::log(new Exception(sprintf('[%s] %s', $method, $e->raw_msg), $e->getCode(), $e), 'WARN'); $error = new IMP_Imap_Exception($e); throw ($auth_e = $error->authException(false)) ? $auth_e : $error; } /* Special handling for various methods. */ switch ($method) { case 'createMailbox': case 'deleteMailbox': case 'renameMailbox': $injector->getInstance('IMP_Mailbox_SessionCache')->expire(null, IMP_Mailbox::get($params[0])); break; case 'getNamespaces': $this->_temp['ns'] = $result; break; case 'login': if (!$this->_ob->getParam('imp:login')) { /* Check for POP3 UIDL support. */ if ($this->isPop3() && !$this->queryCapability('UIDL')) { Horde::log(sprintf('The POP3 server does not support the REQUIRED UIDL capability. [server key: %s]', $this->server_key), 'CRIT'); throw new Horde_Exception_AuthenticationFailure(_("The mail server is not currently avaliable."), Horde_Auth::REASON_MESSAGE); } $this->_ob->setParam('imp:login', true); $this->_changed = true; } break; case 'setACL': $injector->getInstance('IMP_Mailbox_SessionCache')->expire(IMP_Mailbox_SessionCache::CACHE_ACL, IMP_Mailbox::get($params[0])); break; } return $result; }