}
try {
- $elt_info = $imp_imap->ob()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
+ $elt_info = $injector->getInstance('IMP_Imap')->getOb()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
} catch (Horde_Imap_Client_Exception $e) {
$elt_info = null;
}
/* 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);
+ $injector->getInstance('IMP_Imap')->getOb()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
IMP::newmailAlerts($newmsgs);
$result = new stdClass;
$result->poll = array();
- foreach ($GLOBALS['imp_imap']->ob()->statusMultiple($GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
+ foreach ($GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->statusMultiple($GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
$result->poll[$key] = intval($val['unseen']);
}
if ($this->_vars->add) {
$imptree->addPollList($this->_vars->view);
try {
- if ($info = $GLOBALS['imp_imap']->ob()->status($this->_vars->view, Horde_Imap_Client::STATUS_UNSEEN)) {
+ if ($info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($this->_vars->view, Horde_Imap_Client::STATUS_UNSEEN)) {
$result->poll = array($this->_vars->view => intval($info['unseen']));
}
} catch (Horde_Imap_Client_Exception $e) {}
*/
public function moveMessages()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (!$this->_vars->mboxto || empty($indices)) {
return false;
}
*/
public function copyMessages()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (!$this->_vars->mboxto || empty($indices)) {
return false;
}
*/
public function flagMessages()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (!$this->_vars->flags || empty($indices)) {
return false;
}
*/
public function deleteMessages()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (empty($indices)) {
return false;
}
public function reportSpam()
{
$change = $this->_changed(false);
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
$result = false;
if (IMP_Spam::reportSpam($indices, $this->_vars->spam ? 'spam' : 'notspam')) {
*/
public function blacklist()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (empty($indices)) {
return false;
}
*/
public function showPreview()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
if (count($indices) != 1) {
return false;
}
/* 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. */
- $GLOBALS['imp_imap']->ob()->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
$show_msg = new IMP_Views_ShowMessage();
$result->preview = (object)$show_msg->showMessage($args);
if (isset($result->preview->error)) {
*/
public function purgeDeleted()
{
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
$change = $this->_changed($indices);
if (is_null($change)) {
}
try {
- $fetch_ret = $GLOBALS['imp_imap']->ob()->fetch($this->_vars->view, array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_vars->view, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($this->_vars->uid)));
} catch (Horde_Imap_Client_Exception $e) {
{
$imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->imp_compose);
if (!($imp_contents = $imp_compose->getContentsOb())) {
- $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($this->_vars->uid);
$i = each($indices);
$imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($i['key'], reset($i['value']));
}
protected function _checkUidvalidity($result = false)
{
try {
- $GLOBALS['imp_imap']->checkUidvalidity($this->_vars->view);
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->checkUidvalidity($this->_vars->view);
} catch (IMP_Exception $e) {
if (!is_object($result)) {
$result = new stdClass;
{
$del = new stdClass;
$del->mbox = $this->_vars->view;
- $del->uids = $GLOBALS['imp_imap']->ob()->utils->toSequenceString($indices, array('mailbox' => true));
+ $del->uids = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->toSequenceString($indices, array('mailbox' => true));
$del->remove = intval($GLOBALS['prefs']->getValue('hide_deleted') ||
$GLOBALS['prefs']->getValue('use_trash'));
* on the IMAP server (saves some STATUS calls). */
if (!is_null($rw)) {
try {
- $GLOBALS['imp_imap']->ob()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
} catch (Horde_Imap_Client_Exception $e) {
$GLOBALS['notification']->push($e);
return null;
}
try {
- $count = ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN))
+ $count = ($info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN))
? intval($info['unseen'])
: 0;
} catch (Horde_Imap_Client_Exception $e) {
*/
public function createFolder($folder)
{
- $fname = $GLOBALS['imp_imap']->appendNamespace($folder);
+ $fname = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($folder);
return $GLOBALS['injector']->getInstance('IMP_Folder')->create($fname, $GLOBALS['prefs']->getValue('subscribe'))
? $fname
: false;
*/
public function imapOb($mailbox, $indices)
{
- return $GLOBALS['imp_imap']->ob();
+ return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->ob;
}
/**
* Initialization function.
*
* Global variables defined:
- * $imp_imap - An IMP_Imap object
* $imp_mbox - Current mailbox information
*/
protected function _init()
'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
'IMP_Folder' => new IMP_Injector_Binder_Folder(),
'IMP_Identity' => new IMP_Injector_Binder_Identity(),
+ 'IMP_Imap' => new IMP_Injector_Binder_Imap(),
'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
'IMP_Mailbox' => new IMP_Injector_Binder_Mailbox(),
'IMP_Quota' => new IMP_Injector_Binder_Quota(),
$GLOBALS['injector']->addBinder($key, $val);
}
- // Initialize global $imp_imap object.
- $GLOBALS['imp_imap'] = new IMP_Imap();
-
// Set default message character set.
if ($def_charset = $GLOBALS['prefs']->getValue('default_msg_charset')) {
Horde_Mime_Part::$defaultCharset = $def_charset;
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
// Check for valid IMAP Client object.
- if (!$GLOBALS['imp_imap']->ob()) {
+ if (!$imp_imap->ob) {
if (!isset($credentials['userId']) ||
!isset($credentials['password'])) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
return true;
}
- if (!$GLOBALS['imp_imap']->createImapObject($credentials['userId'], $credentials['password'], $credentials['server'])) {
+ if (!$imp_imap->createImapObject($credentials['userId'], $credentials['password'], $credentials['server'])) {
self::_logMessage('failed');
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
}
try {
- $GLOBALS['imp_imap']->ob()->login();
+ $imp_imap->login();
} catch (Horde_Imap_Client_Exception $e) {
self::_logMessage($e->getMessage(), 'ERR');
if ($e->getCode() == Horde_Imap_Client_Exception::SERVER_CONNECT) {
}
$auth_id = Horde_Auth::getAuth();
- $imap_ob = $GLOBALS['imp_imap']->ob();
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
$msg = sprintf(
$status_msg . '%s [%s]%s to {%s:%s [%s]}',
);
/* Load the server configuration. */
- $ptr = $GLOBALS['imp_imap']->loadServerConfig($credentials['server']);
+ $ptr = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->loadServerConfig($credentials['server']);
if ($ptr === false) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
*/
static protected function _canAutoLogin($server_key = null, $force = false)
{
- if (($servers = $GLOBALS['imp_imap']->loadServerConfig()) === false) {
+ if (($servers = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->loadServerConfig()) === false) {
return false;
}
$sess = &$_SESSION['imp'];
- $ptr = $GLOBALS['imp_imap']->loadServerConfig($sess['server_key']);
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $ptr = $imp_imap->loadServerConfig($sess['server_key']);
if ($ptr === false) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
}
/* Set the IMAP threading algorithm. */
- $sess['imap']['thread'] = in_array(isset($ptr['thread']) ? strtoupper($ptr['thread']) : 'REFERENCES', $GLOBALS['imp_imap']->ob()->queryCapability('THREAD'))
+ $sess['imap']['thread'] = in_array(isset($ptr['thread']) ? strtoupper($ptr['thread']) : 'REFERENCES', $imp_imap->queryCapability('THREAD'))
? 'REFERENCES'
: 'ORDEREDSUBJECT';
}
$shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown'];
try {
- $fetch_ret = $GLOBALS['imp_imap']->ob()->fetch('INBOX', array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch('INBOX', array(
Horde_Imap_Client::FETCH_ENVELOPE => true
), array('ids' => array_slice($ids, 0, $shown)));
reset($fetch_ret);
/* Add information necessary to log replies/forwards when finally
* sent. */
if ($this->getMetadata('reply_type')) {
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
try {
- $imap_url = $GLOBALS['imp_imap']->ob()->utils->createUrl(array(
+ $imap_url = $imp_imap->getUtils()->createUrl(array(
'type' => $_SESSION['imp']['protocol'],
- 'username' => $GLOBALS['imp_imap']->ob()->getParam('username'),
- 'hostspec' => $GLOBALS['imp_imap']->ob()->getParam('hostspec'),
+ 'username' => $imp_imap->getParam('username'),
+ 'hostspec' => $imp_imap->getParam('hostspec'),
'mailbox' => $this->getMetadata('mailbox'),
'uid' => $this->getMetadata('uid'),
- 'uidvalidity' => $GLOBALS['imp_imap']->checkUidvalidity($this->getMetadata('mailbox'))
+ 'uidvalidity' => $imp_imap->checkUidvalidity($this->getMetadata('mailbox'))
));
switch ($this->getMetadata('reply_type')) {
/* Add the message to the mailbox. */
try {
- $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
+ $ids = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
if ($old_uid) {
$GLOBALS['injector']->getInstance('IMP_Message')->delete(array($old_uid), array('nuke' => true));
}
if ($val) {
- $imap_url = $GLOBALS['imp_imap']->ob()->utils->parseUrl(rtrim(ltrim($val, '<'), '>'));
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imap_url = $imp_imap->getUtils()->parseUrl(rtrim(ltrim($val, '<'), '>'));
try {
if (($imap_url['type'] == $_SESSION['imp']['protocol']) &&
- ($imap_url['username'] == $GLOBALS['imp_imap']->ob()->getParam('username')) &&
+ ($imap_url['username'] == $imp_imap->getParam('username')) &&
// Ignore hostspec and port, since these can change
// even though the server is the same. UIDVALIDITY should
// catch any true server/backend changes.
- ($GLOBALS['imp_imap']->checkUidvalidity($imap_url['mailbox']) == $imap_url['uidvalidity']) &&
+ ($imp_imap->checkUidvalidity($imap_url['mailbox']) == $imap_url['uidvalidity']) &&
$GLOBALS['injector']->getInstance('IMP_Contents')->getOb($imap_url['mailbox'], $imap_url['uid'])) {
$this->_metadata['mailbox'] = $imap_url['mailbox'];
$this->_metadata['reply_type'] = $reply_type;
}
try {
- $GLOBALS['imp_imap']->ob()->append(Horde_String::convertCharset($opts['sent_folder'], Horde_Nls::getCharset(), 'UTF-8'), array(array('data' => $fcc, 'flags' => $flags)));
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->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;
$subject = $h->getValue('subject');
$header['subject'] = empty($subject)
? 'Re: '
- : 'Re: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($subject, array('keepblob' => true));
+ : 'Re: ' . $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($subject, array('keepblob' => true));
$force = false;
if (in_array($type, array('reply', 'reply_auto', '*'))) {
$header['subject'] = $h->getValue('subject');
if (!empty($header['subject'])) {
- $subject = $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($header['subject'], array('keepblob' => true));
+ $subject = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
$header['title'] = _("Forward") . ': ' . $subject;
$header['subject'] = 'Fwd: ' . $subject;
} else {
} else {
$name = Horde_String::truncate($name, 80);
}
- return 'Fwd: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($name, array('keepblob' => true));
+ return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($name, array('keepblob' => true));
} else {
return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
}
* 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');
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $params['username'] = $imap_ob->getParam('username');
+ $params['password'] = $imap_ob->getParam('password');
}
return array(
/* Get the Horde_Mime_Part object for the given UID. */
try {
- $ret = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
+ $ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true)
), array('ids' => array($this->_uid)));
} catch (Horde_Imap_Client_Exception $e) {
}
try {
- $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_BODYTEXT => array(array('peek' => true, 'stream' => !empty($options['stream'])))
), array('ids' => array($this->_uid)));
return $res[$this->_uid]['bodytext'][0];
}
try {
- $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
if (empty($options['mimeheaders'])) {
if (!empty($res[$this->_uid]['bodypartdecode'][$id])) {
$this->lastBodyPartDecode = $res[$this->_uid]['bodypartdecode'][$id];
}
try {
- $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->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->_uid)));
}
try {
- $res = $GLOBALS['imp_imap']->ob()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => $parse, 'peek' => true))
), array('ids' => array($this->_uid)));
return $res[$this->_uid]['headertext'][0];
return false;
}
- /* Get the list of from addresses. */
$addr = array();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
+ /* Get the list of from addresses. */
foreach ($msgList as $mbox => $msgIndices) {
- $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $imp_imap->checkUidvalidity($mbox);
foreach ($msgIndices as $idx) {
$contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $idx);
}
try {
- $GLOBALS['imp_imap']->ob()->deleteMailbox($folder);
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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['injector']->getInstance('IMP_Imap')->getOb()->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(
- Horde_Imap_Client::FETCH_FULLMSG => array('peek' => true, 'stream' => true),
- Horde_Imap_Client::FETCH_ENVELOPE => true,
- Horde_Imap_Client::FETCH_DATE => true,
- ), array('ids' => array($i), 'sequence' => true));
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->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,
+ ), array('ids' => array($i), 'sequence' => true));
$ptr = reset($res);
} catch (Horde_Imap_Client_Exception $e) {
continue;
{
$message = '';
$msgcount = 0;
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
$fd = fopen($mbox, 'r');
while (!feof($fd)) {
if (preg_match('/From (.+@.+|- )/A', $line)) {
if (!empty($message)) {
try {
- $GLOBALS['imp_imap']->ob()->append($folder, array(array('data' => $message)));
+ $imp_imap->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)));
+ $imp_imap->append($folder, array(array('data' => $message)));
++$msgcount;
} catch (Horde_Imap_Client_Exception $e) {}
}
return $msgcount ? $msgcount : false;
}
+
}
return $cache[$folder];
}
- $ns_info = $GLOBALS['imp_imap']->getNamespace($folder);
+ $ns_info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getNamespace($folder);
$delimiter = is_null($ns_info) ? '' : $ns_info['delimiter'];
/* Substitute any translated prefix text. */
}
}
- if (!empty($mailbox) && !$GLOBALS['imp_imap']->isReadOnly($mailbox)) {
+ if (!empty($mailbox) &&
+ !$GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->isReadOnly($mailbox)) {
$menu_trash_url = self::generateIMPUrl($menu_mailbox_url, $mailbox)->add(array('actionID' => 'empty_mailbox', 'mailbox_token' => Horde::getRequestToken('imp.mailbox')));
$menu->add($menu_trash_url, _("Empty _Trash"), 'empty_trash.png', null, null, "return window.confirm('" . addslashes(_("Are you sure you wish to empty your trash folder?")) . "');", '__noselection');
}
*/
static public function folderPref($folder, $append)
{
- $def_ns = $GLOBALS['imp_imap']->defaultNamespace();
- $empty_ns = $GLOBALS['imp_imap']->getNamespace('');
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $def_ns = $imp_imap->defaultNamespace();
+ $empty_ns = $imp_imap->getNamespace('');
if ($append) {
/* Converting from preference value. */
strpos($folder, $empty_ns['delimiter']) === 0) {
/* Prefixed with delimiter => from empty namespace. */
$folder = substr($folder, strlen($empty_ns['delimiter']));
- } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder, true)) == null) {
+ } elseif (($ns = $imp_imap->getNamespace($folder, true)) == null) {
/* No namespace prefix => from personal namespace. */
$folder = $def_ns['name'] . $folder;
}
- } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder)) !== null) {
+ } elseif (($ns = $imp_imap->getNamespace($folder)) !== null) {
/* Converting to preference value. */
if ($ns['name'] == $def_ns['name']) {
/* From personal namespace => strip namespace. */
*
* @var Horde_Imap_Client
*/
- protected $_ob = null;
+ public $ob = null;
+
+ /**
+ * Server key for this instance.
+ *
+ * @var string
+ */
+ protected $_serverkey = '';
/**
* Is connection read-only?
/**
* Constructor.
+ *
+ * @param string $serverkey Server key for this instance.
+ *
+ * @throws IMP_Exception
*/
- public function __construct()
+ public function __construct($serverkey)
{
+ $this->_serverkey = $serverkey;
+
/* Register the logging callback. */
Horde_Imap_Client_Exception::$logCallback = array($this, 'logException');
*/
public function shutdown()
{
- /* 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 &&
- isset($_SESSION['imp']) &&
- empty($_SESSION['imp']['imap_ob'])) {
- $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. */
- foreach ($this->_ob->alerts() as $alert) {
- $GLOBALS['notification']->push($alert, 'horde.warning');
- }
-
- $_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']] = serialize($this->_ob);
+ /* Only need to serialize object once a session. */
+ if ($this->ob && isset($_SESSION['imp'])) {
+ $_SESSION['imp']['imap_ob'][$this->_serverkey] = serialize($this->ob);
}
}
/**
- * Loads the IMP server configuration from servers.php.
- *
- * @param string $server Returns this labeled entry only.
- *
- * @return mixed If $server is set, then return this entry, or return the
- * entire servers array. Returns false on error.
- */
- static public function loadServerConfig($server = null)
- {
- try {
- $servers = Horde::loadConfiguration('servers.php', 'servers', 'imp');
- if ($servers === null) {
- $servers = false;
- }
- } catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
- return false;
- }
-
- if (is_null($server)) {
- /* Remove any prompt entries (underscores in front of key). */
- foreach (array_keys($servers) as $key) {
- if ($key[0] == '_') {
- unset($servers[$key]);
- }
- }
- return $servers;
- }
-
- /* Check for the existence of the server in the config file. */
- if (empty($servers[$server]) || !is_array($servers[$server])) {
- $entry = sprintf('Invalid server key "%s" from client [%s]', $server, $_SERVER['REMOTE_ADDR']);
- Horde::logMessage($entry, 'ERR');
- return false;
- }
-
- return $servers[$server];
- }
-
- /**
* Loads the Horde_Imap_Client object from serialized session data.
*
* @return boolean True on success, false on error.
+ * @throws IMP_Exception
*/
protected function _loadImapObject()
{
- if (!is_null($this->_ob)) {
+ if (!is_null($this->ob)) {
return true;
}
if (empty($_SESSION['imp']) ||
- empty($_SESSION['imp']['server_key']) ||
- empty($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']])) {
+ empty($_SESSION['imp']['imap_ob'][$this->_serverkey])) {
return false;
}
Horde_Imap_Client::$encryptKey = $GLOBALS['injector']->getInstance('Horde_Secret')->getKey('imp');
- $this->_ob = @unserialize($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']]);
- if (empty($this->_ob)) {
+ $this->ob = @unserialize($_SESSION['imp']['imap_ob'][$this->_serverkey]);
+ if (empty($this->ob)) {
/* Throw fatal error here - should never reach here and if we
* do, we are out of luck. */
throw new IMP_Exception(_("Could not acquire mail server credentials from the session."));
* @param string $username The username to authenticate with.
* @param string $password The password to authenticate with.
* @param string $key Create a new object using this server key.
- * @param boolean $global If true, treat the created object as the IMP
- * global IMAP object.
*
* @return boolean The object on success, false on error.
*/
- public function createImapObject($username, $password, $key,
- $global = true)
+ public function createImapObject($username, $password, $key)
{
- if ($global && !is_null($this->_ob)) {
- return $GLOBALS['imp_imap'];
+ if (!is_null($this->ob)) {
+ return $this->ob;
}
if (($server = $this->loadServerConfig($key)) === false) {
return false;
}
- if ($global) {
- $this->_ob = $ob;
- $this->_postcreate($protocol);
- }
+ $this->ob = $ob;
+ $this->_postcreate($protocol);
return $ob;
}
}
/**
- * Alter some IMP settings once we load/create the global object.
+ * Alter some IMP settings once we load/create the object.
*
* @param string $protocol The protocol used to connect.
*/
($_SESSION['imp']['protocol'] == 'imap') &&
!$GLOBALS['injector']->getInstance('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 $this->_ob->getNamespaces(!empty($_SESSION['imp']['imap']['namespace']) ? $_SESSION['imp']['imap']['namespace'] : array());
+ return $this->ob->getNamespaces(!empty($_SESSION['imp']['imap']['namespace']) ? $_SESSION['imp']['imap']['namespace'] : array());
} catch (Horde_Imap_Client_Exception $e) {
// @todo Error handling
return array();
}
/**
- * Return the Horde_Imap_Client object.
+ * Return the Horde_Imap_Client_Utils object.
*
- * @return Horde_Imap_Client The imap object.
+ * @return Horde_Imap_Client_Utils The utility object.
*/
- public function ob()
+ public function getUtils()
{
- return $this->_ob;
+ return $this->ob
+ ? $this->ob->utils
+ : $GLOBALS['injector']->createInstance('Horde_Imap_Client_Utils');
}
+ /**
+ * 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 IMP_Exception
+ */
+ public function __call($method, $params)
+ {
+ if (!$this->ob || !method_exists($this->ob, $method)) {
+ throw new IMP_Exception(sprintf(_("%s: Invalid method call '%s'."), __CLASS__, $method));
+ }
+
+ return call_user_func_array(array($this->ob, $method), $params);
+ }
+
+ /* Static methods. */
+
+ /**
+ * Loads the IMP server configuration from servers.php.
+ *
+ * @param string $server Returns this labeled entry only.
+ *
+ * @return mixed If $server is set return this entry; else, return the
+ * entire servers array. Returns false on error.
+ */
+ static public function loadServerConfig($server = null)
+ {
+ try {
+ $servers = Horde::loadConfiguration('servers.php', 'servers', 'imp');
+ if ($servers === null) {
+ $servers = false;
+ }
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, 'ERR');
+ return false;
+ }
+
+ if (is_null($server)) {
+ /* Remove any prompt entries (underscores in front of key). */
+ foreach (array_keys($servers) as $key) {
+ if ($key[0] == '_') {
+ unset($servers[$key]);
+ }
+ }
+ return $servers;
+ }
+
+ /* Check for the existence of the server in the config file. */
+ if (empty($servers[$server]) || !is_array($servers[$server])) {
+ $entry = sprintf('Invalid server key "%s" from client [%s]', $server, $_SERVER['REMOTE_ADDR']);
+ Horde::logMessage($entry, 'ERR');
+ return false;
+ }
+
+ return $servers[$server];
+ }
+
+
}
throw new IMP_Exception(_("ACLs not configured for this server."));
}
- if (!$GLOBALS['imp_imap']->ob()->queryCapability('ACL')) {
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ if (!$imp_imap->queryCapability('ACL')) {
throw new IMP_Exception(_("IMAP server does not support ACLs."));
}
- $this->_protected = array($GLOBALS['imp_imap']->ob()->getParam('username'));
+ $this->_protected = array($imp_imap->getParam('username'));
$this->_rightsList = array(
'l' => array(
)
);
- if ($GLOBALS['imp_imap']->ob()->queryCapability('RIGHTS')) {
+ if ($imp_imap->queryCapability('RIGHTS')) {
// RFC 4314 compliant rights
$this->_rightsList = array_merge($this->_rightsList, array(
'k' => array(
public function getACL($mbox)
{
try {
- return $GLOBALS['imp_imap']->ob()->getACL($mbox);
+ return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getACL($mbox);
} catch (Horde_Imap_Client_Exception $e) {
throw new IMP_Exception(_("Could not retrieve ACL"));
}
public function editACL($mbox, $user, $acl)
{
try {
- $GLOBALS['imp_imap']->ob()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
} catch (Horde_Imap_Client_Exception $e) {
throw new IMP_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['injector']->getInstance('IMP_Imap')->getOb()->listACLRights($mbox, $user);
$rights = array_merge($rights['required'], $rights['optional']);
foreach ($rights as $val) {
if (strpos($val, 'a') !== false) {
try {
/* Make sure we are in R/W mailbox mode (SELECT). No flags are
* allowed in EXAMINE mode. */
- $GLOBALS['imp_imap']->ob()->openMailbox($options['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
- $status = $GLOBALS['imp_imap']->ob()->status($options['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap->openMailbox($options['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ $status = $imp_imap->status($options['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
if (($pos = array_search('\\*', $status['permflags'])) !== false) {
if ($GLOBALS['prefs']->getValue('show_all_flags')) {
/* IMAP keywords must conform to RFC 3501 [9] (flag-keyword). Convert
* whitespace to underscore. */
- $key = $GLOBALS['imp_imap']->ob()->utils->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), Horde_Nls::getCharset(), 'UTF7-IMAP'));
+ $key = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), Horde_Nls::getCharset(), 'UTF7-IMAP'));
if (!isset($this->_flags[$key])) {
$entry = $this->_createEntry($label);
public function __construct()
{
if ($_SESSION['imp']['protocol'] == 'imap') {
- $ns = $GLOBALS['imp_imap']->getNamespaceList();
+ $ns = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getNamespaceList();
$ptr = reset($ns);
$this->_delimiter = $ptr['delimiter'];
$this->_namespaces = empty($GLOBALS['conf']['user']['allow_folders'])
}
try {
- $result = $GLOBALS['imp_imap']->ob()->listMailboxes($searches, $showunsub ? Horde_Imap_Client::MBOX_ALL : Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, array('attributes' => true, 'delimiter' => true, 'sort' => true));
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $result = $imp_imap->listMailboxes($searches, $showunsub ? Horde_Imap_Client::MBOX_ALL : Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, array('attributes' => true, 'delimiter' => true, 'sort' => true));
/* INBOX must always appear. */
if (empty($result['INBOX'])) {
- $result = array_merge($GLOBALS['imp_imap']->ob()->listMailboxes('INBOX', Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true)), $result);
+ $result = array_merge($imp_imap->listMailboxes('INBOX', Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true)), $result);
}
} catch (Horde_Imap_Client_Exception $e) {}
if (!empty($id)) {
try {
- $this->_insert($GLOBALS['imp_imap']->ob()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
+ $this->_insert($GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
} catch (Horde_Imap_Client_Exception $e) {}
}
}
{
if (!in_array($mailbox, array(self::OTHER_KEY, self::SHARED_KEY, self::VFOLDER_KEY)) &&
(strpos($mailbox, self::VFOLDER_KEY . $this->_delimiter) !== 0)) {
- return $GLOBALS['imp_imap']->getNamespace($mailbox);
+ return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getNamespace($mailbox);
}
return null;
}
/* If we need message information for this folder, update
* it now. */
try {
- if ($msgs_info = $GLOBALS['imp_imap']->ob()->status($mailbox['v'], Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
+ if ($msgs_info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($mailbox['v'], Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
$row['polled'] = true;
if (!empty($msgs_info['recent'])) {
$row['recent'] = $msgs_info['recent'];
public function createMailboxName($parent, $new)
{
$ns_info = empty($parent)
- ? $GLOBALS['imp_imap']->defaultNamespace()
+ ? $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->defaultNamespace()
: $this->_getNamespace($parent);
if (is_null($ns_info)) {
--- /dev/null
+<?php
+/**
+ * Binder for IMP_Imap::.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Injector_Binder_Imap implements Horde_Injector_Binder
+{
+ /**
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return new IMP_Injector_Factory_Imap($injector);
+ }
+
+ /**
+ */
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based IMP_Imap:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package IMP
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ */
+
+/**
+ * A Horde_Injector:: based IMP_Imap:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @category Horde
+ * @package IMP
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ */
+class IMP_Injector_Factory_Imap
+{
+ /**
+ * Instances.
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ * The injector.
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Injector $injector The injector to use.
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ /**
+ * Return the IMP_Imap:: instance.
+ *
+ * @param string $id The server ID.
+ *
+ * @return IMP_Imap The singleton contents instance.
+ * @throws IMP_Exception
+ */
+ public function getOb($id = null)
+ {
+ if (is_null($id)) {
+ $id = isset($_SESSION['imp'])
+ ? $_SESSION['imp']['server_key']
+ : 'default';
+ }
+
+ if (!isset($this->_instances[$id])) {
+ $this->_instances[$id] = new IMP_Imap($id);
+ }
+
+ return $this->_instances[$id];
+ }
+
+}
$fetch_criteria[Horde_Imap_Client::FETCH_STRUCTURE] = array('parse' => true);
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
if (empty($options['preview'])) {
$cache = null;
$options['preview'] = 0;
} else {
- $cache = $GLOBALS['imp_imap']->ob()->getCache();
+ $cache = $imp_imap->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 = $imp_imap->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 = $imp_imap->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
$cache->set($mbox, $tostore, $status['uidvalidity']);
}
} catch (Horde_Imap_Client_Exception $e) {}
}
$criteria = new Horde_Imap_Client_Search_Query();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
if (IMP::hideDeletedMsgs($this->_mailbox)) {
$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 = $imp_imap->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' => !$uid));
+ $res = $imp_imap->search($this->_mailbox, $criteria, array('results' => array($results), 'sequence' => !$uid));
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['injector']->getInstance('IMP_Imap')->getOb()->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_SEQUENCE) {
try {
- $res = $GLOBALS['imp_imap']->ob()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
+ $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->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, array('criteria' => $_SESSION['imp']['imap']['thread']));
+ $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->thread($this->_mailbox, array('criteria' => $_SESSION['imp']['imap']['thread']));
} catch (Horde_Imap_Client_Exception $e) {
$GLOBALS['notification']->push($e);
return new Horde_Imap_Client_Thread(array(), 'uid');
if (!$this->_searchmbox) {
$sortpref = IMP::getSort($this->_mailbox, true);
try {
- return $GLOBALS['imp_imap']->ob()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
+ return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
} catch (Horde_Imap_Client_Exception $e) {}
}
break;
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
foreach ($msgList as $mbox => $msgIndices) {
$error = null;
- if ($GLOBALS['imp_imap']->isReadOnly($targetMbox)) {
+ if ($imp_imap->isReadOnly($targetMbox)) {
$error = _("The target directory is read-only.");
}
if (!$error &&
($action == 'move') &&
- $GLOBALS['imp_imap']->isReadOnly($mbox)) {
+ $imp_imap->isReadOnly($mbox)) {
$error = _("The source directory is read-only.");
}
if (!$error) {
try {
- $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $imp_imap->checkUidvalidity($mbox);
} catch (IMP_Exception $e) {
$error = $e->getMessage();
}
/* Attempt to copy/move messages to new mailbox. */
if (!$error) {
try {
- $GLOBALS['imp_imap']->ob()->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
+ $imp_imap->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
$imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($mbox);
if (($action == 'move') && $imp_mailbox->isBuilt()) {
}
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
foreach ($msgList as $mbox => $msgIndices) {
$error = null;
- if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
+ if ($imp_imap->isReadOnly($mbox)) {
$error = _("This folder is read-only.");
}
if (!$error) {
try {
- $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $imp_imap->checkUidvalidity($mbox);
} catch (IMP_Exception $e) {
$error = $e->getMessage();
}
/* 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));
+ $imp_imap->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true));
$imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($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 = $imp_imap->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));
+ $imp_imap->store($mbox, array('add' => array('\\deleted'), 'ids' => $msgIndices));
if ($expunge_now) {
$this->expungeMailbox($indices_array);
}
}
$uid = reset($uid);
- if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
+ if ($imp_imap->isReadOnly($mbox)) {
throw new IMP_Exception(_("Cannot strip the MIME part as the mailbox is read-only."));
}
- $uidvalidity = $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $uidvalidity = $imp_imap->checkUidvalidity($mbox);
$contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $uid);
- $imap_ob = $GLOBALS['imp_imap']->ob();
$message = $contents->getMIMEMessage();
$boundary = trim($message->getContentTypeParameter('boundary'), '"');
$parts = array(
array(
't' => 'url',
- 'v' => $imap_ob->utils->createUrl(array_merge($url_array, array('section' => 'HEADER')))
+ 'v' => $imp_imap->getUtils()->createUrl(array_merge($url_array, array('section' => 'HEADER')))
)
);
} else {
$parts[] = array(
't' => 'url',
- 'v' => $imap_ob->utils->createUrl(array_merge($url_array, array('section' => $id . '.MIME')))
+ 'v' => $imp_imap->getUtils()->createUrl(array_merge($url_array, array('section' => $id . '.MIME')))
);
$parts[] = array(
't' => 'url',
- 'v' => $imap_ob->utils->createUrl(array_merge($url_array, array('section' => $id)))
+ 'v' => $imp_imap->getUtils()->createUrl(array_merge($url_array, array('section' => $id)))
);
}
}
/* Get the headers for the message. */
try {
- $res = $imap_ob->fetch($mbox, array(
+ $res = $imp_imap->fetch($mbox, array(
Horde_Imap_Client::FETCH_DATE => true,
Horde_Imap_Client::FETCH_FLAGS => true
), array('ids' => array($uid)));
unset($res['flags'][$pos]);
}
- $new_uid = $imap_ob->append($mbox, array(
+ $new_uid = $imp_imap->append($mbox, array(
array(
'data' => $parts,
'flags' => $res['flags'],
$action_array = $action
? array('add' => $flags)
: array('remove' => $flags);
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
foreach ($msgList as $mbox => $msgIndices) {
$error = null;
- if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
+ if ($imp_imap->isReadOnly($mbox)) {
$error = _("This folder is read-only.");
}
if (!$error) {
try {
- $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $imp_imap->checkUidvalidity($mbox);
} catch (IMP_Exception $e) {
$error = $e->getMessage();
}
if (!$error) {
/* Flag/unflag the messages now. */
try {
- $GLOBALS['imp_imap']->ob()->store($mbox, array_merge($action_array, array('ids' => $msgIndices)));
+ $imp_imap->store($mbox, array_merge($action_array, array('ids' => $msgIndices)));
} catch (Horde_Imap_Client_Exception $e) {
$error = $e->getMessage();
}
$action_array = $action
? array('add' => $flags)
: array('remove' => $flags);
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
foreach ($mboxes as $val) {
try {
- $GLOBALS['imp_imap']->ob()->store($val, $action_array);
+ $imp_imap->store($val, $action_array);
} catch (Horde_Imap_Client_Exception $e) {
return false;
}
return $msg_list ? array() : null;
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
$imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
$process_list = $update_list = array();
foreach (array_keys($mbox_list) as $key) {
- if (!$GLOBALS['imp_imap']->isReadOnly($key)) {
+ if (!$imp_imap->isReadOnly($key)) {
if ($imp_search->isSearchMbox($key)) {
foreach ($imp_search->getSearchFolders($key) as $skey) {
$process_list[$skey] = $mbox_list[$key];
* UIDVALIDITY. */
if (is_array($val)) {
try {
- $GLOBALS['imp_imap']->checkUidvalidity($key);
+ $imp_imap->checkUidvalidity($key);
} catch (IMP_Exception $e) {
continue;
}
}
try {
- $update_list[$key] = $GLOBALS['imp_imap']->ob()->expunge($key, array('ids' => is_array($val) ? $val : array(), 'list' => $msg_list));
+ $update_list[$key] = $imp_imap->expunge($key, array('ids' => is_array($val) ? $val : array(), 'list' => $msg_list));
$imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($key);
if ($imp_mailbox->isBuilt()) {
{
global $notification, $prefs;
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
$imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
$trash_folder = ($prefs->getValue('use_trash'))
? IMP::folderPref($prefs->getValue('trash_folder'), true)
foreach ($mbox_list as $mbox) {
$display_mbox = IMP::displayFolder($mbox);
- if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
+ if ($imp_imap->isReadOnly($mbox)) {
$notification->push(sprintf(_("Could not delete messages from %s. This mailbox is read-only."), $display_mbox), 'horde.error');
continue;
}
/* 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 = $imp_imap->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 = $imp_imap->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
$size = 0;
reset($res);
public function notify($options)
{
if (in_array('status', $options['listeners']) &&
- ($ob = $GLOBALS['imp_imap']->ob())) {
+ ($ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()) &&
+ $ob->ob) {
/* Display IMAP alerts. */
foreach ($ob->alerts() as $alert) {
$GLOBALS['notification']->push($alert, 'horde.warning');
$sent_mail_folder = $ui->vars->sent_mail_folder;
if (empty($sent_mail_folder)) {
- $sent_mail_new = $GLOBALS['imp_imap']->appendNamespace(Horde_String::convertCharset($ui->vars->sent_mail_folder_new, Horde_Nls::getCharset(), 'UTF7-IMAP'));
+ $sent_mail_new = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace(Horde_String::convertCharset($ui->vars->sent_mail_folder_new, Horde_Nls::getCharset(), 'UTF7-IMAP'));
} elseif ($sent_mail_folder == '-1') {
if ($sent_mail_default = $prefs->getValue('sent_mail_folder')) {
- $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_default);
+ $sent_mail_folder = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($sent_mail_default);
}
}
$prefs->setValue($pref, '');
} else {
if (!empty($new)) {
- $folder = $GLOBALS['imp_imap']->appendNamespace($new);
+ $folder = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($new);
if (!$GLOBALS['injector']->getInstance('IMP_Folder')->create($folder, $prefs->getValue('subscribe'))) {
$folder = null;
}
public function getQuota()
{
try {
- $quota = $GLOBALS['imp_imap']->ob()->getQuotaRoot($GLOBALS['injector']->getInstance('IMP_Search')->isSearchMbox($GLOBALS['imp_mbox']['mailbox']) ? 'INBOX' : $GLOBALS['imp_mbox']['mailbox']);
+ $quota = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getQuotaRoot($GLOBALS['injector']->getInstance('IMP_Search')->isSearchMbox($GLOBALS['imp_mbox']['mailbox']) ? 'INBOX' : $GLOBALS['imp_mbox']['mailbox']);
} catch (Horde_Imap_Client_Exception $e) {
throw new IMP_Exception(_("Unable to retrieve quota"));
}
$full = $this->_params['path'] . '/maildirsize';
// Substitute the username in the string if needed.
- $full = str_replace('~U', $GLOBALS['imp_imap']->ob()->getParam('username'), $full);
+ $full = str_replace('~U', $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getParam('username'), $full);
// Read in the quota file and parse it, if possible.
if (!is_file($full)) {
*/
public function imapSearch($mailbox, $query, $opts = array())
{
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
/* If doing a from/to search, use display sorting if possible.
* Although there is a fallback to a PHP-based display sort, for
* performance reasons only do a display sort if it is supported
* on the server. */
if (($_SESSION['imp']['protocol'] == 'imap') && isset($opts['sort'])) {
- $sort_cap = $GLOBALS['imp_imap']->ob()->queryCapability('SORT');
+ $sort_cap = $imp_imap->queryCapability('SORT');
if (is_array($sort_cap) && in_array('DISPLAY', $sort_cap)) {
$pos = array_search(Horde_Imap_Client::SORT_FROM, $opts['sort']);
/* Make sure we search in the proper charset. */
if ($query) {
$query = clone $query;
- $imap_charset = $GLOBALS['imp_imap']->ob()->validSearchCharset('UTF-8')
+ $imap_charset = $imp_imap->validSearchCharset('UTF-8')
? 'UTF-8'
: 'US-ASCII';
$query->charset($imap_charset, array('Horde_String', 'convertCharset'));
}
- return $GLOBALS['imp_imap']->ob()->search($mailbox, $query, $opts);
+ return $imp_imap->search($mailbox, $query, $opts);
}
/**
foreach ($msgList as $mbox => $msgIndices) {
try {
- $GLOBALS['imp_imap']->checkUidvalidity($mbox);
+ $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->checkUidvalidity($mbox);
} catch (IMP_Exception $e) {
continue;
}
$imp_filter->filter('INBOX');
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
/* Get list of mailboxes to poll. */
$poll = $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(true);
- $status = $GLOBALS['imp_imap']->ob()->statusMultiple($poll, Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT);
+ $status = $imp_imap->statusMultiple($poll, Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT);
$anyUnseen = false;
$html = $onclick = '';
/* 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);
+ $imp_imap->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
} elseif (!empty($this->_params['show_unread'])) {
if (count($folders) == 0) {
*/
public function MDNCheck($mailbox, $uid, $headers, $confirmed = false)
{
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
$pref_val = $GLOBALS['prefs']->getValue('disposition_send_mdn');
- if (!$pref_val || $GLOBALS['imp_imap']->isReadOnly($mailbox)) {
+ if (!$pref_val || $imp_imap->isReadOnly($mailbox)) {
return false;
}
/* 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 = $imp_imap->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 = $imp_imap->fetch($mailbox, array(
Horde_Imap_Client::FETCH_FLAGS => true
), array('ids' => array($uid)));
$mdn_sent = in_array('$mdnsent', $res[$uid]['flags']);
$md->flags = array_keys($GLOBALS['injector']->getInstance('IMP_Imap_Flags')->getList(array('imap' => true, 'mailbox' => $is_search ? null : $mbox)));
}
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+
/* These entries may change during a session, so always need to
* update them. */
- $md->readonly = intval($GLOBALS['imp_imap']->isReadOnly($mbox));
+ $md->readonly = intval($imp_imap->isReadOnly($mbox));
/* Check for mailbox existence now. If there are no messages, there
* is a chance that the mailbox doesn't exist. If there is at least
!empty($args['cache'])) {
$uid_expire = false;
try {
- $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
- $parsed = $GLOBALS['imp_imap']->ob()->parseCacheId($args['cacheid']);
+ $status = $imp_imap->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
+ $parsed = $imp_imap->parseCacheId($args['cacheid']);
$uid_expire = ($parsed['uidvalidity'] != $status['uidvalidity']);
} catch (Horde_Imap_Cache_Exception $e) {
$uid_expire = true;
/* Get the cached list. */
$cached = $changed = array();
if (!empty($args['cache'])) {
- $cached = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($args['cache']);
+ $cached = $imp_imap->getUtils()->fromSequenceString($args['cache']);
if ($is_search) {
$cached = array_flip($cached);
} else {
* update the browser cache (done below). */
if ($args['change'] && $args['cacheid']) {
if (!isset($parsed)) {
- $parsed = $GLOBALS['imp_imap']->ob()->parseCacheId($args['cacheid']);
+ $parsed = $imp_imap->parseCacheId($args['cacheid']);
}
if (!empty($parsed['highestmodseq'])) {
try {
- $res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(Horde_Imap_Client::FETCH_UID => 1), array('changedsince' => $parsed['highestmodseq']));
+ $res = $imp_imap->fetch($mbox, array(Horde_Imap_Client::FETCH_UID => 1), array('changedsince' => $parsed['highestmodseq']));
if (!empty($res)) {
$changed = array_flip(array_keys($res));
}
/* Get unseen/thread information. */
if (!$is_search) {
try {
- if ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
+ if ($info = $imp_imap->status($mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
$md->unseen = intval($info['unseen']);
}
} catch (Horde_Imap_Client_Exception $e) {}
/* 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['injector']->getInstance('IMP_Imap')->getOb()->fetch($mailbox, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($uid)));
$do_filter = false;
$imp_flags = $injector->getInstance('IMP_Imap_Flags');
+$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
$open_compose_window = null;
/* Run through the action handlers */
* the RECENT flag. */
if (!$search_mbox) {
try {
- $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ $imp_imap->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
} catch (Horde_Imap_Client_Exception $e) {
$actionID = null;
}
break;
case 'view_messages':
- $redirect = IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], null, null, false)->setRaw(true)->add(array('mode' => 'msgview', 'msglist' => $imp_imap->ob()->utils->toSequenceString(IMP::parseIndicesList($indices), array('mailbox' => true))));
+ $redirect = IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], null, null, false)->setRaw(true)->add(array('mode' => 'msgview', 'msglist' => $imp_imap->getUtils()->toSequenceString(IMP::parseIndicesList($indices), array('mailbox' => true))));
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->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
if (!Horde_Util::getFormData('no_newmail_popup')) {
/* Newmail alerts. */
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 = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $imp_imap->ob()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $readonly))
), array('ids' => array($uid)));
}
/* Determine if mailbox is readonly. */
-$peek = $readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
+$peek = $readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly($imp_mbox['mailbox']);
if ($readonly &&
in_array($vars->actionID, array('delete_message', 'undelete_message', 'move_message', 'flag_message', 'strip_attachment', 'strip_all'))) {
$vars->actionID = null;
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 = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $imp_imap->ob()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $peek))
), array('ids' => array($uid)));
*/
$mode = Horde_Util::getFormData('mode', 'thread');
-$imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($imp_mbox['mailbox'], $imp_mbox['thismailbox'], $imp_mbox['uid']);
+$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb($imp_mbox['mailbox'], $imp_mbox['thismailbox'], $imp_mbox['uid']);
$error = false;
if ($mode == 'thread') {
}
} else {
/* MSGVIEW MODE: Make sure we have a valid list of messages. */
- $msglist = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString(Horde_Util::getFormData('msglist'));
+ $msglist = $imp_imap->getUtils()->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 = $imp_imap->fetch($mbox, array(
Horde_Imap_Client::FETCH_ENVELOPE => true
), array('ids' => $idxlist));