*
* @param string $user Name of user to remove data for.
*
- * @throws Horde_Auth_Exception.
+ * @throws Ingo_Exception.
*/
public function removeUserData($user)
{
- if (!$GLOBALS['registry']->isAdmin() &&
- ($user != $GLOBALS['registry']->getAuth())) {
- throw new Horde_Auth_Exception(_("You are not allowed to remove user data."));
- }
-
/* Remove all filters/rules owned by the user. */
try {
$GLOBALS['ingo_storage']->removeUserData($user);
} catch (Ingo_Exception $e) {
Horde::logMessage($e, 'ERR');
- throw new Horde_Auth_Exception($e);
+ throw $e;
}
/* Now remove all shares owned by the user. */
$share = $GLOBALS['ingo_shares']->getShare($user);
$GLOBALS['ingo_shares']->removeShare($share);
} catch (Horde_Share_Exception $e) {
- Horde::logMessage($e->getMessage(), 'ERR');
+ Horde::logMessage($e, 'ERR');
throw new Ingo_Exception($e);
}
foreach ($shares as $share) {
$share->removeUser($user);
}
- } catch (Horde_Shares_Exception $e) {
+ } catch (Horde_Share_Exception $e) {
Horde::logMessage($e, 'ERR');
}
*/
public function removeUserData($user)
{
- if (!$GLOBALS['registry']->isAdmin() &&
- $user != $GLOBALS['registry']->getAuth()) {
- throw new Kronolith_Exception(_("You are not allowed to remove user data."));
- }
-
/* Remove all events owned by the user in all calendars. */
$result = Kronolith::getDriver()->removeUserData($user);
$result = $GLOBALS['kronolith_shares']->removeShare($share);
} catch (Exception $e) {
Horde::logMessage($e, 'ERR');
+ throw $e;
}
/* Get a list of all shares this user has perms to and remove the
}
} catch (Horde_Share_Exception $e) {
Horde::logMessage($e, 'ERR');
+ throw $e;
}
}
* This file defines Mnemo's external API interface. Other applications can
* interact with Mnemo through this API.
*
- * $Horde: mnemo/lib/api.php,v 1.99 2009-11-24 04:13:44 chuck Exp $
- *
* Copyright 2001-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*
- * @since Mnemo 1.0
- * @package Mnemo
+ * @category Horde
+ * @package Mnemo
*/
-class Mnemo_Api extends Horde_Registry_Api {
-
+class Mnemo_Api extends Horde_Registry_Api
+{
/**
* Removes user data.
*
* @param string $user Name of user to remove data for.
*
- * @return mixed true on success | PEAR_Error on failure
+ * @throws Mnemo_Exception
*/
public function removeUserData($user)
{
- if (!$GLOBALS['registry']->isAdmin() && $user != $GLOBALS['registry']->getAuth()) {
- return PEAR::raiseError(_("You are not allowed to remove user data."));
- }
-
- /* Error flag */
- $hasError = false;
-
/* Get the share object for later deletion */
try {
$share = $GLOBALS['mnemo_shares']->getShare($user);
} catch (Horde_Share_Exception $e) {
- Horde::logMessage($e->getMessage(), 'ERR');
+ Horde::logMessage($e), 'ERR');
}
+
$GLOBALS['display_notepads'] = array($user);
$memos = Mnemo::listMemos();
if ($memos instanceof PEAR_Error) {
- $hasError = true;
- Horde::logMessage($mnemos->getMessage(), 'ERR');
+ Horde::logMessage($mnemos, 'ERR');
+ throw new Mnemo_Exception(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
} else {
$uids = array();
foreach ($memos as $memo) {
try {
$GLOBALS['mnemo_shares']->removeShare($share);
} catch (Horde_Share_Exception $e) {
- $hasError = true;
- Horde::logMessage($e->getMessage(), 'ERR');
+ Horde::logMessage($e, 'ERR');
+ throw new Mnemo_Exception(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
}
}
- /* Get a list of all shares this user has perms to and remove the perms */
+ /* Get a list of all shares this user has perms to and remove the
+ * perms. */
try {
$shares = $GLOBALS['mnemo_shares']->listShares($user);
foreach ($shares as $share) {
$share->removeUser($user);
}
} catch (Horde_Share_Exception $e) {
- $hasError = true;
Horde::logMessage($e, 'ERR');
- }
-
-
- if ($hasError) {
- return PEAR::raiseError(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
- } else {
- return true;
+ throw new Mnemo_Exception(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
}
}
*
* @param string $user Name of user to remove data for.
*
- * @return mixed true on success | PEAR_Error on failure
+ * @throws Nag_Exception
*/
public function removeUserData($user)
{
- if (!$GLOBALS['registry']->isAdmin() && $user != $GLOBALS['registry']->getAuth()) {
- return PEAR::raiseError(_("You are not allowed to remove user data."));
- }
-
- /* Error flag */
- $hasError = false;
-
/* Get the share for later deletion */
try {
$share = $GLOBALS['nag_shares']->getShare($user);
} catch (Horde_Share_Exception $e) {
- Horde::logMessage($e->getMessage(), 'ERR');
+ Horde::logMessage($e, 'ERR');
}
/* Get the list of all tasks */
$tasks = Nag::listTasks(null, null, null, $user, 1);
if ($tasks instanceof PEAR_Error) {
- $hasError = true;
- Horde::logMessage($share, 'ERR');
+ Horde::logMessage($tasks, 'ERR');
+ throw new Nag_Exception(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
} else {
$uids = array();
$tasks->reset();
}
}
-
/* ...and finally, delete the actual share */
if (!empty($share)) {
try {
$GLOBALS['nag_shares']->removeShare($share);
} catch (Horde_Share_Exception $e) {
- $hasError = true;
- Horde::logMessage($result, 'ERR');
+ Horde::logMessage($e, 'ERR');
+ throw new Nag_Exception(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
}
}
$share->removeUser($user);
}
} catch (Horde_Share_Exception $e) {
- $hasError = true;
- Horde::logMessage($shares, 'ERR');
- }
-
- if ($hasError) {
- return PEAR::raiseError(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
- } else {
- return true;
+ Horde::logMessage($e, 'ERR');
+ throw new Nag_Exception(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
}
}
*
* @param string $user Name of user to remove data for.
*
- * @throws Horde_Exception
+ * @throws Turba_Exception
*/
public function removeUserData($user)
{
- if (!$GLOBALS['registry']->isAdmin() &&
- ($user != $GLOBALS['registry']->getAuth())) {
- throw new Horde_Exception(_("You are not allowed to remove user data."));
- }
-
/* We need a clean copy of the $cfgSources array here.*/
require TURBA_BASE . '/config/sources.php';
- $hasError = false;
foreach ($cfgSources as $source) {
if (empty($source['use_shares'])) {
$driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source);
} catch (Turba_Exception $e) {
Horde::logMessage($e, 'ERR');
- $hasError = true;
- continue;
+ throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
}
try {
$driver->removeUserData($user);
} catch (Turba_Exception $e) {
Horde::logMessage($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 (!empty($_SESSION['turba']['has_share'])) {
- $shares = $GLOBALS['turba_shares']->listShares(
- $user, Horde_Perms::EDIT, $user);
+ if (empty($_SESSION['turba']['has_share'])) {
+ return;
+ }
- /* Look for the deleted user's default share and remove it */
- foreach ($shares as $share) {
- $params = @unserialize($share->get('params'));
- /* Only attempt to delete the user's default share */
- if (!empty($params['default'])) {
- $config = Turba::getSourceFromShare($share);
- try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($config);
- } catch (Turba_Exception $e) {
- continue;
- }
+ $shares = $GLOBALS['turba_shares']->listShares($user, Horde_Perms::EDIT, $user);
- try {
- $driver->removeUserData($user);
- } catch (Turba_Exception $e) {
- Horde::logMessage($e, 'ERR');
- $hasError = true;
- }
+ /* Look for the deleted user's default share and remove it */
+ foreach ($shares as $share) {
+ $params = @unserialize($share->get('params'));
+
+ /* Only attempt to delete the user's default share */
+ if (!empty($params['default'])) {
+ $config = Turba::getSourceFromShare($share);
+ try {
+ $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($config);
+ } catch (Turba_Exception $e) {
+ continue;
}
- }
- /* Get a list of all shares this user has perms to and remove the perms. */
- try {
- $shares = $GLOBALS['turba_shares']->listShares($user);
- foreach ($shares as $share) {
- $share->removeUser($user);
+ try {
+ $driver->removeUserData($user);
+ } catch (Turba_Exception $e) {
+ Horde::logMessage($e, 'ERR');
+ throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
}
- } catch (Horde_Share_Exception $e) {
- Horde::logMessage($e, 'ERR');
}
}
- if ($hasError) {
- throw new Horde_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 = $GLOBALS['turba_shares']->listShares($user);
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e, 'ERR');
+ throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
}
}