From 439e8bfa97385983f8ef1e4cdaf358dc8fb4b647 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Thu, 13 Jan 2011 01:20:52 -0500 Subject: [PATCH] No need for this binder, call the factory directly. Standardize on using create() as the factory method. --- add.php | 2 +- contact.php | 2 +- data.php | 6 ++-- delete.php | 2 +- deletefile.php | 2 +- edit.php | 2 +- lib/Api.php | 42 +++++++++++----------- lib/Application.php | 13 ++----- lib/Driver/Vbook.php | 2 +- lib/Form/CreateAddressBook.php | 2 +- lib/Form/DeleteAddressBook.php | 2 +- lib/Injector/Binder/Driver.php | 31 ---------------- lib/Injector/Factory/Driver.php | 2 +- lib/List.php | 2 +- lib/LoginTasks/SystemTask/UpgradeLists.php | 2 +- lib/Object/Group.php | 4 +-- lib/Turba.php | 4 +-- lib/View/Browse.php | 10 +++--- lib/View/List.php | 4 +-- lib/tests/KolabTest.php | 8 ++--- merge.php | 2 +- minisearch.php | 2 +- scripts/import_squirrelmail_file_abook.php | 2 +- scripts/import_squirrelmail_sql_abook.php | 2 +- scripts/upgrades/public_to_horde_share.php | 2 +- search.php | 2 +- vcard.php | 2 +- view.php | 2 +- 28 files changed, 60 insertions(+), 100 deletions(-) delete mode 100644 lib/Injector/Binder/Driver.php diff --git a/add.php b/add.php index ee426292..734200e6 100644 --- a/add.php +++ b/add.php @@ -34,7 +34,7 @@ /* A source has been selected, connect and set up the fields. */ if ($source) { try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); $driver = null; diff --git a/contact.php b/contact.php index 68102fb4..56c747af 100644 --- a/contact.php +++ b/contact.php @@ -22,7 +22,7 @@ /* Set the contact from the key requested. */ try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); Horde::url($prefs->getValue('initial_page'), true)->redirect(); diff --git a/data.php b/data.php index 7810402d..e635a303 100644 --- a/data.php +++ b/data.php @@ -242,7 +242,7 @@ function _getBareEmail($address, $allow_multi = false) foreach ($sources as $source => $objectkeys) { /* Create a Turba storage instance. */ try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); $error = true; @@ -335,7 +335,7 @@ function _getBareEmail($address, $allow_multi = false) case Horde_Data::IMPORT_FILE: $dest = Horde_Util::getFormData('dest'); try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($dest); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); $error = true; @@ -423,7 +423,7 @@ function _getBareEmail($address, $allow_multi = false) /* Create a Turba storage instance. */ $dest = $session->get('horde', 'import_data/target'); try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($dest); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); $driver = null; diff --git a/delete.php b/delete.php index 9de84c86..8f37d864 100644 --- a/delete.php +++ b/delete.php @@ -18,7 +18,7 @@ $source = Horde_Util::getFormData('source'); $key = Horde_Util::getFormData('key'); -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); if ($conf['documents']['type'] != 'none') { try { diff --git a/deletefile.php b/deletefile.php index a67f296d..778499ee 100644 --- a/deletefile.php +++ b/deletefile.php @@ -23,7 +23,7 @@ Horde::url($prefs->getValue('initial_page'), true)->redirect(); } -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); try { $contact = $driver->getObject(Horde_Util::getPost('key')); diff --git a/edit.php b/edit.php index de49e45b..b60ccfb2 100644 --- a/edit.php +++ b/edit.php @@ -45,7 +45,7 @@ $url->redirect(); } -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); /* Set the contact from the requested key. */ try { diff --git a/lib/Api.php b/lib/Api.php index 461bc91f..2ed619e5 100644 --- a/lib/Api.php +++ b/lib/Api.php @@ -51,7 +51,7 @@ public function commentCallback($id) @list($source, $key) = explode('.', $id, 2); if (isset($GLOBALS['cfgSources'][$source]) && $key) { try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $object = $driver->getObject($key)->getValue('name'); } catch (Turba_Exception $e) {} } @@ -322,7 +322,7 @@ public function browse($path = '', $properties = array()) } // Load the Turba driver. - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($parts[1]); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]); $contacts = $driver->search(array()); @@ -371,7 +371,7 @@ public function browse($path = '', $properties = array()) } // Load the Turba driver. - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($parts[1]); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]); $contact = $driver->getObject($parts[2]); @@ -418,7 +418,7 @@ public function path_delete($path) } // Load the Turba driver. - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($parts[1]); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]); return $driver->delete($parts[2]); } @@ -458,7 +458,7 @@ public function listUids($sources = null) throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source)); } - $storage = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $storage = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); try { $results = $storage->search(array()); @@ -518,7 +518,7 @@ public function listBy($action, $timestamp, $sources = null, $end = null) throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source)); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $histories = $history->getByTimestamp( '>', $timestamp, $filter, @@ -589,7 +589,7 @@ public function getActionTimestamp($uid, $action, $sources = null) throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source)); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $ts = $history->getActionTimestamp('turba:' . $driver->getName() . ':' . $uid, @@ -635,7 +635,7 @@ public function import($content, $contentType = 'array', throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $import_source)); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($import_source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source); if (!$driver->hasPermission(Horde_Perms::EDIT)) { throw new Turba_Exception(_("Permission denied")); @@ -763,7 +763,7 @@ public function export($uid, $contentType, $sources = null, $fields = null) throw new Turba_Exception(_("Invalid ID")); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); if (!$driver->hasPermission(Horde_Perms::READ)) { continue; @@ -827,7 +827,7 @@ public function export($uid, $contentType, $sources = null, $fields = null) public function ownVCard() { $contact = $this->getOwnContactObject(); - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($contact['source']); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($contact['source']); $vcard = $driver->tovCard($contact['contact'], '3.0', null, true); $vcard->setAttribute('VERSION', '3.0'); @@ -868,7 +868,7 @@ public function getOwnContactObject() throw new Turba_Exception(_("The address book with your own contact doesn't exist anymore.")); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_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.")); @@ -933,7 +933,7 @@ public function delete($uid, $sources = null) throw new Turba_Exception(_("Invalid ID")); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); if (!$GLOBALS['registry']->isAdmin() && !$driver->hasPermission(Horde_Perms::DELETE)) { @@ -996,7 +996,7 @@ public function replace($uid, $content, $contentType, $sources = null) } // Check permissions. - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); if (!$driver->hasPermission(Horde_Perms::EDIT)) { continue; } @@ -1121,7 +1121,7 @@ public function search($names = array(), $sources = array(), continue; } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); // Determine the name of the column to sort by. $columns = isset($sort_columns[$source]) @@ -1274,7 +1274,7 @@ public function getContact($source = null, $objectId = '') } if (isset($cfgSources[$source])) { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $object = $driver->getObject($objectId); @@ -1310,7 +1310,7 @@ public function getContacts($source = '', $objectIds = array()) } if (isset($cfgSources[$source])) { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $objects = $driver->getObjects($objectIds); @@ -1351,7 +1351,7 @@ public function getAllAttributeValues($field = '', $sources = array()) $results = array(); foreach ($sources as $source) { if (isset($cfgSources[$source])) { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $res = $driver->search(array()); if (!($res instanceof Turba_List)) { @@ -1419,7 +1419,7 @@ public function listTimeObjects($time_categories, $start, $end) $objects = array(); foreach ($time_categories as $category) { list($category, $source) = explode('/', $category, 2); - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $objects = array_merge($objects, $driver->listTimeObjects($start, $end, $category)); } @@ -1563,7 +1563,7 @@ public function addField($address = '', $name = '', $field = '', throw new Turba_Exception(_("Invalid entry")); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); if (!$driver->hasPermission(Horde_Perms::EDIT)) { throw new Turba_Exception(_("Permission denied")); @@ -1654,7 +1654,7 @@ public function getField($address = '', $field = '', $sources = array(), continue; } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $criterium = array('email' => $address); if (!isset($driver->map['email'])) { if (isset($driver->map['emails'])) { @@ -1719,7 +1719,7 @@ public function deleteField($address = '', $field = '', $sources = array()) foreach ($sources as $source) { if (isset($cfgSources[$source])) { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); if (!$driver->hasPermission(Horde_Perms::EDIT)) { continue; } diff --git a/lib/Application.php b/lib/Application.php index 39dda948..5d831b24 100644 --- a/lib/Application.php +++ b/lib/Application.php @@ -59,15 +59,6 @@ class Turba_Application extends Horde_Registry_Application */ protected function _init() { - /* Add Turba-specific binders. */ - $binders = array( - 'Turba_Driver' => new Turba_Injector_Binder_Driver() - ); - - foreach ($binders as $key => $val) { - $GLOBALS['injector']->addBinder($key, $val); - } - // Turba source and attribute configuration. $attributes = Horde::loadConfiguration('attributes.php', 'attributes', 'turba'); include TURBA_BASE . '/config/backends.php'; @@ -399,7 +390,7 @@ public function removeUserData($user) if (empty($source['use_shares'])) { // Shares not enabled for this source try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_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)); @@ -432,7 +423,7 @@ public function removeUserData($user) if (!empty($params['default'])) { $config = Turba::getSourceFromShare($share); try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($config); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($config); } catch (Turba_Exception $e) { continue; } diff --git a/lib/Driver/Vbook.php b/lib/Driver/Vbook.php index 5b679a29..4e7e7401 100644 --- a/lib/Driver/Vbook.php +++ b/lib/Driver/Vbook.php @@ -48,7 +48,7 @@ protected function _init() $this->_share = $this->_params['share']; /* Load the underlying driver. */ - $this->_driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($this->_params['source']); + $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['source']); $this->searchCriteria = empty($this->_params['criteria']) ? array() diff --git a/lib/Form/CreateAddressBook.php b/lib/Form/CreateAddressBook.php index a64568ee..6c39f22a 100644 --- a/lib/Form/CreateAddressBook.php +++ b/lib/Form/CreateAddressBook.php @@ -35,7 +35,7 @@ function execute() // Need a clean cfgSources array include TURBA_BASE . '/config/backends.php'; - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($cfgSources[$GLOBALS['conf']['shares']['source']]); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]); $params = array( 'params' => array('source' => $GLOBALS['conf']['shares']['source']), diff --git a/lib/Form/DeleteAddressBook.php b/lib/Form/DeleteAddressBook.php index bb691344..0b09708b 100644 --- a/lib/Form/DeleteAddressBook.php +++ b/lib/Form/DeleteAddressBook.php @@ -50,7 +50,7 @@ function execute() throw new Turba_Exception(_("You do not have permissions to delete this address book.")); } - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($this->_addressbook->getName()); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_addressbook->getName()); // We have a Turba_Driver, try to delete the address book. $driver->deleteAll(); diff --git a/lib/Injector/Binder/Driver.php b/lib/Injector/Binder/Driver.php deleted file mode 100644 index 51e1f3f2..00000000 --- a/lib/Injector/Binder/Driver.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @category Horde - * @license http://www.horde.org/licenses/asl.html ASL - * @package Turba - */ -class Turba_Injector_Binder_Driver implements Horde_Injector_Binder -{ - /** - */ - public function create(Horde_Injector $injector) - { - return new Turba_Injector_Factory_Driver($injector); - } - - /** - */ - public function equals(Horde_Injector_Binder $binder) - { - return false; - } - -} diff --git a/lib/Injector/Factory/Driver.php b/lib/Injector/Factory/Driver.php index 43dcf66e..658e8b25 100644 --- a/lib/Injector/Factory/Driver.php +++ b/lib/Injector/Factory/Driver.php @@ -60,7 +60,7 @@ public function __construct(Horde_Injector $injector) * @return Turba_Driver The singleton instance. * @throws Turba_Exception */ - public function getDriver($name) + public function create($name) { if (is_array($name)) { $key = md5(serialize($name)); diff --git a/lib/List.php b/lib/List.php index 39e35bcb..a8c231ca 100644 --- a/lib/List.php +++ b/lib/List.php @@ -38,7 +38,7 @@ public function __construct($ids = array()) foreach ($ids as $value) { list($source, $key) = explode(':', $value); try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); $this->insert($driver->getObject($key)); } catch (Turba_Exception $e) {} } diff --git a/lib/LoginTasks/SystemTask/UpgradeLists.php b/lib/LoginTasks/SystemTask/UpgradeLists.php index bba646d0..6c4adeb0 100644 --- a/lib/LoginTasks/SystemTask/UpgradeLists.php +++ b/lib/LoginTasks/SystemTask/UpgradeLists.php @@ -40,7 +40,7 @@ public function execute() $sources = array_keys($GLOBALS['cfgSources']); foreach ($sources as $sourcekey) { try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($sourcekey); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourcekey); $lists = $driver->search($criteria); } catch (Turba_Exception $e) { return false; diff --git a/lib/Object/Group.php b/lib/Object/Group.php index b627317a..156670ba 100644 --- a/lib/Object/Group.php +++ b/lib/Object/Group.php @@ -67,7 +67,7 @@ function addMember($contactId, $sourceId = null) if ($sourceId == $this->getSource()) { $contact = $this->driver->getObject($contactId); } else { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($sourceId); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId); $contact = $driver->getObject($contactId); } @@ -170,7 +170,7 @@ function &listMembers($sort = null) } try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($sourceId); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId); } catch (Turba_Exception $e) { continue; } diff --git a/lib/Turba.php b/lib/Turba.php index 38b9ca90..5ad3b50c 100644 --- a/lib/Turba.php +++ b/lib/Turba.php @@ -353,7 +353,7 @@ function permissionsFilter($in, $permission = Horde_Perms::READ, $options = arra foreach ($in as $sourceId => $source) { try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($sourceId); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId); } catch (Turba_Exception $e) { Horde::logMessage($e, 'ERR'); continue; @@ -440,7 +440,7 @@ function getConfigFromShares($sources) if ($GLOBALS['registry']->getAuth() && !$personal) { // User's default share is missing. try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $GLOBALS['notification']->push($driver, 'horde.error'); continue; diff --git a/lib/View/Browse.php b/lib/View/Browse.php index b265e892..7aaea161 100644 --- a/lib/View/Browse.php +++ b/lib/View/Browse.php @@ -69,7 +69,7 @@ function run() $notification->push(_("There are no browseable address books."), 'horde.warning'); } else { try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); unset($driver); @@ -141,7 +141,7 @@ function run() $targetSource = $vars->get('targetAddressbook'); try { - $targetDriver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($targetSource); + $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); break; @@ -170,7 +170,7 @@ function run() // Try and load the driver for the source. try { - $sourceDriver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($objectSource); + $sourceDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($objectSource); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); continue; @@ -256,7 +256,7 @@ function run() } try { - $targetDriver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($targetSource); + $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); break; @@ -271,7 +271,7 @@ function run() } else { $targetSource = $vars->get('targetAddressbook'); try { - $targetDriver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($targetSource); + $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); break; diff --git a/lib/View/List.php b/lib/View/List.php index 75fc1b47..5e141d77 100644 --- a/lib/View/List.php +++ b/lib/View/List.php @@ -145,7 +145,7 @@ function display() { global $prefs, $session, $default_source, $copymove_source_options; - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($default_source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($default_source); $hasDelete = $driver->hasPermission(Horde_Perms::DELETE); $hasEdit = $driver->hasPermission(Horde_Perms::EDIT); @@ -394,7 +394,7 @@ function getAddSources() 'name' => '  ' . htmlspecialchars($srcConfig['title']), 'source' => htmlspecialchars($src)); - $srcDriver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($src); + $srcDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($src); try { $listList = $srcDriver->search( array('__type' => 'Group'), diff --git a/lib/tests/KolabTest.php b/lib/tests/KolabTest.php index 0635f484..38188c3f 100644 --- a/lib/tests/KolabTest.php +++ b/lib/tests/KolabTest.php @@ -47,14 +47,14 @@ function testBug5476() $this->_kolab->_storage->save($object); // Check that the driver can be created - $turba = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver('wrobel@example.org'); + $turba = $GLOBALS['injector']->getInstance('Turba_Injector_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_Driver')->getDriver('INBOX%2Ftest2'); + $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('INBOX%2Ftest2'); $result = $turba->search(array(), array('last-name')); $this->assertEquals(0, count($result)); @@ -75,7 +75,7 @@ function testPhoto() ); // Save the contact - $turba = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver('wrobel@example.org'); + $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org'); //$this->assertNoError($turba); $this->assertNoError($turba->_add($object)); @@ -102,7 +102,7 @@ function testAttachments() ); // Save the contact - $turba = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver('wrobel@example.org'); + $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org'); //$this->assertNoError($turba); $this->assertNoError($turba->_add($object)); diff --git a/merge.php b/merge.php index a2be0b7a..b288a176 100644 --- a/merge.php +++ b/merge.php @@ -16,7 +16,7 @@ $source = Horde_Util::getFormData('source'); $key = Horde_Util::getFormData('key'); $mergeInto = Horde_Util::getFormData('merge_into'); -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); if ($url = Horde_Util::getFormData('url')) { $url = new Horde_Url($url, true); diff --git a/minisearch.php b/minisearch.php index f179f769..66a7e210 100644 --- a/minisearch.php +++ b/minisearch.php @@ -22,7 +22,7 @@ // Do the search if we have one. if (!is_null($search)) { try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); $criteria['name'] = trim($search); $res = $driver->search($criteria); diff --git a/scripts/import_squirrelmail_file_abook.php b/scripts/import_squirrelmail_file_abook.php index b2cbaedf..344dc6c0 100755 --- a/scripts/import_squirrelmail_file_abook.php +++ b/scripts/import_squirrelmail_file_abook.php @@ -83,7 +83,7 @@ // Initiate driver try { - $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($import_source); + $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source); } catch (Turba_Exception $e) { PEAR::raiseError(sprintf(_("Connection failed: %s"), $e->getMessage()), 'horde.error', null, null, $import_source); continue; diff --git a/scripts/import_squirrelmail_sql_abook.php b/scripts/import_squirrelmail_sql_abook.php index a838676a..3aa47f02 100755 --- a/scripts/import_squirrelmail_sql_abook.php +++ b/scripts/import_squirrelmail_sql_abook.php @@ -92,7 +92,7 @@ // Initiate driver try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($import_source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($import_source); } catch (Turba_Exception $e) { $cli->message(' ' . sprintf(_("Connection failed: %s"), $e->getMessage()), 'cli.error'); continue; diff --git a/scripts/upgrades/public_to_horde_share.php b/scripts/upgrades/public_to_horde_share.php index 0243bce0..eb518bbf 100755 --- a/scripts/upgrades/public_to_horde_share.php +++ b/scripts/upgrades/public_to_horde_share.php @@ -68,7 +68,7 @@ $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_Driver')->getDriver($sourceKey); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($sourceKey); $db = &$driver->_db; diff --git a/search.php b/search.php index be56e215..8238fdbe 100644 --- a/search.php +++ b/search.php @@ -85,7 +85,7 @@ function updateSortOrderFromVars() $action = Horde_Util::getFormData('actionID'); try { - $driver = $injector->getInstance('Turba_Driver')->getDriver($source); + $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); } catch (Turba_Exception $e) { $notification->push($e, 'horde.error'); $driver = null; diff --git a/vcard.php b/vcard.php index d3fbae50..eaa6c153 100644 --- a/vcard.php +++ b/vcard.php @@ -19,7 +19,7 @@ Horde::url($prefs->getValue('initial_page'), true)->redirect(); } -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); /* Set the contact from the key requested. */ try { diff --git a/view.php b/view.php index b4db0259..377640af 100644 --- a/view.php +++ b/view.php @@ -28,7 +28,7 @@ throw new Turba_Exception(_("The contact you requested does not exist.")); } -$driver = $injector->getInstance('Turba_Driver')->getDriver($source); +$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source); $object = $driver->getObject($key); /* Check permissions. */