/* Determine if mailboxes are readonly. */
$readonly_drafts = false;
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
if (!empty($draft)) {
$draft = IMP::folderPref($draft, true);
$readonly_drafts = $imp_folder->exists($draft) &&
$imp_folder = $injector->getInstance('IMP_Folder');
$readonly_drafts = $readonly_sentmail = false;
$draft = $prefs->getValue('drafts_folder');
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
if (!empty($draft)) {
$draft = IMP::folderPref($draft, true);
$readonly_drafts = $imp_folder->exists($draft) &&
if (!empty($new_names) &&
!empty($old_names) &&
($iMax == count($old_names))) {
- $imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
for ($i = 0; $i < $iMax; ++$i) {
$old_name = IMP::formMbox($old_names[$i], false);
$old_ns = $imp_imap->getNamespace($old_name);
}
try {
- $elt_info = $injector->getInstance('IMP_Imap')->getOb()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
+ $elt_info = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->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 ($imaptree->recent as $mbox => $nm) {
- $injector->getInstance('IMP_Imap')->getOb()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
+ $injector->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
IMP::newmailAlerts($imaptree->recent);
$result = new stdClass;
$result->poll = array();
- foreach ($GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->statusMultiple($GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
+ foreach ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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->mbox);
try {
- if ($info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($this->_vars->mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
+ if ($info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->_vars->mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
$result->poll = array($this->_vars->mbox => intval($info['unseen']));
}
} catch (Horde_Imap_Client_Exception $e) {}
}
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_vars->view, array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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) {
protected function _checkUidvalidity($result = false)
{
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->checkUidvalidity($this->_vars->view);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->checkUidvalidity($this->_vars->view);
} catch (IMP_Exception $e) {
if (!is_object($result)) {
$result = new stdClass;
* on the IMAP server (saves some STATUS calls). */
if (!is_null($rw)) {
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
} catch (Horde_Imap_Client_Exception $e) {
if ($e->getCode() == Horde_Imap_Client_Exception::MAILBOX_NOOPEN) {
$GLOBALS['notification']->push(sprintf(_("Could not open mailbox \"%s\"."), $this->_vars->view), 'horde.error');
*/
public function createFolder($folder)
{
- $fname = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($folder);
+ $fname = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($folder);
return $GLOBALS['injector']->getInstance('IMP_Folder')->create($fname, $GLOBALS['prefs']->getValue('subscribe'))
? $fname
: false;
*/
public function imapOb()
{
- return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->ob;
+ return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
}
/**
'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(),
'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
'IMP_Identity' => new IMP_Injector_Binder_Identity(),
- 'IMP_Imap' => new IMP_Injector_Binder_Imap(),
'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
'IMP_Mail' => new IMP_Injector_Binder_Mail(),
'IMP_Mailbox_List' => new IMP_Injector_Binder_MailboxList(),
$trash_folder = IMP::folderPref($trash_folder, true);
if ($injector->getInstance('IMP_Search')->isVTrash($trash_folder) ||
- !$injector->getInstance('IMP_Imap')->getOb()->isReadOnly($trash_folder)) {
+ !$injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($trash_folder)) {
$menu->addArray(array(
'class' => '__noselection',
'icon' => 'empty_trash.png',
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
// Check for valid IMAP Client object.
if (!$imp_imap->ob) {
}
$auth_id = $GLOBALS['registry']->getAuth();
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$msg = sprintf(
$msg . ' %s [%s]%s to {%s:%s%s}',
);
/* Load the server configuration. */
- $ptr = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->loadServerConfig($credentials['server']);
+ $ptr = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->loadServerConfig()) === false) {
+ if (($servers = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->loadServerConfig()) === false) {
return false;
}
$sess = &$_SESSION['imp'];
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$ptr = $imp_imap->loadServerConfig($sess['server_key']);
if ($ptr === false) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
: $this->_params['msgs_shown'];
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch('INBOX', array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch('INBOX', array(
Horde_Imap_Client::FETCH_ENVELOPE => true
), array('ids' => array_slice($indices, 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();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
try {
$imap_url = $imp_imap->getUtils()->createUrl(array(
'type' => $_SESSION['imp']['protocol'],
/* Add the message to the mailbox. */
try {
- $ids = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
+ $ids = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
if ($old_uid) {
$GLOBALS['injector']->getInstance('IMP_Message')->delete($old_uid, array('nuke' => true));
}
if ($val) {
- $imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->crerate();
$imap_url = $imp_imap->getUtils()->parseUrl(rtrim(ltrim($val, '<'), '>'));
try {
}
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->append($opts['sent_folder'], array(array('data' => $fcc, 'flags' => $flags)));
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->append($opts['sent_folder'], 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['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($subject, array('keepblob' => true));
+ : 'Re: ' . $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
+ $subject = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($name, array('keepblob' => true));
+ return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($name, array('keepblob' => true));
}
return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
/* Get the Horde_Mime_Part object for the given UID. */
try {
- $ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
+ $ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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];
}
$addr = array();
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
foreach (array_keys($indices) as $mbox) {
$imp_imap->checkUidvalidity($mbox);
}
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->deleteMailbox($folder);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->createMailbox($folder, array('special_use' => $special_use));
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->createMailbox($folder, array('special_use' => $special_use));
} 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['injector']->getInstance('IMP_Imap')->getOb()->listMailboxes($folder, array('flat' => true));
+ $ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listMailboxes($folder, array('flat' => true));
return !empty($ret);
} catch (Horde_Imap_Client_Exception $e) {
return false;
$all_folders = array_merge(array($old), array_keys(iterator_to_array($imaptree)));
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->renameMailbox($old, $new);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->subscribeMailbox($folder, true);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->subscribeMailbox($folder, false);
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->fetch($folder, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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,
{
$message = '';
$msgcount = 0;
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$fd = fopen($mbox, 'r');
while (!feof($fd)) {
return $cache[$folder];
}
- $ns_info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getNamespace($folder);
+ $ns_info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespace($folder);
$delimiter = is_null($ns_info) ? '' : $ns_info['delimiter'];
/* Substitute any translated prefix text. */
*/
static public function folderPref($folder, $append)
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$def_ns = $imp_imap->defaultNamespace();
$empty_ns = $imp_imap->getNamespace('');
throw new IMP_Exception(_("ACLs not configured for this server."));
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
if (!$imp_imap->queryCapability('ACL')) {
throw new IMP_Exception(_("IMAP server does not support ACLs."));
}
public function getACL($mbox)
{
try {
- return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getACL($mbox);
+ return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getACL($mbox);
} catch (Horde_Imap_Client_Exception $e) {
throw new IMP_Exception(_("Could not retrieve ACL"));
}
public function editACL($mbox, $user, $acl)
{
try {
- $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
+ $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->listACLRights($mbox, $user);
+ $rights = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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. */
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$imp_imap->openMailbox($options['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
$status = $imp_imap->status($options['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
/* IMAP keywords must conform to RFC 3501 [9] (flag-keyword). Convert
* whitespace to underscore. */
- $key = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
+ $key = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
if (!isset($this->_flags[$key])) {
$entry = $this->_createEntry($label);
public function __construct()
{
if ($_SESSION['imp']['protocol'] == 'imap') {
- $ns = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getNamespaceList();
+ $ns = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespaceList();
$ptr = reset($ns);
$this->_delimiter = $ptr['delimiter'];
$this->_namespaces = empty($GLOBALS['conf']['user']['allow_folders'])
}
try {
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$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($id)) {
try {
- $this->_insert($GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
+ $this->_insert($GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->getNamespace($mailbox);
+ return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespace($mailbox);
}
return null;
}
public function createMailboxName($parent, $new)
{
$ns_info = empty($parent)
- ? $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->defaultNamespace()
+ ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->defaultNamespace()
: $this->_getNamespace($parent);
if (is_null($ns_info)) {
$info->unseen = 0;
try {
- if ($msgs_info = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($this->value, Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
+ if ($msgs_info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->value, Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
if (!empty($msgs_info['recent'])) {
$info->recent = intval($msgs_info['recent']);
}
}
}
} elseif (is_string($data)) {
- $indices = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->fromSequenceString($data);
+ $indices = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->fromSequenceString($data);
} elseif ($data instanceof IMP_Compose) {
$indices = array(
$data->getMetadata('mailbox') => array($data->getMetadata('uid'))
*/
public function __toString()
{
- return $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
+ return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
}
/* Iterator methods. */
+++ /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>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @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;
- }
-
-}
* current IMAP / POP3 connection are valid for SMTP authentication as
* well. */
if (!empty($params['auth']) && empty($params['username'])) {
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$params['username'] = $imap_ob->getParam('username');
$params['password'] = $imap_ob->getParam('password');
}
switch (Horde_String::lower($driver)) {
case 'imap':
- $params['imap_ob'] = $injector->getInstance('IMP_Imap')->getOb();
+ $params['imap_ob'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
$params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
? 'INBOX'
: IMP::$mailbox;
break;
case 'maildir':
- $params['username'] = $injector->getInstance('IMP_Imap')->getOb()->getParam('username');
+ $params['username'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->getParam('username');
break;
case 'sql':
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.
+ * @return IMP_Imap The singleton instance.
* @throws IMP_Exception
*/
- public function getOb($id = null)
+ public function create($id = null)
{
if (is_null($id)) {
$id = isset($_SESSION['imp'])
protected function _upgradeExpireImapCache()
{
try {
- $ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->ob;
+ $ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
$ob->login();
$mboxes = $ob->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
$fetch_criteria[Horde_Imap_Client::FETCH_STRUCTURE] = array('parse' => true);
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
if (empty($options['preview'])) {
$cache = null;
}
$criteria = new Horde_Imap_Client_Search_Query();
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
if (IMP::hideDeletedMsgs($this->_mailbox)) {
$criteria->flag('\\deleted', false);
$ret['anymsg'] = true;
if (!$ret['msgcount'] && !$this->_searchmbox) {
try {
- $status = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->thread($this->_mailbox, array('criteria' => $_SESSION['imp']['imap']['thread']));
+ $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
+ return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
} catch (Horde_Imap_Client_Exception $e) {}
}
break;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
foreach ($indices->indices() as $mbox => $msgIndices) {
$error = null;
}
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
foreach ($indices->indices() as $mbox => $msgIndices) {
$error = null;
return;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
if ($imp_imap->isReadOnly($mbox)) {
throw new IMP_Exception(_("Cannot strip the MIME part as the mailbox is read-only."));
$action_array = $action
? array('add' => $flags)
: array('remove' => $flags);
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
foreach ($indices->indices() as $mbox => $msgIndices) {
$error = null;
$action_array = $action
? array('add' => $flags)
: array('remove' => $flags);
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
foreach ($mboxes as $val) {
try {
return $msg_list ? new IMP_Indices() : null;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
$process_list = $update_list = array();
{
global $notification, $prefs;
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
$trash_folder = ($prefs->getValue('use_trash'))
? IMP::folderPref($prefs->getValue('trash_folder'), true)
public function sizeMailbox($mbox, $formatted = true)
{
try {
- $res = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
+ $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->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['injector']->getInstance('IMP_Imap')->getOb()) &&
+ ($ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()) &&
$ob->ob) {
/* Display IMAP alerts. */
foreach ($ob->alerts() as $alert) {
$sent_mail_folder = $sm_default;
}
- $sent_mail_folder = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($sent_mail_folder);
+ $sent_mail_folder = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($sent_mail_folder);
if ($sent_mail_folder) {
$imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder');
$folder = substr($folder, strlen(self::PREF_SPECIALUSE));
} elseif (!empty($new)) {
$new = Horde_String::convertCharset($new, 'UTF-8', 'UTF7-IMAP');
- $folder = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($new);
+ $folder = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($new);
if (!$GLOBALS['injector']->getInstance('IMP_Folder')->create($folder, $prefs->getValue('subscribe'), array($type => true))) {
$folder = null;
}
protected function _getSpecialUse($use)
{
if (is_null($this->_cache)) {
- $this->_cache = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
+ $this->_cache = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
'attributes' => true,
'special_use' => true,
'sort' => true
*/
public function imapSearch($mailbox, $query, $opts = array())
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
/* If doing a from/to search, use display sorting if possible.
* Although there is a fallback to a PHP-based display sort, for
return 0;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$report_count = $result = 0;
foreach ($indices->indices() as $mbox => $msgIndices) {
$GLOBALS['injector']->getInstance('IMP_Filter')->filter('INBOX');
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
/* Get list of mailboxes to poll. */
$poll = $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(true);
*/
public function MDNCheck($mailbox, $uid, $headers, $confirmed = false)
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
$pref_val = $GLOBALS['prefs']->getValue('disposition_send_mdn');
if (!$pref_val || $imp_imap->isReadOnly($mailbox)) {
}
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
/* These entries may change during a session, so always need to
* update them. */
/* Get envelope/header information. We don't use flags in this
* view. */
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->fetch($mailbox, array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox, array(
Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($uid)));
$t->setOption('gettext', true);
/* Determine if mailbox is readonly. */
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
$readonly = $imp_imap->isReadOnly(IMP::$mailbox);
/* Get the base URL for this page. */
$do_filter = false;
$imp_flags = $injector->getInstance('IMP_Imap_Flags');
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
$indices = new IMP_Indices($vars->indices);
/* Run through the action handlers */
$imp_ui = new IMP_Ui_Message();
$js_onload = $js_vars = array();
-$readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly($vars->folder);
+$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($vars->folder);
switch ($vars->actionID) {
case 'strip_attachment':
IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect();
}
-$readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly(IMP::$mailbox);
+$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
$imp_ui_mimp = $injector->getInstance('IMP_Ui_Mimp');
$imp_hdr_ui = new IMP_Ui_Headers();
try {
/* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
* before we can grab it. */
- $flags_ret = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
+ $flags_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->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)));
* select it on the IMAP server (saves some STATUS calls). Open R/W to clear
* the RECENT flag. */
if (!($search_mbox = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox))) {
- $injector->getInstance('IMP_Imap')->getOb()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
+ $injector->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
}
/* Make sure we have a valid index. */
}
/* Determine if mailbox is readonly. */
-$peek = $readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly(IMP::$mailbox);
+$peek = $readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$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 = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
+ $flags_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $injector->getInstance('IMP_Imap')->getOb()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->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)));
}
}
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
if (is_null($server)) {
/* Set first entry to 1, not 0. */
? $vars->mode
: 'thread';
-$imp_imap = $injector->getInstance('IMP_Imap')->getOb();
+$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
$error = false;