Mirrors use of Horde_Core_Factory.
Additionally, these factory injectors don't extend any Horde_Injector
class.
}
$factories = array(
- 'Ansel_Styles' => array('Ansel_Injector_Factory_Styles', 'create'),
- 'Ansel_Faces' => array('Ansel_Injector_Factory_Faces', 'create'),
- 'Ansel_Storage' => array('Ansel_Injector_Factory_Storage', 'create'),
+ 'Ansel_Styles' => 'Ansel_Factory_Styles',
+ 'Ansel_Faces' => 'Ansel_Factory_Faces',
+ 'Ansel_Storage' => 'Ansel_Factory_Storage',
);
foreach ($factories as $interface => $v) {
- $GLOBALS['injector']->bindFactory($interface, $v[0], $v[1]);
+ $GLOBALS['injector']->bindFactory($interface, $v, 'create');
}
// Create db, share, and vfs instances.
--- /dev/null
+<?php
+/**
+ * Factory for Ansel_Faces
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Ansel
+ */
+class Ansel_Factory_Faces
+{
+ public function create (Horde_Injector $injector)
+ {
+ $driver = $GLOBALS['conf']['faces']['driver'];
+ $params = $GLOBALS['conf']['faces'];
+ $class_name = 'Ansel_Faces_' . ucfirst($driver);
+
+ return new $class_name($params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Factory for Ansel_Storage.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Ansel
+ */
+class Ansel_Factory_Storage
+{
+ /**
+ * Array of already instantiated instances
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Injector $injector
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ /**
+ * Return an Ansel_Storage instance scoped for the current Ansel scope.
+ * Scope is determined by the current value of Ansel_Config::scope
+ *
+ * @return Ansel_Storage
+ */
+ public function create()
+ {
+ $scope = $this->_injector->getInstance('Ansel_Config')->get('scope');
+ if (empty($this->_instances[$scope])) {
+ $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Core_Factory_Share')->create($scope, 'Sql'));
+ }
+
+ return $this->_instances[$scope];
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Factory for getting list of all available pre-defined styles.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Ansel
+ */
+class Ansel_Factory_Styles
+{
+ public function create (Horde_Injector $injector)
+ {
+ /* Brings in the $styles array in this scope only */
+ $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
+
+ /* No prettythumbs allowed at all by admin choice */
+ if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
+ $test = $styles;
+ foreach ($test as $key => $style) {
+ if ($style['thumbstyle'] != 'Thumb') {
+ unset($styles[$key]);
+ }
+ }
+ }
+
+ /* Check if the browser / server has png support */
+ if ($GLOBALS['browser']->hasQuirk('png_transparency') ||
+ $GLOBALS['conf']['image']['type'] != 'png') {
+
+ $test = $styles;
+ foreach ($test as $key => $style) {
+ if (!empty($style['requires_png'])) {
+ if (!empty($style['fallback'])) {
+ $styles[$key] = $styles[$style['fallback']];
+ } else {
+ unset($styles[$key]);
+ }
+ }
+ }
+ }
+
+ return $styles;
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * Factory for Ansel_Faces
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package Ansel
- */
-class Ansel_Injector_Factory_Faces
-{
- public function create (Horde_Injector $injector)
- {
- $driver = $GLOBALS['conf']['faces']['driver'];
- $params = $GLOBALS['conf']['faces'];
- $class_name = 'Ansel_Faces_' . ucfirst($driver);
-
- return new $class_name($params);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Factory for Ansel_Storage.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org)
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package Ansel
- */
-class Ansel_Injector_Factory_Storage
-{
- /**
- * Array of already instantiated instances
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- *
- * @var Horde_Injector
- */
- private $_injector;
-
- /**
- * Constructor
- *
- * @param Horde_Injector $injector
- */
- public function __construct(Horde_Injector $injector)
- {
- $this->_injector = $injector;
- }
-
- /**
- * Return an Ansel_Storage instance scoped for the current Ansel scope.
- * Scope is determined by the current value of Ansel_Config::scope
- *
- * @return Ansel_Storage
- */
- public function create()
- {
- $scope = $this->_injector->getInstance('Ansel_Config')->get('scope');
- if (empty($this->_instances[$scope])) {
- $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Core_Factory_Share')->create($scope, 'Sql'));
- }
-
- return $this->_instances[$scope];
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Factory for getting list of all available pre-defined styles.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package Ansel
- */
-class Ansel_Injector_Factory_Styles
-{
- public function create (Horde_Injector $injector)
- {
- /* Brings in the $styles array in this scope only */
- $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
-
- /* No prettythumbs allowed at all by admin choice */
- if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
- $test = $styles;
- foreach ($test as $key => $style) {
- if ($style['thumbstyle'] != 'Thumb') {
- unset($styles[$key]);
- }
- }
- }
-
- /* Check if the browser / server has png support */
- if ($GLOBALS['browser']->hasQuirk('png_transparency') ||
- $GLOBALS['conf']['image']['type'] != 'png') {
-
- $test = $styles;
- foreach ($test as $key => $style) {
- if (!empty($style['requires_png'])) {
- if (!empty($style['fallback'])) {
- $styles[$key] = $styles[$style['fallback']];
- } else {
- unset($styles[$key]);
- }
- }
- }
- }
-
- return $styles;
- }
-
-}
\ No newline at end of file
*/
protected function _init()
{
- $GLOBALS['injector']->bindFactory('Hermes_Driver', 'Hermes_Injector_Factory_Driver', 'create');
+ $GLOBALS['injector']->bindFactory('Hermes_Driver', 'Hermes_Factory_Driver', 'create');
}
/**
--- /dev/null
+<?php
+/**
+ * Hermes_Driver:: factory
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Hermes
+ */
+class Hermes_Factory_Driver
+{
+ /**
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ /**
+ * Return an Hermes_Storage instance.
+ *
+ * @return Ansel_Storage
+ */
+ public function create()
+ {
+ $driver = $GLOBALS['conf']['storage']['driver'];
+ $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
+ if (empty($this->_instances[$signature])) {
+ if ($driver == 'sql' && $GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
+ $params = array('db_adapter' => $this->_injector->getInstance('Horde_Db_Adapter'));
+ } else {
+ throw new Horde_Exception('Using non-global db connection not yet supported.');
+ }
+ $class = 'Hermes_Driver_' . Horde_String::ucfirst($driver);
+ $this->_instances[$signature] = new $class($params);
+ }
+
+ return $this->_instances[$signature];
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * Hermes_Driver:: factory
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package Hermes
- */
-class Hermes_Injector_Factory_Driver
-{
- /**
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- *
- * @var Horde_Injector
- */
- private $_injector;
-
- public function __construct(Horde_Injector $injector)
- {
- $this->_injector = $injector;
- }
-
- /**
- * Return an Hermes_Storage instance.
- *
- * @return Ansel_Storage
- */
- public function create()
- {
- $driver = $GLOBALS['conf']['storage']['driver'];
- $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
- if (empty($this->_instances[$signature])) {
- if ($driver == 'sql' && $GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
- $params = array('db_adapter' => $this->_injector->getInstance('Horde_Db_Adapter'));
- } else {
- throw new Horde_Exception('Using non-global db connection not yet supported.');
- }
- $class = 'Hermes_Driver_' . Horde_String::ucfirst($driver);
- $this->_instances[$signature] = new $class($params);
- }
-
- return $this->_instances[$signature];
- }
-
-}
}
}
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (is_null($server)) {
/* Set first entry to 1, not 0. */
}
/* Init objects. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create();
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
$imp_ui = new IMP_Ui_Compose();
$show_editor = false;
/* Determine if mailboxes are readonly. */
$readonly_drafts = false;
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!empty($draft)) {
$draft = IMP::folderPref($draft, true);
$readonly_drafts = $imp_folder->exists($draft) &&
$compose_disable = !IMP::canCompose();
/* Initialize objects. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
$imp_ui = new IMP_Ui_Compose();
foreach (array_keys($display_hdrs) as $val) {
$imp_folder = $injector->getInstance('IMP_Folder');
$readonly_drafts = $readonly_sentmail = false;
$draft = $prefs->getValue('drafts_folder');
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!empty($draft)) {
$draft = IMP::folderPref($draft, true);
$readonly_drafts = $imp_folder->exists($draft) &&
}
/* Initialize the IMP_Compose:: object. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
$imp_compose->pgpAttachPubkey((bool) $vars->pgp_attach_pubkey);
$imp_compose->userLinkAttachments((bool) $vars->link_attachments);
// // Requires the 'command' parameter to be defined in backends.php,
// // which defines the quota reporting function to run on the SSH
// // host.
-// $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+// $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
// $host = $imap_ob->ob->getParam('hostspec');
// $user = $params['host'];
// $pass = $imap_ob->ob->getParam('password');
Horde_Registry::appInit('imp', array('impmode' => 'mimp'));
/* Redirect back to the mailbox if folder use is not allowed. */
-if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$notification->push(_("Folder use is not enabled."), 'horde.error');
Horde::url('mailbox-mimp.php', true)->redirect();
}
Horde::addScriptFile('folders.js', 'imp');
/* Redirect back to the mailbox if folder use is not allowed. */
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->allowFolders()) {
$notification->push(_("Folder use is not enabled."), 'horde.error');
Horde::url('mailbox.php', true)->redirect();
}
try {
- $elt_info = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
+ $elt_info = $injector->getInstance('IMP_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_Injector_Factory_Imap')->create()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
+ $injector->getInstance('IMP_Factory_Imap')->create()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
}
IMP::newmailAlerts($imaptree->recent);
if ($this->_vars->add) {
$imptree->addPollList($this->_vars->mbox);
try {
- if ($info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->_vars->mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
+ if ($info = $GLOBALS['injector']->getInstance('IMP_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) {}
$result->ViewPort = $this->_viewPortData(true);
} else {
$result->ViewPort = new stdClass;
- $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+ $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
$result->ViewPort->view = $this->_vars->view;
}
$result = $this->_checkUidvalidity($result);
} elseif (!$change) {
/* Only update cacheid info if it changed. */
- $cacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+ $cacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
if ($cacheid != $this->_vars->cacheid) {
$result->ViewPort = new stdClass;
$result->ViewPort->updatecacheid = $cacheid;
*/
public function cancelCompose()
{
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
$imp_compose->destroy('cancel');
return true;
*/
public function deleteDraft()
{
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose)->destroy('cancel');
+ $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose)->destroy('cancel');
return true;
}
public function deleteAttach()
{
if (isset($this->_vars->atc_indices)) {
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
foreach ($this->_vars->atc_indices as $val) {
$GLOBALS['notification']->push(sprintf(_("Deleted attachment \"%s\"."), Horde_Mime::decode($imp_compose[$val]['part']->getName(true))), 'horde.success');
unset($imp_compose[$val]);
}
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_vars->folder, array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_vars->folder, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
), array('ids' => array($this->_vars->uid)));
} catch (Horde_Imap_Client_Exception $e) {
*/
public function addAttachment()
{
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
$result = new stdClass;
$result->action = 'addAttachment';
$result->success = 1;
try {
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
$imp_compose->sendRedirectMessage($this->_vars->redirect_to);
$result->mbox = $imp_compose->getMetadata('mailbox');
if (is_null($mbox)) {
$result = array();
- foreach ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->statusMultiple($imaptree->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
+ foreach ($GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->statusMultiple($imaptree->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
$result[$key] = intval($val['unseen']);
}
return $result;
}
$headers['subject'] = $this->_vars->subject;
- $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
return array($result, $imp_compose, $headers, $identity);
}
*/
protected function _initCompose()
{
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
if (!($imp_contents = $imp_compose->getContentsOb())) {
$imp_contents = $this->_vars->uid
- ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($this->_vars->uid))
+ ? $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($this->_vars->uid))
: null;
}
protected function _checkUidvalidity($result = false)
{
try {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->checkUidvalidity($this->_vars->view);
+ $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->checkUidvalidity($this->_vars->view);
} catch (IMP_Exception $e) {
if (!is_object($result)) {
$result = new stdClass;
$result->ViewPort = $this->_viewPortData(true);
} else {
$result->ViewPort = new stdClass;
- $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+ $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
$result->ViewPort->view = $this->_vars->view;
}
* on the IMAP server (saves some STATUS calls). */
if (!is_null($rw)) {
try {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
+ $GLOBALS['injector']->getInstance('IMP_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');
}
}
- return ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
+ return ($GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
}
/**
*/
public function createFolder($folder)
{
- $fname = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($folder);
+ $fname = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->appendNamespace($folder);
return $GLOBALS['injector']->getInstance('IMP_Folder')->create($fname, $GLOBALS['prefs']->getValue('subscribe'))
? $fname
: false;
*/
public function server()
{
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
return array(
'hostspec' => $imap_ob->ob->getParam('hostspec'),
*/
public function imapOb()
{
- return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
+ return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->ob;
}
/**
{
if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
Horde_Util::getFormData('composeCache')) {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
+ $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
}
}
{
/* Add IMP-specific factories. */
$factories = array(
- 'IMP_AuthImap' => 'IMP_Injector_Factory_AuthImap',
- 'IMP_Crypt_Pgp' => 'IMP_Injector_Factory_Pgp',
- 'IMP_Crypt_Smime' => 'IMP_Injector_Factory_Smime',
- 'IMP_Flags' => 'IMP_Injector_Factory_Flags',
- 'IMP_Identity' => 'IMP_Injector_Factory_Identity',
- 'IMP_Imap_Tree' => 'IMP_Injector_Factory_Imaptree',
- 'IMP_Mail' => 'IMP_Injector_Factory_Mail',
- 'IMP_Quota' => 'IMP_Injector_Factory_Quota',
- 'IMP_Search' => 'IMP_Injector_Factory_Search',
- 'IMP_Sentmail' => 'IMP_Injector_Factory_Sentmail'
+ 'IMP_AuthImap' => 'IMP_Factory_AuthImap',
+ 'IMP_Crypt_Pgp' => 'IMP_Factory_Pgp',
+ 'IMP_Crypt_Smime' => 'IMP_Factory_Smime',
+ 'IMP_Flags' => 'IMP_Factory_Flags',
+ 'IMP_Identity' => 'IMP_Factory_Identity',
+ 'IMP_Imap_Tree' => 'IMP_Factory_Imaptree',
+ 'IMP_Mail' => 'IMP_Factory_Mail',
+ 'IMP_Quota' => 'IMP_Factory_Quota',
+ 'IMP_Search' => 'IMP_Factory_Search',
+ 'IMP_Sentmail' => 'IMP_Factory_Sentmail'
);
foreach ($factories as $key => $val) {
{
/* Clean up dangling IMP_Compose objects. */
foreach (array_keys($GLOBALS['session']->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY)) as $key) {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($key)->destroy('cancel');
+ $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($key)->destroy('cancel');
}
/* No need to keep Tree object in cache - it will be recreated next
$trash_folder = IMP::folderPref($trash_folder, true);
if ($injector->getInstance('IMP_Search')->isVTrash($trash_folder) ||
- !$injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($trash_folder)) {
+ !$injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly($trash_folder)) {
$menu->addArray(array(
'class' => '__noselection',
'icon' => 'empty_trash.png',
));
}
- if ($injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+ if ($injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$menu->addArray(array(
'icon' => 'folders/folder.png',
'text' => _("_Folders"),
$credentials['server'] = self::getAutoLoginServer();
}
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create($credentials['server']);
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create($credentials['server']);
// Check for valid IMAP Client object.
if (!$imp_imap->ob) {
*/
static protected function _canAutoLogin($server_key = null, $force = false)
{
- if (($servers = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->loadServerConfig()) === false) {
+ if (($servers = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->loadServerConfig()) === false) {
return false;
}
{
global $browser, $conf, $injector, $prefs, $registry, $session;
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create(null, true);
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(null, true);
$ptr = $imp_imap->loadServerConfig($session->get('imp', 'server_key'));
if ($ptr === false) {
throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
/* Check for drafts due to session timeouts. */
- $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create()->recoverSessionExpireDraft();
+ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create()->recoverSessionExpireDraft();
self::_logMessage(true, $imp_imap);
}
: $this->_params['msgs_shown'];
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch('INBOX', array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
try {
$imap_url = $imp_imap->getUtils()->createUrl(array(
'type' => $GLOBALS['session']->get('imp', 'protocol'),
/* Add the message to the mailbox. */
try {
- $ids = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
+ $ids = $GLOBALS['injector']->getInstance('IMP_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));
global $injector, $prefs;
try {
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create($indices);
} catch (IMP_Exception $e) {
throw new IMP_Compose_Exception($e);
}
}
if ($val) {
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
$imap_url = $imp_imap->getUtils()->parseUrl(rtrim(ltrim($val, '<'), '>'));
try {
// even though the server is the same. UIDVALIDITY should
// catch any true server/backend changes.
($imp_imap->checkUidvalidity($imap_url['mailbox']) == $imap_url['uidvalidity']) &&
- $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imap_url['mailbox'], $imap_url['uid']))) {
+ $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imap_url['mailbox'], $imap_url['uid']))) {
$this->_metadata['mailbox'] = $imap_url['mailbox'];
$this->_metadata['reply_type'] = $reply_type;
$this->_metadata['uid'] = $imap_url['uid'];
}
try {
- $injector->getInstance('IMP_Injector_Factory_Imap')->create()->append($opts['sent_folder'], array(array('data' => $fcc, 'flags' => $flags)));
+ $injector->getInstance('IMP_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_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($subject, array('keepblob' => true));
+ : 'Re: ' . $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
+ $subject = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
$header['title'] = _("Forward") . ': ' . $subject;
$header['subject'] = 'Fwd: ' . $subject;
} else {
$attached = 0;
foreach ($indices as $mbox => $idx) {
++$attached;
- $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+ $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
$headerob = $contents->getHeaderOb();
$part = new Horde_Mime_Part();
} else {
$name = Horde_String::truncate($name, 80);
}
- return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($name, array('keepblob' => true));
+ return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->getBaseSubject($name, array('keepblob' => true));
}
return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
public function getContentsOb()
{
return $this->getMetadata('reply_type')
- ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($this->getMetadata('mailbox'), $this->getMetadata('uid')))
+ ? $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($this->getMetadata('mailbox'), $this->getMetadata('uid')))
: null;
}
/* Get the Horde_Mime_Part object for the given UID. */
try {
- $ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+ $ret = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
+ $res = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_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];
? null
: $options['type'];
- $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this, $type);
+ $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this, $type);
switch ($mode) {
case self::RENDER_FULL:
if ($is_atc &&
$download_zip &&
($part['bytes'] > 204800)) {
- $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this, $mime_type);
+ $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this, $mime_type);
if (!$viewer->getMetadata('compressed')) {
$part['download_zip'] = $this->linkView($mime_part, 'download_attach', null, array('class' => 'iconImg downloadZipAtc', 'dload' => true, 'jstext' => sprintf(_("Download %s in .zip Format"), $mime_part->getDescription(true)), 'params' => array('zip' => 1)));
}
$last_id = null;
$mime_part = $this->getMIMEPart($id, array('nocontents' => true));
- $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this);
+ $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this);
if ($viewer->embeddedMimeParts()) {
$mime_part = $this->getMIMEPart($id);
$viewer->setMIMEPart($mime_part);
if (!is_object($part)) {
$part = $this->getMIMEPart($part, array('nocontents' => true));
}
- $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($part, $this, $type);
+ $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($part, $this, $type);
if ($mask & self::RENDER_INLINE_AUTO) {
$mask |= self::RENDER_INLINE | self::RENDER_INFO;
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based Horde_Auth_Imap:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based Horde_Auth_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.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_AuthImap
+{
+ /**
+ * Return the Horde_Auth_Imap:: instance that uses IMP configuration.
+ *
+ * @return Horde_Auth_Imap The singleton instance.
+ * @throws IMP_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $params = $GLOBALS['registry']->callByPackage('imp', 'server');
+ if (is_null($params)) {
+ throw new IMP_Exception('No server parameters found.');
+ }
+
+ $aparams = $GLOBALS['session']->get('imp', 'imap_admin', Horde_Session::TYPE_ARRAY);
+
+ $params = array_merge(
+ $params,
+ (isset($aparams['params']) ? $aparams['params'] : array()),
+ array(
+ 'default_user' => $GLOBALS['registry']->getAuth(),
+ 'logger' => $injector->getInstance('Horde_Log_Logger')
+ )
+ );
+
+ if (isset($params['admin_password'])) {
+ $secret = $injector->getInstance('Horde_Secret');
+ $params['admin_password'] = $secret->read($secret->getKey('imp'), $params['admin_password']);
+ }
+
+ return Horde_Auth::factory('imap', $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based IMP_Compose:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector:: based IMP_Compose:: 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.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Compose
+{
+ /**
+ * 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;
+
+ register_shutdown_function(array($this, 'shutdown'));
+ }
+
+ /**
+ * Return the IMP_Compose:: instance.
+ *
+ * @param string $cacheid The cache ID string.
+ *
+ * @return IMP_Compose The singleton compose instance.
+ * @throws IMP_Exception
+ */
+ public function create($cacheid = null)
+ {
+ if (empty($cacheid)) {
+ $cacheid = strval(new Horde_Support_Randomid());
+ } elseif (!isset($this->_instances[$cacheid])) {
+ $this->_instances[$cacheid] = $GLOBALS['session']->retrieve($cacheid);
+ }
+
+ if (empty($this->_instances[$cacheid])) {
+ $this->_instances[$cacheid] = new IMP_Compose($cacheid);
+ }
+
+ return $this->_instances[$cacheid];
+ }
+
+ /**
+ * Tasks to perform on shutdown.
+ */
+ public function shutdown()
+ {
+ global $session;
+
+ $cache = $session->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY);
+ $changed = false;
+
+ foreach ($this->_instances as $key => $val) {
+ switch ($val->changed) {
+ case 'changed':
+ $val->changed = '';
+ $session->store($val, false, $key);
+ $cache[$key] = 1;
+ $changed = true;
+ break;
+
+ case 'deleted':
+ unset($cache[$key]);
+ $session->purge($key);
+ $changed = true;
+ break;
+ }
+
+ }
+
+ if ($changed) {
+ $session->set('imp', 'compose_cache', $cache);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based IMP_Contents:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector:: based IMP_Contents:: 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.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Contents
+{
+ /**
+ * Instances.
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ * Return the IMP_Contents:: instance.
+ *
+ * @param IMP_Indices $indices An indices object.
+ *
+ * @return IMP_Contents The singleton contents instance.
+ * @throws IMP_Exception
+ */
+ public function create($indices)
+ {
+ $key = strval($indices);
+
+ if (!isset($this->_instances[$key])) {
+ $this->_instances[$key] = new IMP_Contents($indices);
+ }
+
+ return $this->_instances[$key];
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Flags object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Flags object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Flags
+{
+ /**
+ * Return the IMP_Flags instance.
+ *
+ * @return IMP_Flags The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ try {
+ $instance = $GLOBALS['session']->get('imp', 'flags');
+ } catch (Exception $e) {
+ Horde::logMessage('Could not unserialize stored IMP_Flags object.', 'DEBUG');
+ $instance = null;
+ }
+
+ if (is_null($instance)) {
+ $instance = new IMP_Flags();
+ }
+
+ register_shutdown_function(array($this, 'shutdown'), $instance);
+
+ return $instance;
+ }
+
+ /**
+ * Store serialized version of object in the current session.
+ *
+ * @param IMP_Flags $instance Flags object.
+ */
+ public function shutdown($instance)
+ {
+ /* Only need to store the object if the object has changed. */
+ if ($instance->changed) {
+ $GLOBALS['session']->set('imp', 'flags', $instance);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for IMP's identity object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for IMP's identity object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Identity
+{
+ /**
+ * Return the IMP identity instance.
+ *
+ * @return IMP_Prefs_Identity The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return $injector->getInstance('Horde_Core_Factory_Identity')->create(null, 'imp');
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based IMP_Imap:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @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.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Imap
+{
+ /**
+ * Instances.
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ * The list of instances to save.
+ *
+ * @var array
+ */
+ private $_save = array();
+
+ /**
+ * Return the IMP_Imap:: instance.
+ *
+ * @param string $id The server ID.
+ * @param boolean $save Save the instance in the session?
+ *
+ * @return IMP_Imap The singleton instance.
+ * @throws IMP_Exception
+ */
+ public function create($id = null, $save = false)
+ {
+ global $session;
+
+ if (is_null($id) &&
+ !($id = $session->get('imp', 'server_key'))) {
+ $id = 'default';
+ }
+
+ if (!isset($this->_instances[$id])) {
+ if (!($ob = $session->get('imp', 'imap_ob/' . $id))) {
+ $ob = new IMP_Imap();
+ }
+
+ $this->_instances[$id] = $ob;
+ }
+
+ if ($save && !$session->exists('imp', 'imap_ob/' . $id)) {
+ if (empty($this->_save)) {
+ register_shutdown_function(array($this, 'shutdown'));
+ }
+ $this->_save[] = $id;
+ }
+
+ return $this->_instances[$id];
+ }
+
+ /**
+ * Saves IMP_Imap instances to the session.
+ */
+ public function shutdown()
+ {
+ foreach (array_unique($this->_save) as $id) {
+ $GLOBALS['session']->set('imp', 'imap_ob/' . $id, $this->_instances[$id]);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Imap_Tree object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Imap_Tree object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Imaptree
+{
+ /**
+ * Return the IMP_Imap_Tree object.
+ *
+ * @return IMP_Imap_Tree The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ global $session;
+
+ $instance = null;
+
+ /* If an IMP_Imap_Tree object is currently stored in the cache,
+ * re-create that object. Else, create a new instance. */
+ if ($session->exists('imp', 'treeob')) {
+ /* Since IMAP tree generation is so expensive/time-consuming,
+ * fallback to storing in the session even if no permanent cache
+ * backend is setup. */
+ $cache = $injector->getInstance('Horde_Cache');
+ if ($cache instanceof Horde_Cache_Null) {
+ $instance = $session->retrieve('imp_imaptree');
+ } else {
+ try {
+ $instance = @unserialize($cache->get($session->get('imp', 'treeob'), 86400));
+ } catch (Exception $e) {
+ Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
+ }
+ }
+ } else {
+ $session->set('imp', 'treeob', strval(new Horde_Support_Randomid()));
+ }
+
+ if (!($instance instanceof IMP_Imap_Tree)) {
+ $instance = new IMP_Imap_Tree();
+ }
+
+ register_shutdown_function(array($this, 'shutdown'), $instance, $injector);
+
+ return $instance;
+ }
+
+ /**
+ * Store serialized version of object in the current session.
+ *
+ * @param IMP_Imap_Tree $instance Tree object.
+ * @param Horde_Injector $injector Injector object.
+ */
+ public function shutdown($instance, $injector)
+ {
+ global $session;
+
+ /* Only need to store the object if the tree has changed. */
+ if ($instance->changed) {
+ $cache = $injector->getInstance('Horde_Cache');
+ if ($cache instanceof Horde_Cache_Null) {
+ $session->store($instance, true, 'imp_imaptree');
+ } else {
+ $cache->set($GLOBALS['session']->get('imp', 'treeob'), serialize($instance), 86400);
+ }
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Mail
+{
+ /**
+ * Return the Horde_Mail instance.
+ *
+ * @return Horde_Mail The singleton instance.
+ * @throws Horde_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ /* We don't actually want to alter the contents of the $conf['mailer']
+ * array, so we make a copy of the current settings. We will apply our
+ * modifications (if any) to the copy, instead. */
+ $params = $GLOBALS['conf']['mailer']['params'];
+
+ /* Force the SMTP host and port value to the current SMTP server if
+ * one has been selected for this connection. */
+ $params = array_merge($params, $GLOBALS['session']->get('imp', 'smtp', Horde_Session::TYPE_ARRAY));
+
+ /* If SMTP authentication has been requested, use either the username
+ * and password provided in the configuration or populate the username
+ * and password fields based on the current values for the user. Note
+ * that we assume that the username and password values from the
+ * current IMAP / POP3 connection are valid for SMTP authentication as
+ * well. */
+ if (!empty($params['auth']) && empty($params['username'])) {
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
+ $params['username'] = $imap_ob->getParam('username');
+ $params['password'] = $imap_ob->getParam('password');
+ }
+
+ $transport = $GLOBALS['conf']['mailer']['type'];
+ $class = 'Horde_Mail_Transport_' . ucfirst($transport);
+ if (class_exists($class)) {
+ return new $class($params);
+ }
+
+ throw new Horde_Exception('Unable to find class for transport ' . $transport);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based IMP_Mailbox_List:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector:: based IMP_Mailbox_List:: 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.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_MailboxList
+{
+ /**
+ * Instances.
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Injector $injector The injector to use.
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ register_shutdown_function(array($this, 'shutdown'));
+ }
+
+ /**
+ * Return the mailbox list instance.
+ * For IMP/MIMP, returns an IMP_Mailbox_List_Track object.
+ * For DIMP/Mobile, returns an IMP_Mailbox_List object.
+ *
+ * @param string $mailbox The mailbox name.
+ * @param IMP_Indices $indices An indices object. Only used for 'imp' and
+ * 'mimp' views.
+ *
+ * @return IMP_Mailbox_List The singleton instance.
+ * @throws IMP_Exception
+ */
+ public function create($mailbox, $indices = null)
+ {
+ $mode = IMP::getViewMode();
+
+ if (!isset($this->_instances[$mailbox])) {
+ switch ($mode) {
+ case 'dimp':
+ case 'mobile':
+ $ob = new IMP_Mailbox_List($mailbox);
+ break;
+
+ case 'imp':
+ case 'mimp':
+ try {
+ $ob = $GLOBALS['session']->get('imp', 'imp_mailbox/' . $mailbox);
+ } catch (Exception $e) {
+ $ob = null;
+ }
+
+ if (is_null($ob)) {
+ $ob = new IMP_Mailbox_List_Track($mailbox);
+ }
+ break;
+ }
+
+ $this->_instances[$mailbox] = $ob;
+ }
+
+ switch ($mode) {
+ case 'imp':
+ case 'mimp':
+ $this->_instances[$mailbox]->setIndex($indices);
+ $this->_instance[$mailbox]->checkcache = is_null($indices);
+ break;
+ }
+
+ return $this->_instances[$mailbox];
+ }
+
+ /**
+ * Tasks to perform on shutdown.
+ */
+ public function shutdown()
+ {
+ switch (IMP::getViewMode()) {
+ case 'imp':
+ case 'mimp':
+ /* Cache mailbox information if viewing in standard (IMP) message
+ * mode. Needed to keep navigation consistent when moving through
+ * the message list, and to ensure messages aren't marked as
+ * missing in search mailboxes (e.g. if search is dependent on
+ * unseen flag). */
+ foreach ($this->_instances as $key => $val) {
+ if ($val->changed) {
+ $GLOBALS['session']->set('imp', 'imp_mailbox/' . $key, $val);
+ }
+ }
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * 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 Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * 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_Factory_MimeViewer
+{
+ /**
+ * 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;
+ }
+
+ /**
+ * Attempts to return a concrete Horde_Mime_Viewer object based on the
+ * MIME type.
+ *
+ * @param Horde_Mime_Part $mime An object with the data to be rendered.
+ * @param IMP_Contents $contents The IMP_Contents object associated with
+ * $mime.
+ * @param string $type The MIME type to use for loading.
+ *
+ * @return Horde_Mime_Viewer_Base The newly created instance.
+ * @throws Horde_Mime_Viewer_Exception
+ */
+ public function create(Horde_Mime_Part $mime,
+ IMP_Contents $contents = null, $type = null)
+ {
+ list($driver, $params) = $this->_injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig($type ? $type : $mime->getType(), 'imp');
+
+ switch ($driver) {
+ case 'Report':
+ case 'Security':
+ $params['viewer_callback'] = array($this, 'createCallback');
+ break;
+ }
+
+ $params['imp_contents'] = $contents;
+
+ return Horde_Mime_Viewer::factory($driver, $mime, $params);
+ }
+
+ /**
+ * Callback used to return a MIME Viewer object from within certain
+ * Viewer drivers.
+ *
+ * @param Horde_Mime_Viewer_Base $viewer The MIME Viewer driver
+ * requesting the new object.
+ * @param Horde_Mime_Part $mime An object with the data to be
+ * rendered.
+ * @param string $type The MIME type to use for
+ * rendering.
+ *
+ * @return Horde_Mime_Viewer_Base The newly created instance.
+ * @throws Horde_Mime_Viewer_Exception
+ */
+ public function createCallback(Horde_Mime_Viewer_Base $viewer,
+ Horde_Mime_Part $mime, $type)
+ {
+ return $this->create($mime, $viewer->getConfigParam('imp_contents'), $type);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Pgp
+{
+ /**
+ * Return the IMP_Crypt_Pgp instance.
+ *
+ * @return IMP_Crypt_Pgp The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $params = array(
+ 'program' => $GLOBALS['conf']['gnupg']['path']
+ );
+
+ if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
+ $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
+ if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
+ $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
+ }
+ }
+
+ return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Pgp', $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Quota object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Quota object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Quota
+{
+ /**
+ * Return the IMP_Quota instance.
+ *
+ * @return IMP_Quota The singleton instance.
+ * @throws IMP_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $qparams = $GLOBALS['session']->get('imp', 'imap_quota');
+
+ if (!isset($qparams['driver'])) {
+ throw new IMP_Exception('Quota config missing driver parameter.');
+ }
+ $driver = $qparams['driver'];
+ $params = isset($qparams['params'])
+ ? $qparams['params']
+ : array();
+
+ /* If 'password' exists in params, it has been encrypted in the
+ * session so we need to decrypt. */
+ if (isset($params['password'])) {
+ $secret = $injector->getInstance('Horde_Secret');
+ $params['password'] = $secret->read($secret->getKey('imp'), $params['password']);
+ }
+
+ $imap_ob = $injector->getInstance('IMP_Factory_Imap')->create();
+
+ switch (Horde_String::lower($driver)) {
+ case 'imap':
+ $params['imap_ob'] = $imap_ob;
+ $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
+ ? 'INBOX'
+ : IMP::$mailbox;
+ break;
+
+ case 'sql':
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
+ break;
+ }
+
+ $params['username'] = $imap_ob->getParam('username');
+
+ return IMP_Quota::factory($driver, $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Search object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Search object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Search
+{
+ /**
+ * Return the IMP_Search instance.
+ *
+ * @return IMP_Search The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ try {
+ $instance = $GLOBALS['session']->get('imp', 'search');
+ } catch (Exception $e) {
+ Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
+ $instance = null;
+ }
+
+ if (is_null($instance)) {
+ $instance = new IMP_Search();
+ }
+
+ register_shutdown_function(array($this, 'shutdown'), $instance);
+
+ return $instance;
+ }
+
+ /**
+ * Store serialized version of object in the current session.
+ *
+ * @param IMP_Search $instance Search object.
+ */
+ public function shutdown($instance)
+ {
+ /* Only need to store the object if the object has changed. */
+ if ($instance->changed) {
+ $GLOBALS['session']->set('imp', 'search', $instance);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Sentmail object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Sentmail object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Sentmail
+{
+ /**
+ * Return the IMP_Sentmail instance.
+ *
+ * @return IMP_Sentmail The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $driver = empty($GLOBALS['conf']['sentmail']['driver'])
+ ? 'Null'
+ : $GLOBALS['conf']['sentmail']['driver'];
+ $params = Horde::getDriverConfig('sentmail', $driver);
+
+ if (strcasecmp($driver, 'Sql') === 0) {
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
+ } elseif (strcasecmp($driver, 'None') === 0) {
+ $driver = 'Null';
+ }
+
+ return IMP_Sentmail::factory($driver, $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Smime object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Smime object.
+ *
+ * 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
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Factory_Smime
+{
+ /**
+ * Return the IMP_Crypt_Smime instance.
+ *
+ * @return IMP_Crypt_Smime The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Smime');
+ }
+
+}
}
$addr = array();
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
foreach (array_keys($indices) as $mbox) {
$imp_imap->checkUidvalidity($mbox);
/* Get the list of from addresses. */
foreach ($indices as $mbox => $idx) {
- $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+ $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
$hdr = $contents->getHeaderOb();
$addr[] = Horde_Mime_Address::bareAddress($hdr->getValue('from'));
}
case 'imapflag':
/* IMAP keywords must conform to RFC 3501 [9] (flag-keyword).
* Convert whitespace to underscore. */
- $this->_imapflag = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($value, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
+ $this->_imapflag = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($value, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
break;
case 'label':
try {
/* Make sure we are in R/W mailbox mode (SELECT). No flags are
* allowed in EXAMINE mode. */
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$imp_imap->openMailbox($opts['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
$status = $imp_imap->status($opts['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
} catch (Horde_Imap_Client_Exception $e) {
}
try {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->deleteMailbox($folder);
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->createMailbox($folder, array('special_use' => $special_use));
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->listMailboxes($folder, array('flat' => true));
+ $ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listMailboxes($folder, array('flat' => true));
return !empty($ret);
} catch (Horde_Imap_Client_Exception $e) {
return false;
$all_folders = $this->getAllSubfolders($old);
try {
- $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->renameMailbox($old, $new);
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->subscribeMailbox($folder, true);
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->subscribeMailbox($folder, false);
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($folder, array(
+ $res = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$fd = fopen($mbox, 'r');
while (!feof($fd)) {
return $cache[$folder];
}
- $ns_info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespace($folder);
+ $ns_info = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getNamespace($folder);
$delimiter = is_null($ns_info) ? '' : $ns_info['delimiter'];
/* Substitute any translated prefix text. */
{
$t = $GLOBALS['injector']->createInstance('Horde_Template');
$t->set('forminput', Horde_Util::formInput());
- $t->set('use_folders', $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders(), true);
+ $t->set('use_folders', $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders(), true);
if ($t->get('use_folders')) {
Horde::addScriptFile('imp.js', 'imp');
$menu_view = $GLOBALS['prefs']->getValue('menu_view');
*/
static public function folderPref($folder, $append)
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->getACL($mbox);
+ return $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
+ $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->listACLRights($mbox, $user);
+ $rights = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listACLRights($mbox, $user);
$rights = array_merge($rights['required'], $rights['optional']);
foreach ($rights as $val) {
if (strpos($val, 'a') !== false) {
unset($this->_cache['fulllist'], $this->_cache['subscribed']);
/* Do IMAP specific initialization. */
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if ($session->get('imp', 'protocol') == 'imap') {
$ns = $imp_imap->getNamespaceList();
$ptr = reset($ns);
}
try {
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
+ $this->_insert($GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->getNamespace($mailbox);
+ return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getNamespace($mailbox);
}
return null;
}
$this->changed = true;
}
- if (!$GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+ if (!$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
return;
}
public function createMailboxName($parent, $new)
{
$ns_info = empty($parent)
- ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->defaultNamespace()
+ ? $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->defaultNamespace()
: $this->_getNamespace($parent);
if (is_null($ns_info)) {
$info->unseen = 0;
try {
- 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 ($msgs_info = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->getUtils()->fromSequenceString($data);
+ $indices = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
+ return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
}
/* Iterator methods. */
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based Horde_Auth_Imap:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based Horde_Auth_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.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_AuthImap
-{
- /**
- * Return the Horde_Auth_Imap:: instance that uses IMP configuration.
- *
- * @return Horde_Auth_Imap The singleton instance.
- * @throws IMP_Exception
- */
- public function create(Horde_Injector $injector)
- {
- $params = $GLOBALS['registry']->callByPackage('imp', 'server');
- if (is_null($params)) {
- throw new IMP_Exception('No server parameters found.');
- }
-
- $aparams = $GLOBALS['session']->get('imp', 'imap_admin', Horde_Session::TYPE_ARRAY);
-
- $params = array_merge(
- $params,
- (isset($aparams['params']) ? $aparams['params'] : array()),
- array(
- 'default_user' => $GLOBALS['registry']->getAuth(),
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- )
- );
-
- if (isset($params['admin_password'])) {
- $secret = $injector->getInstance('Horde_Secret');
- $params['admin_password'] = $secret->read($secret->getKey('imp'), $params['admin_password']);
- }
-
- return Horde_Auth::factory('imap', $params);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based IMP_Compose:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector:: based IMP_Compose:: 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.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Compose
-{
- /**
- * 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;
-
- register_shutdown_function(array($this, 'shutdown'));
- }
-
- /**
- * Return the IMP_Compose:: instance.
- *
- * @param string $cacheid The cache ID string.
- *
- * @return IMP_Compose The singleton compose instance.
- * @throws IMP_Exception
- */
- public function create($cacheid = null)
- {
- if (empty($cacheid)) {
- $cacheid = strval(new Horde_Support_Randomid());
- } elseif (!isset($this->_instances[$cacheid])) {
- $this->_instances[$cacheid] = $GLOBALS['session']->retrieve($cacheid);
- }
-
- if (empty($this->_instances[$cacheid])) {
- $this->_instances[$cacheid] = new IMP_Compose($cacheid);
- }
-
- return $this->_instances[$cacheid];
- }
-
- /**
- * Tasks to perform on shutdown.
- */
- public function shutdown()
- {
- global $session;
-
- $cache = $session->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY);
- $changed = false;
-
- foreach ($this->_instances as $key => $val) {
- switch ($val->changed) {
- case 'changed':
- $val->changed = '';
- $session->store($val, false, $key);
- $cache[$key] = 1;
- $changed = true;
- break;
-
- case 'deleted':
- unset($cache[$key]);
- $session->purge($key);
- $changed = true;
- break;
- }
-
- }
-
- if ($changed) {
- $session->set('imp', 'compose_cache', $cache);
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based IMP_Contents:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector:: based IMP_Contents:: 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.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Contents
-{
- /**
- * Instances.
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- * Return the IMP_Contents:: instance.
- *
- * @param IMP_Indices $indices An indices object.
- *
- * @return IMP_Contents The singleton contents instance.
- * @throws IMP_Exception
- */
- public function create($indices)
- {
- $key = strval($indices);
-
- if (!isset($this->_instances[$key])) {
- $this->_instances[$key] = new IMP_Contents($indices);
- }
-
- return $this->_instances[$key];
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Flags object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Flags object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Flags
-{
- /**
- * Return the IMP_Flags instance.
- *
- * @return IMP_Flags The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- try {
- $instance = $GLOBALS['session']->get('imp', 'flags');
- } catch (Exception $e) {
- Horde::logMessage('Could not unserialize stored IMP_Flags object.', 'DEBUG');
- $instance = null;
- }
-
- if (is_null($instance)) {
- $instance = new IMP_Flags();
- }
-
- register_shutdown_function(array($this, 'shutdown'), $instance);
-
- return $instance;
- }
-
- /**
- * Store serialized version of object in the current session.
- *
- * @param IMP_Flags $instance Flags object.
- */
- public function shutdown($instance)
- {
- /* Only need to store the object if the object has changed. */
- if ($instance->changed) {
- $GLOBALS['session']->set('imp', 'flags', $instance);
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for IMP's identity object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for IMP's identity object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Identity
-{
- /**
- * Return the IMP identity instance.
- *
- * @return IMP_Prefs_Identity The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- return $injector->getInstance('Horde_Core_Factory_Identity')->create(null, 'imp');
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based IMP_Imap:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @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.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Imap
-{
- /**
- * Instances.
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- * The list of instances to save.
- *
- * @var array
- */
- private $_save = array();
-
- /**
- * Return the IMP_Imap:: instance.
- *
- * @param string $id The server ID.
- * @param boolean $save Save the instance in the session?
- *
- * @return IMP_Imap The singleton instance.
- * @throws IMP_Exception
- */
- public function create($id = null, $save = false)
- {
- global $session;
-
- if (is_null($id) &&
- !($id = $session->get('imp', 'server_key'))) {
- $id = 'default';
- }
-
- if (!isset($this->_instances[$id])) {
- if (!($ob = $session->get('imp', 'imap_ob/' . $id))) {
- $ob = new IMP_Imap();
- }
-
- $this->_instances[$id] = $ob;
- }
-
- if ($save && !$session->exists('imp', 'imap_ob/' . $id)) {
- if (empty($this->_save)) {
- register_shutdown_function(array($this, 'shutdown'));
- }
- $this->_save[] = $id;
- }
-
- return $this->_instances[$id];
- }
-
- /**
- * Saves IMP_Imap instances to the session.
- */
- public function shutdown()
- {
- foreach (array_unique($this->_save) as $id) {
- $GLOBALS['session']->set('imp', 'imap_ob/' . $id, $this->_instances[$id]);
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Imap_Tree object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Imap_Tree object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Imaptree
-{
- /**
- * Return the IMP_Imap_Tree object.
- *
- * @return IMP_Imap_Tree The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- global $session;
-
- $instance = null;
-
- /* If an IMP_Imap_Tree object is currently stored in the cache,
- * re-create that object. Else, create a new instance. */
- if ($session->exists('imp', 'treeob')) {
- /* Since IMAP tree generation is so expensive/time-consuming,
- * fallback to storing in the session even if no permanent cache
- * backend is setup. */
- $cache = $injector->getInstance('Horde_Cache');
- if ($cache instanceof Horde_Cache_Null) {
- $instance = $session->retrieve('imp_imaptree');
- } else {
- try {
- $instance = @unserialize($cache->get($session->get('imp', 'treeob'), 86400));
- } catch (Exception $e) {
- Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
- }
- }
- } else {
- $session->set('imp', 'treeob', strval(new Horde_Support_Randomid()));
- }
-
- if (!($instance instanceof IMP_Imap_Tree)) {
- $instance = new IMP_Imap_Tree();
- }
-
- register_shutdown_function(array($this, 'shutdown'), $instance, $injector);
-
- return $instance;
- }
-
- /**
- * Store serialized version of object in the current session.
- *
- * @param IMP_Imap_Tree $instance Tree object.
- * @param Horde_Injector $injector Injector object.
- */
- public function shutdown($instance, $injector)
- {
- global $session;
-
- /* Only need to store the object if the tree has changed. */
- if ($instance->changed) {
- $cache = $injector->getInstance('Horde_Cache');
- if ($cache instanceof Horde_Cache_Null) {
- $session->store($instance, true, 'imp_imaptree');
- } else {
- $cache->set($GLOBALS['session']->get('imp', 'treeob'), serialize($instance), 86400);
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Mail
-{
- /**
- * Return the Horde_Mail instance.
- *
- * @return Horde_Mail The singleton instance.
- * @throws Horde_Exception
- */
- public function create(Horde_Injector $injector)
- {
- /* We don't actually want to alter the contents of the $conf['mailer']
- * array, so we make a copy of the current settings. We will apply our
- * modifications (if any) to the copy, instead. */
- $params = $GLOBALS['conf']['mailer']['params'];
-
- /* Force the SMTP host and port value to the current SMTP server if
- * one has been selected for this connection. */
- $params = array_merge($params, $GLOBALS['session']->get('imp', 'smtp', Horde_Session::TYPE_ARRAY));
-
- /* If SMTP authentication has been requested, use either the username
- * and password provided in the configuration or populate the username
- * and password fields based on the current values for the user. Note
- * that we assume that the username and password values from the
- * current IMAP / POP3 connection are valid for SMTP authentication as
- * well. */
- if (!empty($params['auth']) && empty($params['username'])) {
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
- $params['username'] = $imap_ob->getParam('username');
- $params['password'] = $imap_ob->getParam('password');
- }
-
- $transport = $GLOBALS['conf']['mailer']['type'];
- $class = 'Horde_Mail_Transport_' . ucfirst($transport);
- if (class_exists($class)) {
- return new $class($params);
- }
-
- throw new Horde_Exception('Unable to find class for transport ' . $transport);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based IMP_Mailbox_List:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector:: based IMP_Mailbox_List:: 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.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_MailboxList
-{
- /**
- * Instances.
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- * Constructor.
- *
- * @param Horde_Injector $injector The injector to use.
- */
- public function __construct(Horde_Injector $injector)
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
-
- /**
- * Return the mailbox list instance.
- * For IMP/MIMP, returns an IMP_Mailbox_List_Track object.
- * For DIMP/Mobile, returns an IMP_Mailbox_List object.
- *
- * @param string $mailbox The mailbox name.
- * @param IMP_Indices $indices An indices object. Only used for 'imp' and
- * 'mimp' views.
- *
- * @return IMP_Mailbox_List The singleton instance.
- * @throws IMP_Exception
- */
- public function create($mailbox, $indices = null)
- {
- $mode = IMP::getViewMode();
-
- if (!isset($this->_instances[$mailbox])) {
- switch ($mode) {
- case 'dimp':
- case 'mobile':
- $ob = new IMP_Mailbox_List($mailbox);
- break;
-
- case 'imp':
- case 'mimp':
- try {
- $ob = $GLOBALS['session']->get('imp', 'imp_mailbox/' . $mailbox);
- } catch (Exception $e) {
- $ob = null;
- }
-
- if (is_null($ob)) {
- $ob = new IMP_Mailbox_List_Track($mailbox);
- }
- break;
- }
-
- $this->_instances[$mailbox] = $ob;
- }
-
- switch ($mode) {
- case 'imp':
- case 'mimp':
- $this->_instances[$mailbox]->setIndex($indices);
- $this->_instance[$mailbox]->checkcache = is_null($indices);
- break;
- }
-
- return $this->_instances[$mailbox];
- }
-
- /**
- * Tasks to perform on shutdown.
- */
- public function shutdown()
- {
- switch (IMP::getViewMode()) {
- case 'imp':
- case 'mimp':
- /* Cache mailbox information if viewing in standard (IMP) message
- * mode. Needed to keep navigation consistent when moving through
- * the message list, and to ensure messages aren't marked as
- * missing in search mailboxes (e.g. if search is dependent on
- * unseen flag). */
- foreach ($this->_instances as $key => $val) {
- if ($val->changed) {
- $GLOBALS['session']->set('imp', 'imp_mailbox/' . $key, $val);
- }
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
- *
- * 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 Horde_Mime_Viewer factory for IMP drivers.
- *
- * 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_MimeViewer
-{
- /**
- * 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;
- }
-
- /**
- * Attempts to return a concrete Horde_Mime_Viewer object based on the
- * MIME type.
- *
- * @param Horde_Mime_Part $mime An object with the data to be rendered.
- * @param IMP_Contents $contents The IMP_Contents object associated with
- * $mime.
- * @param string $type The MIME type to use for loading.
- *
- * @return Horde_Mime_Viewer_Base The newly created instance.
- * @throws Horde_Mime_Viewer_Exception
- */
- public function create(Horde_Mime_Part $mime,
- IMP_Contents $contents = null, $type = null)
- {
- list($driver, $params) = $this->_injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig($type ? $type : $mime->getType(), 'imp');
-
- switch ($driver) {
- case 'Report':
- case 'Security':
- $params['viewer_callback'] = array($this, 'createCallback');
- break;
- }
-
- $params['imp_contents'] = $contents;
-
- return Horde_Mime_Viewer::factory($driver, $mime, $params);
- }
-
- /**
- * Callback used to return a MIME Viewer object from within certain
- * Viewer drivers.
- *
- * @param Horde_Mime_Viewer_Base $viewer The MIME Viewer driver
- * requesting the new object.
- * @param Horde_Mime_Part $mime An object with the data to be
- * rendered.
- * @param string $type The MIME type to use for
- * rendering.
- *
- * @return Horde_Mime_Viewer_Base The newly created instance.
- * @throws Horde_Mime_Viewer_Exception
- */
- public function createCallback(Horde_Mime_Viewer_Base $viewer,
- Horde_Mime_Part $mime, $type)
- {
- return $this->create($mime, $viewer->getConfigParam('imp_contents'), $type);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Pgp
-{
- /**
- * Return the IMP_Crypt_Pgp instance.
- *
- * @return IMP_Crypt_Pgp The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- $params = array(
- 'program' => $GLOBALS['conf']['gnupg']['path']
- );
-
- if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
- $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
- if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
- $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
- }
- }
-
- return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Pgp', $params);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Quota object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Quota object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Quota
-{
- /**
- * Return the IMP_Quota instance.
- *
- * @return IMP_Quota The singleton instance.
- * @throws IMP_Exception
- */
- public function create(Horde_Injector $injector)
- {
- $qparams = $GLOBALS['session']->get('imp', 'imap_quota');
-
- if (!isset($qparams['driver'])) {
- throw new IMP_Exception('Quota config missing driver parameter.');
- }
- $driver = $qparams['driver'];
- $params = isset($qparams['params'])
- ? $qparams['params']
- : array();
-
- /* If 'password' exists in params, it has been encrypted in the
- * session so we need to decrypt. */
- if (isset($params['password'])) {
- $secret = $injector->getInstance('Horde_Secret');
- $params['password'] = $secret->read($secret->getKey('imp'), $params['password']);
- }
-
- $imap_ob = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
-
- switch (Horde_String::lower($driver)) {
- case 'imap':
- $params['imap_ob'] = $imap_ob;
- $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
- ? 'INBOX'
- : IMP::$mailbox;
- break;
-
- case 'sql':
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
- break;
- }
-
- $params['username'] = $imap_ob->getParam('username');
-
- return IMP_Quota::factory($driver, $params);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Search object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Search object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Search
-{
- /**
- * Return the IMP_Search instance.
- *
- * @return IMP_Search The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- try {
- $instance = $GLOBALS['session']->get('imp', 'search');
- } catch (Exception $e) {
- Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
- $instance = null;
- }
-
- if (is_null($instance)) {
- $instance = new IMP_Search();
- }
-
- register_shutdown_function(array($this, 'shutdown'), $instance);
-
- return $instance;
- }
-
- /**
- * Store serialized version of object in the current session.
- *
- * @param IMP_Search $instance Search object.
- */
- public function shutdown($instance)
- {
- /* Only need to store the object if the object has changed. */
- if ($instance->changed) {
- $GLOBALS['session']->set('imp', 'search', $instance);
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Sentmail object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Sentmail object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Sentmail
-{
- /**
- * Return the IMP_Sentmail instance.
- *
- * @return IMP_Sentmail The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- $driver = empty($GLOBALS['conf']['sentmail']['driver'])
- ? 'Null'
- : $GLOBALS['conf']['sentmail']['driver'];
- $params = Horde::getDriverConfig('sentmail', $driver);
-
- if (strcasecmp($driver, 'Sql') === 0) {
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
- } elseif (strcasecmp($driver, 'None') === 0) {
- $driver = 'Null';
- }
-
- return IMP_Sentmail::factory($driver, $params);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Crypt_Smime object.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-
-/**
- * A Horde_Injector based factory for the IMP_Crypt_Smime object.
- *
- * 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
- * @link http://pear.horde.org/index.php?package=IMP
- * @package IMP
- */
-class IMP_Injector_Factory_Smime
-{
- /**
- * Return the IMP_Crypt_Smime instance.
- *
- * @return IMP_Crypt_Smime The singleton instance.
- */
- public function create(Horde_Injector $injector)
- {
- return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Smime');
- }
-
-}
protected function _upgradeExpireImapCache()
{
try {
- $ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
+ $ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->ob;
if ($cache = $ob->getCache()) {
$ob->login();
));
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
if (empty($options['preview'])) {
$cache = null;
!in_array('\\seen', $v['flags'])))) {
if (empty($preview_info[$k])) {
try {
- $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $k));
+ $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $k));
$prev = $imp_contents->generatePreview();
$preview_info[$k] = array('IMPpreview' => $prev['text'], 'IMPpreviewc' => $prev['cut']);
if (!is_null($cache)) {
}
$criteria = new Horde_Imap_Client_Search_Query();
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
+ $status = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
+ $res = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $GLOBALS['session']->get('imp', 'imap_thread')));
+ $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $GLOBALS['session']->get('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_Injector_Factory_Imap')->create()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
+ return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
} catch (Horde_Imap_Client_Exception $e) {}
}
break;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
foreach ($indices->indices() as $mbox => $msgIndices) {
$error = null;
}
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
foreach ($indices->indices() as $mbox => $msgIndices) {
$error = null;
foreach ($indices as $folder => $index) {
/* Fetch the message contents. */
- $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($folder, $index));
+ $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($folder, $index));
/* Fetch the message headers. */
$imp_headers = $imp_contents->getHeaderOb();
return;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
if ($imp_imap->isReadOnly($mbox)) {
throw new IMP_Exception(_("Cannot strip the MIME part as the mailbox is read-only."));
$uidvalidity = $imp_imap->checkUidvalidity($mbox);
- $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+ $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($indices);
$message = $contents->getMIMEMessage();
$boundary = trim($message->getContentTypeParameter('boundary'), '"');
$action_array = $action
? array('add' => $flags)
: array('remove' => $flags);
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
foreach ($mboxes as $val) {
try {
return $msg_list ? new IMP_Indices() : null;
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
$process_list = $update_list = array();
{
global $notification, $prefs;
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
+ $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
$size = 0;
reset($res);
if ($val == $number) {
$parts[$number] = $this->_mimepart->getContents();
} else {
- $ic = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $val));
+ $ic = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $val));
$parts[$ic->getMIMEMessage()->getContentTypeParameter('number')] = $ic->getBody();
}
}
public function notify($options)
{
if (in_array('status', $options['listeners']) &&
- ($ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()) &&
+ ($ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()) &&
$ob->ob) {
/* Display IMAP alerts. */
foreach ($ob->alerts() as $alert) {
*/
public function saveSentmail($ident = null)
{
- return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()
+ return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders()
? $this->getValue('save_sent_mail', $ident)
: false;
}
$ui->suppressGroups[] = 'smime';
}
- if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+ if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$ui->suppressGroups[] = 'searches';
}
case 'alternative_display':
$mock_part = new Horde_Mime_Part();
$mock_part->setType('text/html');
- $v = $injector->getInstance('IMP_Injector_Factory_MimeViewer')->create($mock_part);
+ $v = $injector->getInstance('IMP_Factory_MimeViewer')->create($mock_part);
if (!$v->canRender('inline')) {
$ui->suppress[] = 'alternative_display';
$t = $injector->createInstance('Horde_Template');
$t->setOption('gettext', true);
- if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+ if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$t->set('nofolder', true);
} else {
$mailbox_selected = $prefs->getValue('initial_page');
{
global $injector, $prefs;
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->allowFolders() ||
$prefs->isLocked('sent_mail_folder')) {
{
global $injector, $prefs;
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->allowFolders() ||
$prefs->isLocked($pref)) {
$folder = substr($folder, strlen(self::PREF_SPECIALUSE));
} elseif (!empty($new)) {
$new = Horde_String::convertCharset($new, 'UTF-8', 'UTF7-IMAP');
- $folder = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($new);
+ $folder = $injector->getInstance('IMP_Factory_Imap')->create()->appendNamespace($new);
if (!$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_Injector_Factory_Imap')->create()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
+ $this->_cache = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
'attributes' => true,
'special_use' => true,
'sort' => true
*/
public function getQuota()
{
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$userDetails = $this->_getUserDetails(
$this->_params['username'],
$GLOBALS['session']->get('imp', 'maildomain')
*/
public function imapSearch($mailbox, $query, $opts = array())
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_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_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$report_count = $result = 0;
foreach ($indices->indices() as $mbox => $msgIndices) {
/* Fetch the raw message contents (headers and complete
* body). */
try {
- $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+ $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
} catch (IMP_Exception $e) {
continue;
}
}
if (!isset($imp_compose)) {
- $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create();
+ $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create();
try {
$from_line = $GLOBALS['injector']->getInstance('IMP_Identity')->getFromLine();
} catch (Horde_Exception $e) {
$GLOBALS['injector']->getInstance('IMP_Filter')->filter('INBOX');
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
/* Get list of mailboxes to poll. */
$poll = $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(true);
if (!is_null($indices)) {
try {
- $ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+ $ob = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($indices);
} catch (Horde_Exception $e) {}
}
*/
public function MDNCheck($mailbox, $uid, $headers, $confirmed = false)
{
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
$pref_val = $GLOBALS['prefs']->getValue('send_mdn');
if (!$pref_val || $imp_imap->isReadOnly($mailbox)) {
$t->setOption('gettext', true);
if (!empty($args['composeCache'])) {
- $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($args['composeCache']);
+ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($args['composeCache']);
$t->set('composeCache', $args['composeCache']);
}
$t->set('read_receipt_set', ($d_read != 'ask'));
}
- $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
$t->set('save_sent_mail', ($imp_imap->allowFolders() && !$prefs->isLocked('save_sent_mail')));
$t->set('priority', $prefs->getValue('set_priority'));
if (!$prefs->isLocked('default_encrypt') &&
}
/* Generate the sorted mailbox list now. */
- $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($mbox);
+ $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($mbox);
$sorted_list = $imp_mailbox->getSortedList();
$msgcount = count($sorted_list['s']);
}
}
- $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
/* These entries may change during a session, so always need to
* update them. */
* view. */
$imp_contents = null;
try {
- $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox, array(
+ $fetch_ret = $GLOBALS['injector']->getInstance('IMP_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)));
if (isset($fetch_ret[$uid]['headertext'])) {
/* Parse MIME info and create the body of the message. */
- $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mailbox, $uid));
+ $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mailbox, $uid));
}
} catch (Horde_Imap_Client_Exception $e) {
} catch (IMP_Exception $e) {}
$t->setOption('gettext', true);
/* Determine if mailbox is readonly. */
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
$readonly = $imp_imap->isReadOnly(IMP::$mailbox);
/* Get the base URL for this page. */
}
/* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox);
$pageOb = $imp_mailbox->buildMailboxPage($vars->p, $vars->s);
/* Generate page title. */
$do_filter = false;
$imp_flags = $injector->getInstance('IMP_Flags');
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
$indices = new IMP_Indices($vars->indices);
/* Run through the action handlers */
}
/* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox);
$pageOb = $imp_mailbox->buildMailboxPage($vars->page, $start);
$show_preview = $prefs->getValue('preview_enabled');
$imp_ui = new IMP_Ui_Message();
$js_onload = $js_vars = array();
-$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($vars->folder);
+$readonly = $injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly($vars->folder);
switch ($vars->actionID) {
case 'strip_attachment':
$vars = Horde_Variables::getDefaultVariables();
/* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
if (!$imp_mailbox->isValidIndex()) {
IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect();
}
-$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
+$readonly = $injector->getInstance('IMP_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_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+ $flags_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_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)));
/* Parse the message. */
try {
- $imp_contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
+ $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
} catch (IMP_Exception $e) {
IMP::generateIMPUrl('mailbox-mimp.php', $mailbox_name)->add('a', 'm')->redirect();
}
* 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_Injector_Factory_Imap')->create()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
+ $injector->getInstance('IMP_Factory_Imap')->create()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
}
/* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
if (!$imp_mailbox->isValidIndex()) {
_returnToMailbox(null, 'message_missing');
require IMP_BASE . '/mailbox.php';
}
/* Determine if mailbox is readonly. */
-$peek = $readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
+$peek = $readonly = $injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
/* Get mailbox/UID of message. */
$index_array = $imp_mailbox->getIMAPIndex();
/* Parse the message. */
try {
- $imp_contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
+ $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
} catch (IMP_Exception $e) {
$imp_mailbox->removeMsgs(true);
_returnToMailbox(null, 'message_missing');
try {
/* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
* before we can grab it. */
- $flags_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+ $flags_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
Horde_Imap_Client::FETCH_FLAGS => true,
), array('ids' => array($uid)));
- $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+ $fetch_ret = $injector->getInstance('IMP_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)));
$n_template->set('flaglist_set', $form_set);
$n_template->set('flaglist_unset', $form_unset);
- if ($injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+ if ($injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$n_template->set('move', Horde::widget('#', _("Move to folder"), 'widget moveAction', '', '', _("Move"), true));
$n_template->set('copy', Horde::widget('#', _("Copy to folder"), 'widget copyAction', '', '', _("Copy"), true));
$n_template->set('options', IMP::flistSelect(array('heading' => _("This message to"), 'new_folder' => true, 'inc_tasklists' => true, 'inc_notepads' => true)));
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mobile'));
new Horde_View_Helper_Text($view);
-if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
$view->allowFolders = false;
} else {
$view->allowFolders = true;
case 'save_attachment_public_key':
/* Retrieve the key from the message. */
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
$mime_part = $contents->getMIMEPart($vars->mime_id);
if (empty($mime_part)) {
throw new IMP_Exception('Cannot retrieve public key from message.');
$new_mail = (isset($request_parts[1]) && ($request_parts[1] === 'new'));
}
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create($mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create($mailbox);
$imp_search = $injector->getInstance('IMP_Search');
/* Obtain some information describing the mailbox state. */
/* Run through the action handlers. */
switch ($vars->actionID) {
case 'save_image':
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mbox, $vars->uid));
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mbox, $vars->uid));
$mime_part = $contents->getMIMEPart($vars->id);
$image_data = array(
'data' => $mime_part->getContents(),
case 'save_attachment_public_key':
/* Retrieve the key from the message. */
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
$mime_part = $contents->getMIMEPart($vars->mime_id);
if (empty($mime_part)) {
throw new IMP_Exception(_("Cannot retrieve public key from message."));
$has_blacklist = $registry->hasMethod('mail/blacklistFrom');
$has_whitelist = $registry->hasMethod('mail/whitelistFrom');
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
// Quota information
$show_quota = $session->get('imp', 'imap_quota')
? $vars->mode
: 'thread';
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
$error = false;
if ($mode == 'thread') {
/* Get the body of the message. */
$curr_msg = $curr_tree = array();
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
$mime_id = $contents->findBody();
if ($contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE)) {
$ret = $contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE);
* message data. Rather, we must use the IMP_Compose object to get the
* necessary data for Horde_Mime_Part. */
if ($vars->actionID == 'compose_attach_preview') {
- $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
$mime = $imp_compose->buildAttachment($vars->id);
$mime->setMimeId($vars->id);
if (!$vars->uid || !$vars->mailbox) {
exit;
}
- $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+ $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
}
/* Run through action handlers */
*/
protected function _init()
{
- $GLOBALS['injector']->bindFactory('Jonah_Driver', 'Jonah_Injector_Factory_Driver', 'create');
+ $GLOBALS['injector']->bindFactory('Jonah_Driver', 'Jonah_Factory_Driver', 'create');
if ($channel_id = Horde_Util::getFormData('channel_id')) {
$url = Horde::url('delivery/rss.php', true, -1)
--- /dev/null
+<?php
+/**
+ * Jonah_Driver factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you did not
+ * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Ben Klang <ben@alkaloid.net>
+ * @package Jonah
+ */
+class Jonah_Factory_Driver
+{
+ /**
+ * 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 driver instance.
+ *
+ * @param string $driver The concrete driver to return
+ * @param array $params An array of additional driver parameters.
+ *
+ * @return Jonah_Driver
+ * @throws Jonah_Exception
+ */
+ public function create()
+ {
+ $driver = Horde_String::ucfirst($GLOBALS['conf']['news']['storage']['driver']);
+ $driver = basename($driver);
+ $params = Horde::getDriverConfig(array('news', 'storage'), $driver);
+
+ $sig = md5($driver . serialize($params));
+ if (isset($this->_instances[$sig])) {
+ return $this->_instances[$sig];
+ }
+
+ $class = 'Jonah_Driver_' . $driver;
+ if (class_exists($class)) {
+ $object = new $class($params);
+ $this->_instances[$sig] = $object;
+ } else {
+ throw new Jonah_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
+ }
+
+ return $this->_instances[$sig];
+ }
+}
+++ /dev/null
-<?php
-/**
- * Jonah_Driver factory.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (BSD). If you did not
- * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @author Ben Klang <ben@alkaloid.net>
- * @package Jonah
- */
-class Jonah_Injector_Factory_Driver
-{
- /**
- * 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 driver instance.
- *
- * @param string $driver The concrete driver to return
- * @param array $params An array of additional driver parameters.
- *
- * @return Jonah_Driver
- * @throws Jonah_Exception
- */
- public function create()
- {
- $driver = Horde_String::ucfirst($GLOBALS['conf']['news']['storage']['driver']);
- $driver = basename($driver);
- $params = Horde::getDriverConfig(array('news', 'storage'), $driver);
-
- $sig = md5($driver . serialize($params));
- if (isset($this->_instances[$sig])) {
- return $this->_instances[$sig];
- }
-
- $class = 'Jonah_Driver_' . $driver;
- if (class_exists($class)) {
- $object = new $class($params);
- $this->_instances[$sig] = $object;
- } else {
- throw new Jonah_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
- }
-
- return $this->_instances[$sig];
- }
-}
\ No newline at end of file
$result = new stdClass;
try {
- $driver = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Driver')->create('Ical', $params);
+ $driver = $GLOBALS['injector']->getInstance('Kronolith_Factory_Driver')->create('Ical', $params);
$driver->open($this->_vars->url);
$ical = $driver->getRemoteCalendar(false);
$result->success = true;
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the registry entry for the Content system is present.');
}
- $GLOBALS['injector']->bindFactory('Kronolith_Geo', 'Kronolith_Injector_Factory_Geo', 'create');
+ $GLOBALS['injector']->bindFactory('Kronolith_Geo', 'Kronolith_Factory_Geo', 'create');
/* Set the timezone variable, if available. */
$GLOBALS['registry']->setTimeZone();
--- /dev/null
+<?php
+/**
+ * Horde_Injector based factory for Kronolith_Driver
+ */
+class Kronolith_Factory_Driver
+{
+ /**
+ * 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 driver instance.
+ *
+ * @param string $driver The storage backend to use
+ * @param array $params Driver params
+ *
+ * @return Kronolith_Driver
+ * @throws Kronolith_Exception
+ */
+ public function create($driver, $params = array())
+ {
+ $driver = basename($driver);
+ if (!empty($this->_instances[$driver])) {
+ return $this->_instances[$driver];
+ }
+ $key = $driver;
+ $class = 'Kronolith_Driver_' . $driver;
+ if (class_exists($class)) {
+ $driver = new $class($params);
+ try {
+ $driver->initialize();
+ } catch (Exception $e) {
+ $driver = new Kronolith_Driver($params, sprintf(_("The Calendar backend is not currently available: %s"), $e->getMessage()));
+ }
+ } else {
+ $driver = new Kronolith_Driver($params, sprintf(_("Unable to load the definition of %s."), $class));
+ }
+ $this->_instances[$key] = $driver;
+
+ return $driver;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Horde_Injector based factory for Kronolith_Geo drivers
+ *
+ * @author Michael J Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Factory_Geo
+{
+ /**
+ * Instances.
+ *
+ * @var array
+ */
+ private $_instances = array();
+
+ /**
+ * Return the driver instance.
+ *
+ * @return Kronolith_Storage
+ * @throws Kronolith_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ if (empty($this->_instances[$GLOBALS['conf']['maps']['geodriver']])) {
+ if (!empty($GLOBALS['conf']['maps']['geodriver'])) {
+ $class = 'Kronolith_Geo_' . $GLOBALS['conf']['maps']['geodriver'];
+ $db = $injector->getInstance('Horde_Db_Adapter');
+ $this->_instances[$GLOBALS['conf']['maps']['geodriver']] = new $class($db);
+ } else {
+ throw new Kronolith_Exception(_("Geospatial support not configured."));
+ }
+ }
+
+ return $this->_instances[$GLOBALS['conf']['maps']['geodriver']];
+ }
+
+}
--- /dev/null
+<?php
+
+class Kronolith_Factory_Storage
+{
+ /**
+ * 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 driver instance.
+ *
+ * @return Kronolith_Storage
+ * @throws Kronolith_Exception
+ */
+ public function create($params = array())
+ {
+ if (empty($params['user'])) {
+ $user = $GLOBALS['registry']->getAuth();
+ } else {
+ $user = $params['user'];
+ unset($params['user']);
+ }
+
+ if (empty($params['driver'])) {
+ $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
+ } else {
+ $driver = $params['driver'];
+ unset($params['driver']);
+ }
+ $driver = basename($driver);
+ $class = 'Kronolith_Storage_' . $driver;
+
+ $driver_params = Horde::getDriverConfig('storage', 'Sql');
+ if ($driver == 'Sql') {
+ if ($driver_params != 'Horde') {
+ // Custom DB config
+ $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('kronolith', Horde::getDriverConfig('storage', 'Sql'));
+ } else {
+ // Horde default DB config
+ $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter');
+ }
+ $params['table'] = $driver_params['table'];
+ }
+
+ if (class_exists($class)) {
+ $driver = new $class($user, $params);
+ } else {
+ throw new Kronolith_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+ }
+
+ try {
+ $driver->initialize();
+ } catch (Exception $e) {
+ $driver = new Kronolith_Storage($params);
+ }
+
+ return $driver;
+ }
+
+}
}
/* Check storage driver. */
- $storage = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Storage')->create();
+ $storage = $GLOBALS['injector']->getInstance('Kronolith_Factory_Storage')->create();
try {
$fb = $storage->search($email);
+++ /dev/null
-<?php
-/**
- * Horde_Injector based factory for Kronolith_Driver
- */
-class Kronolith_Injector_Factory_Driver
-{
- /**
- * 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 driver instance.
- *
- * @param string $driver The storage backend to use
- * @param array $params Driver params
- *
- * @return Kronolith_Driver
- * @throws Kronolith_Exception
- */
- public function create($driver, $params = array())
- {
- $driver = basename($driver);
- if (!empty($this->_instances[$driver])) {
- return $this->_instances[$driver];
- }
- $key = $driver;
- $class = 'Kronolith_Driver_' . $driver;
- if (class_exists($class)) {
- $driver = new $class($params);
- try {
- $driver->initialize();
- } catch (Exception $e) {
- $driver = new Kronolith_Driver($params, sprintf(_("The Calendar backend is not currently available: %s"), $e->getMessage()));
- }
- } else {
- $driver = new Kronolith_Driver($params, sprintf(_("Unable to load the definition of %s."), $class));
- }
- $this->_instances[$key] = $driver;
-
- return $driver;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Horde_Injector based factory for Kronolith_Geo drivers
- *
- * @author Michael J Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_Injector_Factory_Geo
-{
- /**
- * Instances.
- *
- * @var array
- */
- private $_instances = array();
-
- /**
- * Return the driver instance.
- *
- * @return Kronolith_Storage
- * @throws Kronolith_Exception
- */
- public function create(Horde_Injector $injector)
- {
- if (empty($this->_instances[$GLOBALS['conf']['maps']['geodriver']])) {
- if (!empty($GLOBALS['conf']['maps']['geodriver'])) {
- $class = 'Kronolith_Geo_' . $GLOBALS['conf']['maps']['geodriver'];
- $db = $injector->getInstance('Horde_Db_Adapter');
- $this->_instances[$GLOBALS['conf']['maps']['geodriver']] = new $class($db);
- } else {
- throw new Kronolith_Exception(_("Geospatial support not configured."));
- }
- }
-
- return $this->_instances[$GLOBALS['conf']['maps']['geodriver']];
- }
-
-}
\ No newline at end of file
+++ /dev/null
-<?php
-
-class Kronolith_Injector_Factory_Storage
-{
- /**
- * 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 driver instance.
- *
- * @return Kronolith_Storage
- * @throws Kronolith_Exception
- */
- public function create($params = array())
- {
- if (empty($params['user'])) {
- $user = $GLOBALS['registry']->getAuth();
- } else {
- $user = $params['user'];
- unset($params['user']);
- }
-
- if (empty($params['driver'])) {
- $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
- } else {
- $driver = $params['driver'];
- unset($params['driver']);
- }
- $driver = basename($driver);
- $class = 'Kronolith_Storage_' . $driver;
-
- $driver_params = Horde::getDriverConfig('storage', 'Sql');
- if ($driver == 'Sql') {
- if ($driver_params != 'Horde') {
- // Custom DB config
- $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('kronolith', Horde::getDriverConfig('storage', 'Sql'));
- } else {
- // Horde default DB config
- $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter');
- }
- $params['table'] = $driver_params['table'];
- }
-
- if (class_exists($class)) {
- $driver = new $class($user, $params);
- } else {
- throw new Kronolith_Exception(sprintf(_("Unable to load the definition of %s."), $class));
- }
-
- try {
- $driver->initialize();
- } catch (Exception $e) {
- $driver = new Kronolith_Storage($params);
- }
-
- return $driver;
- }
-
-}
\ No newline at end of file
break;
}
- self::$_instances[$driver] = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Driver')->create($driver, $params);
+ self::$_instances[$driver] = $GLOBALS['injector']->getInstance('Kronolith_Factory_Driver')->create($driver, $params);
}
if (!is_null($calendar)) {
/* A source has been selected, connect and set up the fields. */
if ($source) {
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$driver = null;
/* Set the contact from the key requested. */
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
Horde::url($prefs->getValue('initial_page'), true)->redirect();
foreach ($sources as $source => $objectkeys) {
/* Create a Turba storage instance. */
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$error = true;
case Horde_Data::IMPORT_FILE:
$dest = Horde_Util::getFormData('dest');
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$error = true;
/* Create a Turba storage instance. */
$dest = $session->get('horde', 'import_data/target');
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$driver = null;
$source = Horde_Util::getFormData('source');
$key = Horde_Util::getFormData('key');
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
if ($conf['documents']['type'] != 'none') {
try {
Horde::url($prefs->getValue('initial_page'), true)->redirect();
}
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
try {
$contact = $driver->getObject(Horde_Util::getPost('key'));
$url->redirect();
}
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
/* Set the contact from the requested key. */
try {
@list($source, $key) = explode('.', $id, 2);
if (isset($GLOBALS['cfgSources'][$source]) && $key) {
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$object = $driver->getObject($key)->getValue('name');
} catch (Turba_Exception $e) {}
}
}
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($params['source']);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($params['source']);
if ($driver->checkDefaultShare($share, $cfgSources[$params['source']])) {
return $uid;
}
}
// Load the Turba driver.
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
$contacts = $driver->search(array());
}
// Load the Turba driver.
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
$contact = $driver->getObject($parts[2]);
}
// Load the Turba driver.
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
return $driver->delete($parts[2]);
}
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}
- $storage = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $storage = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
try {
$results = $storage->search(array());
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$histories = $history->getByTimestamp(
'>', $timestamp, $filter,
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$ts = $history->getActionTimestamp('turba:' . $driver->getName()
. ':' . $uid,
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $import_source));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($import_source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
throw new Turba_Exception(_("Permission denied"));
throw new Turba_Exception(_("Invalid ID"));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::READ)) {
continue;
public function ownVCard()
{
$contact = $this->getOwnContactObject();
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($contact['source']);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($contact['source']);
$vcard = $driver->tovCard($contact['contact'], '3.0', null, true);
$vcard->setAttribute('VERSION', '3.0');
throw new Turba_Exception(_("The address book with your own contact doesn't exist anymore."));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::READ)) {
throw new Turba_Exception(_("You don't have sufficient permissions to read the address book that contains your own contact."));
throw new Turba_Exception(_("Invalid ID"));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$GLOBALS['registry']->isAdmin() &&
!$driver->hasPermission(Horde_Perms::DELETE)) {
}
// Check permissions.
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
continue;
}
continue;
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
// Determine the name of the column to sort by.
$columns = isset($sort_columns[$source])
}
if (isset($cfgSources[$source])) {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$object = $driver->getObject($objectId);
}
if (isset($cfgSources[$source])) {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$objects = $driver->getObjects($objectIds);
$results = array();
foreach ($sources as $source) {
if (isset($cfgSources[$source])) {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$res = $driver->search(array());
if (!($res instanceof Turba_List)) {
$objects = array();
foreach ($time_categories as $category) {
list($category, $source) = explode('/', $category, 2);
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$objects = array_merge($objects, $driver->listTimeObjects($start, $end, $category));
}
throw new Turba_Exception(_("Invalid entry"));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
throw new Turba_Exception(_("Permission denied"));
continue;
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$criterium = array('email' => $address);
if (!isset($driver->map['email'])) {
if (isset($driver->map['emails'])) {
foreach ($sources as $source) {
if (isset($cfgSources[$source])) {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
continue;
}
if (empty($source['use_shares'])) {
// Shares not enabled for this source
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
Horde::logMessage($e, 'ERR');
throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
if (!empty($params['default'])) {
$config = Turba::getSourceFromShare($share);
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($config);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($config);
} catch (Turba_Exception $e) {
continue;
}
{
parent::__construct($name, $params);
$this->_share = $this->_params['config']['params']['share'];
- $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['config']);
+ $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['config']);
}
/**
$this->_share = $this->_params['share'];
/* Load the underlying driver. */
- $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['source']);
+ $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['source']);
$this->searchCriteria = empty($this->_params['criteria'])
? array()
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based Turba_Driver:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.horde.org/licenses/apl.html APL
+ * @link http://pear.horde.org/index.php?package=Turba
+ * @package Turba
+ */
+
+/**
+ * A Horde_Injector:: based Turba_Driver:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (APL). If you
+ * did not receive this file, see http://www.horde.org/licenses/apl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.horde.org/licenses/apl.html APL
+ * @link http://pear.horde.org/index.php?package=Turba
+ * @package Turba
+ */
+class Turba_Factory_Driver
+{
+ /**
+ * 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 Turba_Driver:: instance.
+ *
+ * @param mixed $name Either a string containing the internal name of this
+ * source, or a config array describing the source.
+ *
+ * @return Turba_Driver The singleton instance.
+ * @throws Turba_Exception
+ */
+ public function create($name)
+ {
+ if (is_array($name)) {
+ $key = md5(serialize($name));
+ $srcName = '';
+ $srcConfig = $name;
+ } else {
+ $key = $name;
+ $srcName = $name;
+ if (empty($GLOBALS['cfgSources'][$name])) {
+ throw new Turba_Exception(sprintf(_("The address book \"%s\" does not exist."), $name));
+ }
+ $srcConfig = $GLOBALS['cfgSources'][$name];
+ }
+
+ if (!isset($this->_instances[$key])) {
+ $class = 'Turba_Driver_' . ucfirst(basename($srcConfig['type']));
+ if (!class_exists($class)) {
+ throw new Turba_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+ }
+
+ if (empty($srcConfig['params'])) {
+ $srcConfig['params'] = array();
+ }
+
+ switch ($class) {
+ case 'Turba_Driver_Sql':
+ try {
+ $srcConfig['params']['db'] = empty($srcConfig['params']['sql'])
+ ? $GLOBALS['injector']->getInstance('Horde_Db_Adapter')
+ : $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('turba', $this->_params['sql']);
+ } catch (Horde_Db_Exception $e) {
+ throw new Turba_Exception($e);
+ }
+ break;
+ }
+
+ $driver = new $class($srcName, $srcConfig['params']);
+
+ // Title
+ $driver->title = $srcConfig['title'];
+
+ /* Initialize */
+ //$driver->_init();
+
+ /* Store and translate the map at the Source level. */
+ $driver->map = $srcConfig['map'];
+ foreach ($driver->map as $key => $val) {
+ if (!is_array($val)) {
+ $driver->fields[$key] = $val;
+ }
+ }
+
+ /* Store tabs. */
+ if (isset($srcConfig['tabs'])) {
+ $driver->tabs = $srcConfig['tabs'];
+ }
+
+ /* Store remaining fields. */
+ if (isset($srcConfig['strict'])) {
+ $driver->strict = $srcConfig['strict'];
+ }
+ if (isset($srcConfig['approximate'])) {
+ $driver->approximate = $srcConfig['approximate'];
+ }
+ if (isset($srcConfig['list_name_field'])) {
+ $driver->listNameField = $srcConfig['list_name_field'];
+ }
+ if (isset($srcConfig['alternative_name'])) {
+ $driver->alternativeName = $srcConfig['alternative_name'];
+ }
+ $this->_instances[$key] = $driver;
+ }
+
+ return $this->_instances[$key];
+ }
+
+}
// Need a clean cfgSources array
include TURBA_BASE . '/config/backends.php';
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);
$params = array(
'params' => array('source' => $GLOBALS['conf']['shares']['source']),
throw new Turba_Exception(_("You do not have permissions to delete this address book."));
}
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_addressbook->getName());
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_addressbook->getName());
// We have a Turba_Driver, try to delete the address book.
$driver->deleteAll();
+++ /dev/null
-<?php
-/**
- * A Horde_Injector:: based Turba_Driver:: factory.
- *
- * PHP version 5
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.horde.org/licenses/apl.html APL
- * @link http://pear.horde.org/index.php?package=Turba
- * @package Turba
- */
-
-/**
- * A Horde_Injector:: based Turba_Driver:: factory.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (APL). If you
- * did not receive this file, see http://www.horde.org/licenses/apl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.horde.org/licenses/apl.html APL
- * @link http://pear.horde.org/index.php?package=Turba
- * @package Turba
- */
-class Turba_Injector_Factory_Driver
-{
- /**
- * 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 Turba_Driver:: instance.
- *
- * @param mixed $name Either a string containing the internal name of this
- * source, or a config array describing the source.
- *
- * @return Turba_Driver The singleton instance.
- * @throws Turba_Exception
- */
- public function create($name)
- {
- if (is_array($name)) {
- $key = md5(serialize($name));
- $srcName = '';
- $srcConfig = $name;
- } else {
- $key = $name;
- $srcName = $name;
- if (empty($GLOBALS['cfgSources'][$name])) {
- throw new Turba_Exception(sprintf(_("The address book \"%s\" does not exist."), $name));
- }
- $srcConfig = $GLOBALS['cfgSources'][$name];
- }
-
- if (!isset($this->_instances[$key])) {
- $class = 'Turba_Driver_' . ucfirst(basename($srcConfig['type']));
- if (!class_exists($class)) {
- throw new Turba_Exception(sprintf(_("Unable to load the definition of %s."), $class));
- }
-
- if (empty($srcConfig['params'])) {
- $srcConfig['params'] = array();
- }
-
- switch ($class) {
- case 'Turba_Driver_Sql':
- try {
- $srcConfig['params']['db'] = empty($srcConfig['params']['sql'])
- ? $GLOBALS['injector']->getInstance('Horde_Db_Adapter')
- : $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('turba', $this->_params['sql']);
- } catch (Horde_Db_Exception $e) {
- throw new Turba_Exception($e);
- }
- break;
- }
-
- $driver = new $class($srcName, $srcConfig['params']);
-
- // Title
- $driver->title = $srcConfig['title'];
-
- /* Initialize */
- //$driver->_init();
-
- /* Store and translate the map at the Source level. */
- $driver->map = $srcConfig['map'];
- foreach ($driver->map as $key => $val) {
- if (!is_array($val)) {
- $driver->fields[$key] = $val;
- }
- }
-
- /* Store tabs. */
- if (isset($srcConfig['tabs'])) {
- $driver->tabs = $srcConfig['tabs'];
- }
-
- /* Store remaining fields. */
- if (isset($srcConfig['strict'])) {
- $driver->strict = $srcConfig['strict'];
- }
- if (isset($srcConfig['approximate'])) {
- $driver->approximate = $srcConfig['approximate'];
- }
- if (isset($srcConfig['list_name_field'])) {
- $driver->listNameField = $srcConfig['list_name_field'];
- }
- if (isset($srcConfig['alternative_name'])) {
- $driver->alternativeName = $srcConfig['alternative_name'];
- }
- $this->_instances[$key] = $driver;
- }
-
- return $this->_instances[$key];
- }
-
-}
foreach ($ids as $value) {
list($source, $key) = explode(':', $value);
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$this->insert($driver->getObject($key));
} catch (Turba_Exception $e) {}
}
$sources = array_keys($GLOBALS['cfgSources']);
foreach ($sources as $sourcekey) {
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourcekey);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourcekey);
$lists = $driver->search($criteria);
} catch (Turba_Exception $e) {
return false;
if ($sourceId == $this->getSource()) {
$contact = $this->driver->getObject($contactId);
} else {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
$contact = $driver->getObject($contactId);
}
}
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
} catch (Turba_Exception $e) {
continue;
}
foreach ($in as $sourceId => $source) {
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
} catch (Turba_Exception $e) {
Horde::logMessage($e, 'ERR');
continue;
if ($GLOBALS['registry']->getAuth() && !$personal) {
// User's default share is missing.
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$GLOBALS['notification']->push($driver, 'horde.error');
continue;
} else {
try {
$driver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
try {
$targetDriver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($targetSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
// Try and load the driver for the source.
try {
$sourceDriver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($objectSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
try {
$targetDriver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($targetSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$targetSource = $vars->get('targetAddressbook');
try {
$targetDriver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($targetSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
global $prefs, $session, $default_source, $copymove_source_options;
$driver = $GLOBALS['injector']
- ->getInstance('Turba_Injector_Factory_Driver')
+ ->getInstance('Turba_Factory_Driver')
->create($default_source);
$hasDelete = $driver->hasPermission(Horde_Perms::DELETE);
$hasEdit = $driver->hasPermission(Horde_Perms::EDIT);
'name' => ' ' . htmlspecialchars($srcConfig['title']),
'source' => htmlspecialchars($src));
- $srcDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($src);
+ $srcDriver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($src);
try {
$listList = $srcDriver->search(
array('__type' => 'Group'),
$this->_kolab->_storage->save($object);
// Check that the driver can be created
- $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+ $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$result = $turba->search(array(), array('last-name'));
$this->assertNoError($result);
$this->assertEquals(2, count($result));
- $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('INBOX%2Ftest2');
+ $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('INBOX%2Ftest2');
$result = $turba->search(array(), array('last-name'));
$this->assertEquals(0, count($result));
);
// Save the contact
- $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+ $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$this->assertNoError($turba->_add($object));
);
// Save the contact
- $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+ $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$this->assertNoError($turba->_add($object));
$source = Horde_Util::getFormData('source');
$key = Horde_Util::getFormData('key');
$mergeInto = Horde_Util::getFormData('merge_into');
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
if ($url = Horde_Util::getFormData('url')) {
$url = new Horde_Url($url, true);
// Do the search if we have one.
if (!is_null($search)) {
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
$criteria['name'] = trim($search);
$res = $driver->search($criteria);
// Initiate driver
try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($import_source);
} catch (Turba_Exception $e) {
PEAR::raiseError(sprintf(_("Connection failed: %s"), $e->getMessage()), 'horde.error', null, null, $import_source);
continue;
// Initiate driver
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($import_source);
} catch (Turba_Exception $e) {
$cli->message(' ' . sprintf(_("Connection failed: %s"), $e->getMessage()), 'cli.error');
continue;
$CLI->message('Created new Horde_Share object for the shared address book.', 'cli.success');
// Share created, now get a Turba_Driver and make the changes.
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($sourceKey);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($sourceKey);
$db = &$driver->_db;
$action = Horde_Util::getFormData('actionID');
try {
- $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+ $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$driver = null;
Horde::url($prefs->getValue('initial_page'), true)->redirect();
}
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
/* Set the contact from the key requested. */
try {
throw new Turba_Exception(_("The contact you requested does not exist."));
}
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
$object = $driver->getObject($key);
/* Check permissions. */