Returns the source entries from config/backends.php that have been
configured as available sources in the main Turba configuration.
public static availableSources ( ) : array | ||
Результат | array | List of available sources. |
/** * @return Horde_Share The new share object. * @throws Turba_Exception */ public function execute() { // Need a clean cfgSources array $cfgSources = Turba::availableSources(); $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]); $params = array('params' => array('source' => $GLOBALS['conf']['shares']['source']), 'name' => $this->_vars->get('name'), 'desc' => $this->_vars->get('description')); return $driver->createShare(strval(new Horde_Support_Randomid()), $params); }
/** * Obtain an array of $cfgSource entries matching the filter criteria. * * @param type $filter A single key -> value hash to filter the sources. * * @return array */ public function getSourcesConfig($filter = array()) { $results = array(); if (!empty($filter)) { foreach (Turba::availableSources() as $key => $source) { $curr = current(array_keys($filter)); if (!empty($source[$curr]) && $source[$curr] == current($filter)) { $results[$key] = $source; } } } return $results; }
/** */ public function removeUserData($user) { /* We need a clean copy of the $cfgSources array here.*/ $cfgSources = Turba::availableSources(); foreach ($cfgSources as $sourceId => $source) { if (empty($source['use_shares'])) { // Shares not enabled for this source try { $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source, $sourceId); } catch (Turba_Exception $e) { Horde::log($e, 'ERR'); } try { $driver->removeUserData($user); } catch (Turba_Exception_NotSupported $e) { continue; } catch (Turba_Exception $e) { Horde::log($e, 'ERR'); throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user)); } } } /* Only attempt share removal if we have shares configured */ if (!$GLOBALS['session']->get('turba', 'has_share')) { return; } $turba_shares = $GLOBALS['injector']->getInstance('Turba_Shares'); $shares = $turba_shares->listShares($user, array('attributes' => $user)); // Look for the deleted user's shares and remove them foreach ($shares as $share) { $config = Turba::getSourceFromShare($share); try { $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($config, $share->getName()); } catch (Turba_Exception $e) { continue; } try { $driver->removeUserData($user); } catch (Turba_Exception_NotSupported $e) { continue; } catch (Turba_Exception $e) { Horde::log($e, 'ERR'); throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user)); } } /* Get a list of all shares this user has perms to and remove the * perms. */ try { $shares = $turba_shares->listShares($user); foreach ($shares as $share) { $share->removeUser($user); } } catch (Horde_Share_Exception $e) { Horde::log($e, 'ERR'); throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user)); } }
/** * Prepare the Turba setup. * * @return NULL */ public function prepareTurba() { $world =& $this->prepareBasicSetup(); $this->assertTrue($world['auth']->authenticate('*****@*****.**', array('password' => 'none'))); $GLOBALS['registry']->pushApp('turba', array('check_perms' => false)); // Turba base libraries. require_once TURBA_BASE . '/lib/Turba.php'; require_once TURBA_BASE . '/lib/Driver.php'; require_once TURBA_BASE . '/lib/Object.php'; // Turba source and attribute configuration. include TURBA_BASE . '/config/attributes.php'; $cfgSources = Turba::availableSources(); unset($cfgSources['kolab_global']); $this->prepareNewFolder($world['storage'], 'Contacts', 'contact', true); $this->prepareNewFolder($world['storage'], 'test2', 'contact'); $GLOBALS['session']->set('turba', 'has_share', true); $GLOBALS['cfgSources'] = Turba::getConfigFromShares($cfgSources); }