/**
*/
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));
}
}