$result = new stdClass;
$result->folder = $mbox;
- $result->uids = $GLOBALS['imp_imap']->ob->utils->toSequenceString($indices, array('mailbox' => true));
+ $result->uids = $GLOBALS['imp_imap']->ob()->utils->toSequenceString($indices, array('mailbox' => true));
$result->remove = intval($GLOBALS['prefs']->getValue('hide_deleted') ||
$GLOBALS['prefs']->getValue('use_trash'));
$result->cacheid = $imp_mailbox->getCacheID($mbox);
* the IMAP server (saves some STATUS calls). */
if (!is_null($rw) && !$GLOBALS['imp_search']->isSearchMbox($mbox)) {
try {
- $GLOBALS['imp_imap']->ob->openMailbox($mbox, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
+ $GLOBALS['imp_imap']->ob()->openMailbox($mbox, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
} catch (Horde_Imap_Client_Exception $e) {
return false;
}
// Process common request variables.
$mbox = Horde_Util::getPost('view');
-$indices = $imp_imap->ob->utils->fromSequenceString(Horde_Util::getPost('uid'));
+$indices = $imp_imap->ob()->utils->fromSequenceString(Horde_Util::getPost('uid'));
$cacheid = Horde_Util::getPost('cacheid');
// Open an output buffer to ensure that we catch errors that might break JSON
/* We know we are going to be exclusively dealing with this mailbox, so
* select it on the IMAP server (saves some STATUS calls). Open R/W to
* clear the RECENT flag. */
- $imp_imap->ob->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->ob()->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
$show_msg = new IMP_Views_ShowMessage();
$result = (object)$show_msg->showMessage($args);
/* Get the IMP_Headers:: object. */
try {
- $fetch_ret = $imp_imap->ob->fetch($mbox, array(
+ $fetch_ret = $imp_imap->ob()->fetch($mbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($index)));
} catch (Horde_Imap_Client_Exception $e) {
/* Open the mailbox R/W so we ensure the 'recent' flags are cleared from
* the current mailbox. */
foreach ($newmsgs as $mbox => $nm) {
- $imp_imap->ob->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->ob()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
if ($prefs->getValue('nav_popup')) {
return false;
}
- return $GLOBALS['imp_imap']->ob->fetch($mailbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices));
+ return $GLOBALS['imp_imap']->ob()->fetch($mailbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices));
}
/**
return false;
}
- return $GLOBALS['imp_imap']->ob->getCacheId($mailbox);
+ return $GLOBALS['imp_imap']->ob()->getCacheId($mailbox);
}
/**
}
// Check for valid IMAP Client object.
- if (!$GLOBALS['imp_imap']->ob) {
+ if (!$GLOBALS['imp_imap']->ob()) {
if (!isset($credentials['userId']) ||
!isset($credentials['password'])) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
}
try {
- $GLOBALS['imp_imap']->ob->login();
+ $GLOBALS['imp_imap']->ob()->login();
} catch (Horde_Imap_Client_Exception $e) {
self::logMessage($e->getMessage(), __FILE__, __LINE__);
if ($e->getCode() == Horde_Imap_Client_Exception::SERVER_CONNECT) {
break;
}
- $imp_imap = $GLOBALS['imp_imap']->ob;
+ $imap_ob = $GLOBALS['imp_imap']->ob();
$msg = sprintf(
$status_msg . ' for %s [%s]%s to {%s:%s [%s]}',
empty($_SESSION['imp']['uniquser']) ? '' : $_SESSION['imp']['uniquser'],
$_SERVER['REMOTE_ADDR'],
empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : ' (forwarded for [' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '])',
- $imp_imap ? $imp_imap->getParam('hostspec') : '',
- $imp_imap ? $imp_imap->getParam('port') : '',
+ $imap_ob ? $imap_ob->getParam('hostspec') : '',
+ $imap_ob ? $imap_ob->getParam('port') : '',
empty($_SESSION['imp']['protocol']) ? '' : $_SESSION['imp']['protocol']
);
$shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown'];
try {
- $fetch_ret = $GLOBALS['imp_imap']->ob->fetch('INBOX', array(
+ $fetch_ret = $GLOBALS['imp_imap']->ob()->fetch('INBOX', array(
Horde_Imap_Client::FETCH_ENVELOPE => true
), array('ids' => array_slice($ids, 0, $shown)));
reset($fetch_ret);
/* Open the mailbox R/W to ensure the 'recent' flags are cleared
* from the current mailbox. */
foreach ($newmsgs as $mbox => $nm) {
- $GLOBALS['imp_imap']->ob->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
+ $GLOBALS['imp_imap']->ob()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
if ($prefs->getValue('nav_popup')) {
/* Add the message to the mailbox. */
try {
- $ids = $GLOBALS['imp_imap']->ob->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags, 'messageid' => $headers->getValue('message-id'))));
+ $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags, 'messageid' => $headers->getValue('message-id'))));
$this->_metadata['draft_index'] = reset($ids);
$this->_modified = true;
return sprintf(_("The draft has been saved to the \"%s\" folder."), IMP::displayFolder($drafts_mbox));
}
try {
- $GLOBALS['imp_imap']->ob->append(Horde_String::convertCharset($opts['sent_folder'], Horde_Nls::getCharset(), 'UTF-8'), array(array('data' => $fcc, 'flags' => $flags)));
+ $GLOBALS['imp_imap']->ob()->append(Horde_String::convertCharset($opts['sent_folder'], Horde_Nls::getCharset(), 'UTF-8'), array(array('data' => $fcc, 'flags' => $flags)));
} catch (Horde_Imap_Client_Exception $e) {
$notification->push(sprintf(_("Message sent successfully, but not saved to %s"), IMP::displayFolder($opts['sent_folder'])));
$sent_saved = false;
* current IMAP / POP3 connection are valid for SMTP authentication as
* well. */
if (!empty($params['auth']) && empty($params['username'])) {
- $params['username'] = $GLOBALS['imp_imap']->ob->getParam('username');
- $params['password'] = $GLOBALS['imp_imap']->ob->getParam('password');
+ $params['username'] = $GLOBALS['imp_imap']->ob()->getParam('username');
+ $params['password'] = $GLOBALS['imp_imap']->ob()->getParam('password');
}
return array('driver' => $GLOBALS['conf']['mailer']['type'], 'params' => $params);
$subject = $h->getValue('subject');
$header['subject'] = empty($subject)
? 'Re: '
- : 'Re: ' . $GLOBALS['imp_imap']->ob->utils->getBaseSubject($subject, array('keepblob' => true));
+ : 'Re: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($subject, array('keepblob' => true));
if (in_array($actionID, array('reply', '*'))) {
($header['to'] = $to) ||
$header['subject'] = $h->getValue('subject');
if (!empty($header['subject'])) {
$header['title'] = _("Forward") . ': ' . $header['subject'];
- $header['subject'] = 'Fwd: ' . $GLOBALS['imp_imap']->ob->utils->getBaseSubject($header['subject'], array('keepblob' => true));
+ $header['subject'] = 'Fwd: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($header['subject'], array('keepblob' => true));
} else {
$header['title'] = _("Forward");
$header['subject'] = 'Fwd:';
} else {
$name = Horde_String::truncate($name, 80);
}
- return 'Fwd: ' . $GLOBALS['imp_imap']->ob->utils->getBaseSubject($name, array('keepblob' => true));
+ return 'Fwd: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($name, array('keepblob' => true));
} else {
return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
}
/* Get the Horde_Mime_Part object for the given index. */
try {
- $ret = $GLOBALS['imp_imap']->ob->fetch($this->_mailbox, array(
+ $ret = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true)
), array('ids' => array($this->_index)));
} catch (Horde_Imap_Client_Exception $e) {
}
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($this->_mailbox, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_BODYTEXT => array(array('peek' => true, 'stream' => !empty($options['stream'])))
), array('ids' => array($this->_index)));
return $res[$this->_index]['bodytext'][0];
}
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($this->_mailbox, $query, array('ids' => array($this->_index)));
+ $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, $query, array('ids' => array($this->_index)));
if (empty($options['mimeheaders'])) {
if (!empty($res[$this->_index]['bodypartdecode'][$id])) {
$this->lastBodyPartDecode = $res[$this->_index]['bodypartdecode'][$id];
}
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($this->_mailbox, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('peek' => true)),
Horde_Imap_Client::FETCH_BODYTEXT => array(array('peek' => true, 'stream' => !empty($options['stream'])))
), array('ids' => array($this->_index)));
}
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($this->_mailbox, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => true))
), array('ids' => array($this->_index)));
return $res[$this->_index]['headertext'][0];
}
try {
- $GLOBALS['imp_imap']->ob->deleteMailbox($folder);
+ $GLOBALS['imp_imap']->ob()->deleteMailbox($folder);
$notification->push(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), 'horde.success');
$deleted[] = $folder;
} catch (Horde_Imap_Client_Exception $e) {
/* Attempt to create the mailbox. */
try {
- $GLOBALS['imp_imap']->ob->createMailbox($folder);
+ $GLOBALS['imp_imap']->ob()->createMailbox($folder);
} catch (Horde_Imap_Client_Exception $e) {
$notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), IMP::displayFolder($folder)) . ': ' . $e->getMessage(), 'horde.error');
return false;
}
try {
- $ret = $GLOBALS['imp_imap']->ob->listMailboxes($folder, array('flat' => true));
+ $ret = $GLOBALS['imp_imap']->ob()->listMailboxes($folder, array('flat' => true));
return !empty($ret);
} catch (Horde_Imap_Client_Exception $e) {
return false;
$sub_folders = $imaptree->folderList();
try {
- $GLOBALS['imp_imap']->ob->renameMailbox($old, $new);
+ $GLOBALS['imp_imap']->ob()->renameMailbox($old, $new);
} catch (Horde_Imap_Client_Exception $e) {
$GLOBALS['notification']->push(sprintf(_("Renaming \"%s\" to \"%s\" failed. This is what the server said"), IMP::displayFolder($old), IMP::displayFolder($new)) . ': ' . $e->getMessage(), 'horde.error');
return false;
foreach (array_filter($folders) as $folder) {
try {
- $GLOBALS['imp_imap']->ob->subscribeMailbox($folder, true);
+ $GLOBALS['imp_imap']->ob()->subscribeMailbox($folder, true);
$notification->push(sprintf(_("You were successfully subscribed to \"%s\""), IMP::displayFolder($folder)), 'horde.success');
$subscribed[] = $folder;
} catch (Horde_Imap_Client_Exception $e) {
$notification->push(sprintf(_("You cannot unsubscribe from \"%s\"."), IMP::displayFolder($folder)), 'horde.error');
} else {
try {
- $GLOBALS['imp_imap']->ob->subscribeMailbox($folder, false);
+ $GLOBALS['imp_imap']->ob()->subscribeMailbox($folder, false);
$notification->push(sprintf(_("You were successfully unsubscribed from \"%s\""), IMP::displayFolder($folder)), 'horde.success');
$unsubscribed[] = $folder;
} catch (Horde_Imap_Client_Exception $e) {
foreach ($folder_list as $folder) {
try {
- $status = $GLOBALS['imp_imap']->ob->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['imp_imap']->ob()->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
} catch (Horde_Imap_Client_Exception $e) {
continue;
}
/* Download one message at a time to save on memory
* overhead. */
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($folder, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($folder, array(
Horde_Imap_Client::FETCH_FULLMSG => array('peek' => true, 'stream' => true),
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_DATE => true,
if (preg_match('/From (.+@.+|- )/A', $line)) {
if (!empty($message)) {
try {
- $GLOBALS['imp_imap']->ob->append($folder, array(array('data' => $message)));
+ $GLOBALS['imp_imap']->ob()->append($folder, array(array('data' => $message)));
++$msgcount;
} catch (Horde_Imap_Client_Exception $e) {}
}
if (!empty($message)) {
try {
- $GLOBALS['imp_imap']->ob->append($folder, array(array('data' => $message)));
+ $GLOBALS['imp_imap']->ob()->append($folder, array(array('data' => $message)));
++$msgcount;
} catch (Horde_Imap_Client_Exception $e) {}
}
if (!$search_mbox &&
!empty($GLOBALS['conf']['server']['sort_limit'])) {
try {
- $status = $GLOBALS['imp_imap']->ob->status($mbox, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_MESSAGES);
if ($status['messages'] > $GLOBALS['conf']['server']['sort_limit']) {
$ob['limit'] = true;
$ob['by'] = Horde_Imap_Client::SORT_ARRIVAL;
$val = $this->getValue('from_addr', $ident);
if (empty($val)) {
- $val = $GLOBALS['imp_imap']->ob->getParam('username');
+ $val = $GLOBALS['imp_imap']->ob()->getParam('username');
}
if (!strstr($val, '@')) {
*
* @var Horde_Imap_Client
*/
- public $ob = null;
+ protected $_ob = null;
/**
* Is connection read-only?
/* Only need to serialize object once a session. When we do
* serialize, make sure we login in order to ensure we have done the
* necessary initialization. */
- if ($this->ob &&
+ if ($this->_ob &&
isset($_SESSION['imp']) &&
!isset($_SESSION['imp']['imap_ob'])) {
- $this->ob->login();
+ $this->_ob->login();
/* First login may occur on a non-viewable page. However,
* any login alerts received should be displayed to the user at
* some point. We need to do an explicit grab of the alarms
* right now. */
$notification = Horde_Notification::singleton();
- foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) {
+ foreach ($this->_ob->alerts() as $alert) {
$notification->push($alert, 'horde.warning');
}
- $_SESSION['imp']['imap_ob'] = serialize($this->ob);
+ $_SESSION['imp']['imap_ob'] = serialize($this->_ob);
}
}
*/
protected function _loadImapObject()
{
- if (!is_null($this->ob)) {
+ if (!is_null($this->_ob)) {
return true;
}
Horde_Imap_Client::$encryptKey = Horde_Secret::getKey('imp');
$old_error = error_reporting(0);
- $this->ob = unserialize($_SESSION['imp']['imap_ob']);
+ $this->_ob = unserialize($_SESSION['imp']['imap_ob']);
error_reporting($old_error);
- if (empty($this->ob)) {
+ if (empty($this->_ob)) {
// @todo How to handle bad unserialize?
// @todo Log message
return false;
public function createImapObject($username, $password, $key,
$global = true)
{
- if ($global && !is_null($this->ob)) {
+ if ($global && !is_null($this->_ob)) {
return $GLOBALS['imp_imap'];
}
}
if ($global) {
- $this->ob = $ob;
+ $this->_ob = $ob;
$this->_postcreate($protocol);
}
($_SESSION['imp']['protocol'] == 'imap') &&
!$GLOBALS['imp_search']->isSearchMbox($mailbox)) {
try {
- $status = $this->ob->status($mailbox, Horde_Imap_Client::STATUS_UIDNOTSTICKY);
+ $status = $this->_ob->status($mailbox, Horde_Imap_Client::STATUS_UIDNOTSTICKY);
$res = $status['uidnotsticky'];
} catch (Horde_Imap_Client_Exception $e) {}
}
}
if (!isset($this->_uidvalid[$mailbox])) {
- $status = $this->ob->status($mailbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
+ $status = $this->_ob->status($mailbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
$ptr = &$_SESSION['imp']['cache'];
$val = isset($ptr['uidvalid'][$mailbox])
? $ptr['uidvalid'][$mailbox]
public function getNamespaceList()
{
try {
- return $GLOBALS['imp_imap']->ob->getNamespaces(!empty($_SESSION['imp']['imap_ext']['namespace']) ? $_SESSION['imp']['imap_ext']['namespace'] : array());
+ return $this->_ob->getNamespaces(!empty($_SESSION['imp']['imap_ext']['namespace']) ? $_SESSION['imp']['imap_ext']['namespace'] : array());
} catch (Horde_Imap_Client_Exception $e) {
// @todo Error handling
return array();
return $ns_info['name'] . $mbox;
}
+ /**
+ * Return the Horde_Imap_Client object.
+ *
+ * @return Horde_Imap_Client The imap object.
+ */
+ public function ob()
+ {
+ return $this->_ob;
+ }
+
}
throw new Horde_Exception(_("ACL requires an IMAP server."));
}
- $capability = $GLOBALS['imp_imap']->ob->queryCapability('ACL');
+ $capability = $GLOBALS['imp_imap']->ob()->queryCapability('ACL');
if (!$capability) {
throw new Horde_Exception(_("IMAP server does not support ACLs."));
}
- $rfc4314 = $GLOBALS['imp_imap']->ob->queryCapability('RIGHTS');
+ $rfc4314 = $GLOBALS['imp_imap']->ob()->queryCapability('RIGHTS');
- $this->_protected = array($GLOBALS['imp_imap']->ob->getParam('username'));
+ $this->_protected = array($GLOBALS['imp_imap']->ob()->getParam('username'));
$this->_rightsList = array(
'l' => array(
public function getACL($mbox)
{
try {
- return $GLOBALS['imp_imap']->ob->getACL($mbox);
+ return $GLOBALS['imp_imap']->ob()->getACL($mbox);
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Exception(_("Could not retrieve ACL"));
}
public function editACL($mbox, $user, $acl)
{
try {
- $GLOBALS['imp_imap']->ob->setACL($mbox, $user, array('rights' => $acl));
+ $GLOBALS['imp_imap']->ob()->setACL($mbox, $user, array('rights' => $acl));
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Exception(sprintf(_("Couldn't give user \"%s\" the following rights for the folder \"%s\": %s"), $user, $mbox, implode('', $acl)));
}
public function canEdit($mbox, $user)
{
try {
- $rights = $GLOBALS['imp_imap']->ob->listACLRights($mbox, $user);
+ $rights = $GLOBALS['imp_imap']->ob()->listACLRights($mbox, $user);
foreach ($rights as $val) {
if (strpos($val, 'a') !== false) {
return true;
* from the PERMANENTFLAGS IMAP response. */
if (!empty($options['mailbox'])) {
try {
- $status = $GLOBALS['imp_imap']->ob->status($options['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
+ $status = $GLOBALS['imp_imap']->ob()->status($options['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
if (!in_array('\\*', $status['permflags'])) {
$avail_flags = array_intersect($avail_flags, $status['permflags']);
}
foreach ($this->_namespaces as $key => $val) {
try {
- $names = array_merge($names, $GLOBALS['imp_imap']->ob->listMailboxes($key . '*', $showunsub ? Horde_Imap_Client::MBOX_ALL : Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true)));
+ $names = array_merge($names, $GLOBALS['imp_imap']->ob()->listMailboxes($key . '*', $showunsub ? Horde_Imap_Client::MBOX_ALL : Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true)));
if ($showunsub) {
$this->_fulllist = $names;
} else {
public function getElementInfo($name)
{
try {
- return $GLOBALS['imp_imap']->ob->status($name, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN);
+ return $GLOBALS['imp_imap']->ob()->status($name, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN);
} catch (Horde_Imap_Client_Exception $e) {
return array();
}
$cache = null;
$options['preview'] = 0;
} else {
- $cache = $GLOBALS['imp_imap']->ob->getCache();
+ $cache = $GLOBALS['imp_imap']->ob()->getCache();
}
/* Retrieve information from each mailbox. */
foreach ($to_process as $mbox => $ids) {
try {
- $fetch_res = $GLOBALS['imp_imap']->ob->fetch($mbox, $fetch_criteria, array('ids' => array_keys($ids)));
+ $fetch_res = $GLOBALS['imp_imap']->ob()->fetch($mbox, $fetch_criteria, array('ids' => array_keys($ids)));
if ($options['preview']) {
$preview_info = $tostore = array();
$uids[$mbox] = array_keys($fetch_res);
if (!is_null($cache) && !empty($tostore)) {
- $status = $GLOBALS['imp_imap']->ob->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
+ $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
$cache->set($mbox, $tostore, $status['uidvalidity']);
}
} catch (Horde_Imap_Client_Exception $e) {}
$query->flag('\\deleted', false);
}
try {
- $res = $GLOBALS['imp_imap']->ob->search($this->_mailbox, $query, array('sort' => array($sortpref['by']), 'reverse' => (bool)$sortpref['dir']));
+ $res = $GLOBALS['imp_imap']->ob()->search($this->_mailbox, $query, array('sort' => array($sortpref['by']), 'reverse' => (bool)$sortpref['dir']));
$this->_sorted = $res['sort'];
} catch (Horde_Imap_Client_Exception $e) {
$this->_sorted = array();
$criteria->flag('\\deleted', false);
} elseif ($count) {
try {
- $status_res = $GLOBALS['imp_imap']->ob->status($this->_mailbox, $type == 'recent' ? Horde_Imap_Client::STATUS_RECENT : Horde_Imap_Client::STATUS_UNSEEN);
+ $status_res = $GLOBALS['imp_imap']->ob()->status($this->_mailbox, $type == 'recent' ? Horde_Imap_Client::STATUS_RECENT : Horde_Imap_Client::STATUS_UNSEEN);
return $status_res[$type];
} catch (Horde_Imap_Client_Exception $e) {
return 0;
}
try {
- $res = $GLOBALS['imp_imap']->ob->search($this->_mailbox, $criteria, array('results' => array($results), 'sequence' => true));
+ $res = $GLOBALS['imp_imap']->ob()->search($this->_mailbox, $criteria, array('results' => array($results), 'sequence' => true));
return $count ? $res['count'] : $res;
} catch (Horde_Imap_Client_Exception $e) {
return $count ? 0 : array();
$ret['anymsg'] = true;
if (!$ret['msgcount'] && !$this->_searchmbox) {
try {
- $status = $GLOBALS['imp_imap']->ob->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['imp_imap']->ob()->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
$ret['anymsg'] = (bool)$status['messages'];
} catch (Horde_Imap_Client_Exception $e) {
$ret['anymsg'] = false;
* information is returned via a SELECT/EXAMINE call. */
if ($sortpref['by'] == Horde_Imap_Client::SORT_ARRIVAL) {
try {
- $res = $GLOBALS['imp_imap']->ob->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
+ $res = $GLOBALS['imp_imap']->ob()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
if (!is_null($res['firstunseen'])) {
return $res['firstunseen'];
}
{
if (is_null($this->_threadob)) {
try {
- $this->_threadob = $GLOBALS['imp_imap']->ob->thread($this->_mailbox);
+ $this->_threadob = $GLOBALS['imp_imap']->ob()->thread($this->_mailbox);
$ref_errcode = null;
} catch (Horde_Imap_Client_Exception $e) {
$ref_errcode = $e->getCode();
if ($ref_errcode == Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT) {
try {
- $this->_threadob = $GLOBALS['imp_imap']->ob->thread($this->_mailbox, array('criteria' => Horde_Imap_Client::THREAD_ORDEREDSUBJECT));
+ $this->_threadob = $GLOBALS['imp_imap']->ob()->thread($this->_mailbox, array('criteria' => Horde_Imap_Client::THREAD_ORDEREDSUBJECT));
} catch (Horde_Imap_Client_Exception $e) {
$GLOBALS['notification']->push(_("Server does not support thread sorting."), 'horde.error');
return new Horde_Imap_Client_Thread(array(), 'uid');
if (!$this->_searchmbox) {
$sortpref = IMP::getSort($this->_mailbox);
try {
- $id = $GLOBALS['imp_imap']->ob->getCacheId($this->_mailbox);
+ $id = $GLOBALS['imp_imap']->ob()->getCacheId($this->_mailbox);
return $id . '|' . $sortpref['by'] . '|' . $sortpref['dir'];
} catch (Horde_Imap_Client_Exception $e) {}
}
/* Attempt to copy/move messages to new mailbox. */
if (!$error) {
try {
- $GLOBALS['imp_imap']->ob->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
+ $GLOBALS['imp_imap']->ob()->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
$imp_mailbox = IMP_Mailbox::singleton($mbox);
if (($action == 'move') && $imp_mailbox->isBuilt()) {
/* Trash is only valid for IMAP mailboxes. */
if ($use_trash_folder && ($mbox != $trash)) {
try {
- $GLOBALS['imp_imap']->ob->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true));
+ $GLOBALS['imp_imap']->ob()->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true));
$imp_mailbox = IMP_Mailbox::singleton($mbox);
if ($imp_mailbox->isBuilt()) {
$fetch = null;
if ($maillog_update) {
try {
- $fetch = $GLOBALS['imp_imap']->ob->fetch($mbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $msgIndices));
+ $fetch = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $msgIndices));
} catch (Horde_Imap_Client_Exception $e) {}
}
}
try {
- $GLOBALS['imp_imap']->ob->store($mbox, array('add' => array('\\deleted'), 'ids' => $msgIndices));
+ $GLOBALS['imp_imap']->ob()->store($mbox, array('add' => array('\\deleted'), 'ids' => $msgIndices));
if ($expunge_now) {
$this->expungeMailbox($indices_array);
}
/* Get the headers for the message. */
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($mbox, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('peek' => true)),
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_FLAGS => true
unset($res['flags'][$pos]);
}
- $uid = $GLOBALS['imp_imap']->ob->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id'])));
+ $uid = $GLOBALS['imp_imap']->ob()->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id'])));
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Exception(_("An error occured while attempting to strip the attachment."));
}
if (!$error) {
/* Flag/unflag the messages now. */
try {
- $GLOBALS['imp_imap']->ob->store($mbox, array_merge($action_array, array('ids' => $msgIndices)));
+ $GLOBALS['imp_imap']->ob()->store($mbox, array_merge($action_array, array('ids' => $msgIndices)));
} catch (Horde_Imap_Client_Exception $e) {
$error = $e->getMessage();
}
foreach ($mboxes as $val) {
try {
- $GLOBALS['imp_imap']->ob->store($val, $action_array);
+ $GLOBALS['imp_imap']->ob()->store($val, $action_array);
} catch (Horde_Imap_Client_Exception $e) {
return false;
}
}
try {
- $update_list[$key] = $GLOBALS['imp_imap']->ob->expunge($key, array('ids' => is_array($val) ? $val : array(), 'list' => $msg_list));
+ $update_list[$key] = $GLOBALS['imp_imap']->ob()->expunge($key, array('ids' => is_array($val) ? $val : array(), 'list' => $msg_list));
$imp_mailbox = IMP_Mailbox::singleton($key);
if ($imp_mailbox->isBuilt()) {
/* Make sure there is at least 1 message before attempting to
delete. */
try {
- $status = $GLOBALS['imp_imap']->ob->status($mbox, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_MESSAGES);
if (empty($status['messages'])) {
$notification->push(sprintf(_("The mailbox %s is already empty."), $display_mbox), 'horde.message');
continue;
$this->flagAllInMailbox(array('\\deleted'), array($mbox), true);
$this->expungeMailbox(array($mbox => 1));
} else {
- $ret = $GLOBALS['imp_imap']->ob->search($mbox);
+ $ret = $GLOBALS['imp_imap']->ob()->search($mbox);
$indices = array($mbox => $ret['match']);
$this->delete($indices);
}
public function sizeMailbox($mbox, $formatted = true)
{
try {
- $res = $GLOBALS['imp_imap']->ob->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
+ $res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
$size = 0;
reset($res);
/* Display IMAP alerts. */
if (isset($GLOBALS['imp_imap']->ob)) {
- foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) {
+ foreach ($GLOBALS['imp_imap']->ob()->alerts() as $alert) {
$GLOBALS['notification']->push($alert, 'horde.warning');
}
}
public function notify(&$messageStack, $options = array())
{
/* Display IMAP alerts. */
- foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) {
+ foreach ($GLOBALS['imp_imap']->ob()->alerts() as $alert) {
$GLOBALS['notification']->push($alert, 'horde.warning');
}
public function getQuota()
{
try {
- $quota = $GLOBALS['imp_imap']->ob->getQuotaRoot($GLOBALS['imp_search']->isSearchMbox($GLOBALS['imp_mbox']['mailbox']) ? 'INBOX' : $GLOBALS['imp_mbox']['mailbox']);
+ $quota = $GLOBALS['imp_imap']->ob()->getQuotaRoot($GLOBALS['imp_search']->isSearchMbox($GLOBALS['imp_mbox']['mailbox']) ? 'INBOX' : $GLOBALS['imp_mbox']['mailbox']);
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Exception(_("Unable to retrieve quota"), 'horde.error');
}
}
foreach ($search['folders'] as $val) {
- $results = $GLOBALS['imp_imap']->ob->search($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
+ $results = $GLOBALS['imp_imap']->ob()->search($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
foreach ($results['sort'] as $val2) {
$sorted[] = $val2 . IMP::IDX_SEP . $val;
}
$sortdir = null)
{
try {
- $results = $GLOBALS['imp_imap']->ob->search($mailbox, $query, array('reverse' => $sortdir, 'sort' => array($sortby)));
+ $results = $GLOBALS['imp_imap']->ob()->search($mailbox, $query, array('reverse' => $sortdir, 'sort' => array($sortby)));
return $results['sort'];
} catch (Horde_Imap_Client_Exception $e) {
return array();
/* See if we have already processed this message. */
/* 1st test: $MDNSent keyword (RFC 3503 [3.1]). */
try {
- $status = $GLOBALS['imp_imap']->ob->status($mailbox, Horde_Imap_Client::STATUS_PERMFLAGS);
+ $status = $GLOBALS['imp_imap']->ob()->status($mailbox, Horde_Imap_Client::STATUS_PERMFLAGS);
if (in_array('\\*', $status['permflags']) ||
in_array('$mdnsent', $status['permflags'])) {
$mdn_flag = true;
- $res = $GLOBALS['imp_imap']->ob->fetch($mailbox, array(
+ $res = $GLOBALS['imp_imap']->ob()->fetch($mailbox, array(
Horde_Imap_Client::FETCH_FLAGS => true
), array('ids' => array($uid)));
$mdn_sent = in_array('$mdnsent', $res[$uid]['flags']);
!empty($args['cache'])) {
$uid_expire = false;
try {
- $status = $GLOBALS['imp_imap']->ob->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
+ $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
list($old_uidvalid,) = explode('|', $args['cacheid']);
$uid_expire = ($old_uidvalid != $status['uidvalidity']);
} catch (Horde_Imap_Cache_Exception $e) {
if (isset($md->search)) {
$cached = Horde_Serialize::unserialize($args['cache'], Horde_Serialize::JSON);
} else {
- $cached = $GLOBALS['imp_imap']->ob->utils->fromSequenceString($args['cached']);
+ $cached = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($args['cached']);
$cached = reset($cached);
}
$cached = array_flip($cached);
/* Get envelope/header information. We don't use flags in this
* view. */
try {
- $fetch_ret = $GLOBALS['imp_imap']->ob->fetch($mailbox, array(
+ $fetch_ret = $GLOBALS['imp_imap']->ob()->fetch($mailbox, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($index)));
* select it on the IMAP server (saves some STATUS calls). Open R/W to clear
* the RECENT flag. */
if (!$search_mbox) {
- $imp_imap->ob->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
}
/* Determine if mailbox is readonly. */
break;
case 'view_messages':
- $redirect = Horde_Util::addParameter(IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], null, null, false), array('mode' => 'msgview', 'msglist' => $GLOBALS['imp_imap']->ob->utils->toSequenceString(IMP::parseIndicesList($indices), array('mailbox' => true))), null, false);
+ $redirect = Horde_Util::addParameter(IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], null, null, false), array('mode' => 'msgview', 'msglist' => $GLOBALS['imp_imap']->ob()->utils->toSequenceString(IMP::parseIndicesList($indices), array('mailbox' => true))), null, false);
header('Location: ' . $redirect);
exit;
}
if (!empty($newmsgs)) {
/* Open the mailbox R/W so we ensure the 'recent' flags are cleared from
* the current mailbox. */
- $imp_imap->ob->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
if (!Horde_Util::getFormData('no_newmail_popup')) {
/* Newmail audio. */
try {
/* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
* before we can grab it. */
- $flags_ret = $imp_imap->ob->fetch($mailbox_name, array(
+ $flags_ret = $imp_imap->ob()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($index)));
- $fetch_ret = $imp_imap->ob->fetch($mailbox_name, array(
+ $fetch_ret = $imp_imap->ob()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $readonly))
), array('ids' => array($index)));
* select it on the IMAP server (saves some STATUS calls). Open R/W to clear
* the RECENT flag. */
if (!$imp_search->isSearchMbox($imp_mbox['mailbox'])) {
- $imp_imap->ob->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
}
/* Make sure we have a valid index. */
try {
/* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
* before we can grab it. */
- $flags_ret = $imp_imap->ob->fetch($mailbox_name, array(
+ $flags_ret = $imp_imap->ob()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($index)));
- $fetch_ret = $imp_imap->ob->fetch($mailbox_name, array(
+ $fetch_ret = $imp_imap->ob()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $peek))
), array('ids' => array($index)));
}
} else {
/* MSGVIEW MODE: Make sure we have a valid list of messages. */
- $msglist = $GLOBALS['imp_imap']->ob->utils->fromSequenceString(Horde_Util::getFormData('msglist'));
+ $msglist = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString(Horde_Util::getFormData('msglist'));
if (empty($msglist)) {
$error = true;
}
$imp_ui = new IMP_UI_Message();
foreach ($loop_array as $mbox => $idxlist) {
- $fetch_res = $GLOBALS['imp_imap']->ob->fetch($mbox, array(
+ $fetch_res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(
Horde_Imap_Client::FETCH_ENVELOPE => true
), array('ids' => $idxlist));