}
try {
- $driver = Turba_Driver::factory($params['source'], $cfgSources[$params['source']]);
+ $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($params['source']);
if ($driver->checkDefaultShare($share, $cfgSources[$params['source']])) {
return $uid;
}
* @param array $params Hash containing additional configuration
* parameters.
*/
- public function __construct($params = array())
+ public function __construct($name = '', $params = array())
{
+ $this->_name = $name;
$this->_params = $params;
}
*/
public function __construct($params)
{
+ parent::__construct($name, $params);
+
$this->params = $params;
$this->_groupField = $params['group_id_field'];
$this->_groupValue = $params['group_id_value'];
$this->_myRights = $params['my_rights'];
$this->_perms = $this->_aclToHordePerms($params['my_rights']);
- }
- /**
- * Initialize the IMSP connection and check for error.
- *
- * @throws Turba_Exception
- */
- protected function _init()
- {
global $conf;
$this->_bookName = $this->getContactOwner();
/**
* Attempts to open a Kolab Groupware folder.
*/
- protected function _init()
+ public function __construct($name = '', $params = array())
{
+ parent::__construct($name, $params);
$this->_kolab = new Kolab();
$wrapper = empty($this->_kolab->version)
? 'Turba_Driver_Kolab_Wrapper_old'
), $params);
parent::__construct($params);
- }
-
- /**
- * @throws Turba_Exception
- */
- protected function _init()
- {
if (!Horde_Util::extensionExists('ldap')) {
throw new Turba_Exception(_("LDAP support is required but the LDAP module is not available or not loaded."));
}
protected $_driver;
/**
+ * Constructor
+ *
+ * @param string $name The source name
+ * @param array $params The parameter array describing the source
+ *
+ * @return Turba_Driver
+ */
+ public function __construct($name = '', $params = array())
+ {
+ parent::__construct($name, $params);
+ $this->_share = $this->_params['config']['params']['share'];
+ $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['config']);
+ }
+
+ /**
* Checks if this backend has a certain capability.
*
* @param string $capability The capability to check for.
}
/**
- * @throws Turba_Exception
- */
- protected function _init()
- {
- $this->_share = &$this->_params['config']['params']['share'];
- $this->_driver = Turba_Driver::factory($this->_name, $this->_params['config']);
- }
-
- /**
* Searches the address book with the given criteria and returns a
* filtered list of results. If the criteria parameter is an empty array,
* all records will be returned.
protected $_db;
/**
- * @throws Turba_Exception
+ *
+ * @param string $name
+ * @param array $params
*/
- protected function _init()
+ public function __construct($name = '', $params = array())
{
- // TODO: Move to injector
+ parent::__construct($name, $params);
+ // TODO: Move to injector
if (empty($this->_params['sql'])) {
try {
$this->_db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
public $searchCriteria;
/**
- * Return the owner to use when searching or creating contacts in
- * this address book.
- *
- * @return string
- */
- protected function _getContactOwner()
- {
- return $this->_driver->getContactOwner();
- }
-
- /**
* @throws Turba_Exception
*/
- protected function _init()
+ public function __construct($name = '', $params = array())
{
+ parent::__construct($name, $params);
+
/* Grab a reference to the share for this vbook. */
$this->_share = $this->_params['share'];
}
/**
+ * Return the owner to use when searching or creating contacts in
+ * this address book.
+ *
+ * @return string
+ */
+ protected function _getContactOwner()
+ {
+ return $this->_driver->getContactOwner();
+ }
+
+ /**
* Return all entries matching the combined searches represented by
* $criteria and the vitural address book's search criteria.
*
}
if (!isset($this->_instances[$key])) {
- $this->_instances[$key] = Turba_Driver::factory($srcName, $srcConfig);
+ $class = 'Turba_Driver_' . ucfirst(basename($srcConfig['type']));
+ if (class_exists($class)) {
+ $driver = new $class($srcName, $srcConfig['params']);
+ } else {
+ throw new Turba_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+ }
+
+ // 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];