return $GLOBALS['folks_driver']->isOnline($user);
}
- /**
- * Deletes a user and its data
- *
- * @param string $userId The userId to delete.
- *
- * @return boolean True on success or a PEAR_Error object on failure.
- */
- public function removeUserData($user = null)
- {
- return $this->removeUser($user);
- }
-
}
return $GLOBALS['folks_driver']->deleteUser($userId);
}
+
+ /**
+ * Deletes a user and its data
+ *
+ * @param string $userId The userId to delete.
+ *
+ * @return boolean True on success or a PEAR_Error object on failure.
+ */
+ public function removeUserData($user = null)
+ {
+ return $this->authRemoveUser($user);
+ }
+
}
);
/**
- * Removes user data.
- *
- * @param string $user Name of user to remove data for.
- *
- * @return mixed true on success | PEAR_Error on failure
- */
- public function removeUserData($user)
- {
- if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
- return PEAR::raiseError(_("You are not allowed to remove user data."));
- }
-
- require_once dirname(__FILE__) . '/../lib/base.php';
-
- /* Remove all filters/rules owned by the user. */
- $result = $GLOBALS['ingo_storage']->removeUserData($user);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $result;
- }
-
- /* Now remove all shares owned by the user. */
- if (!empty($GLOBALS['ingo_shares'])) {
- /* Get the user's default share. */
- $share = $GLOBALS['ingo_shares']->getShare($user);
- if (is_a($share, 'PEAR_Error')) {
- Horde::logMessage($share, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $share;
- } else {
- $result = $GLOBALS['ingo_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $result;
- }
- }
-
- /* Get a list of all shares this user has perms to and remove the
- * perms. */
- $shares = $GLOBALS['ingo_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
- Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- foreach ($shares as $share) {
- $share->removeUser($user);
- }
-
- /* Get a list of all shares this user owns and has perms to delete
- * and remove them. */
- $shares = $GLOBALS['ingo_shares']->listShares($user, PERMS_DELETE, $user);
- if (is_a($shares, 'PEAR_Error')) {
- Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $shares;
- }
- foreach ($shares as $share) {
- $GLOBALS['ingo_shares']->removeShare($share);
- }
- }
-
- return true;
- }
-
- /**
* Add addresses to the blacklist.
*
* @param string $addresses The addresses to add to the blacklist.
return Ingo::getMenu();
}
+ /**
+ * Removes user data.
+ *
+ * @param string $user Name of user to remove data for.
+ *
+ * @return mixed true on success | PEAR_Error on failure
+ */
+ public function removeUserData($user)
+ {
+ if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
+ return PEAR::raiseError(_("You are not allowed to remove user data."));
+ }
+
+ require_once dirname(__FILE__) . '/../lib/base.php';
+
+ /* Remove all filters/rules owned by the user. */
+ $result = $GLOBALS['ingo_storage']->removeUserData($user);
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ return $result;
+ }
+
+ /* Now remove all shares owned by the user. */
+ if (!empty($GLOBALS['ingo_shares'])) {
+ /* Get the user's default share. */
+ $share = $GLOBALS['ingo_shares']->getShare($user);
+ if (is_a($share, 'PEAR_Error')) {
+ Horde::logMessage($share, __FILE__, __LINE__, PEAR_LOG_ERR);
+ return $share;
+ } else {
+ $result = $GLOBALS['ingo_shares']->removeShare($share);
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ return $result;
+ }
+ }
+
+ /* Get a list of all shares this user has perms to and remove the
+ * perms. */
+ $shares = $GLOBALS['ingo_shares']->listShares($user);
+ if (is_a($shares, 'PEAR_Error')) {
+ Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+
+ /* Get a list of all shares this user owns and has perms to delete
+ * and remove them. */
+ $shares = $GLOBALS['ingo_shares']->listShares($user, PERMS_DELETE, $user);
+ if (is_a($shares, 'PEAR_Error')) {
+ Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
+ return $shares;
+ }
+ foreach ($shares as $share) {
+ $GLOBALS['ingo_shares']->removeShare($share);
+ }
+ }
+
+ return true;
+ }
+
}
);
/**
- * Removes user data.
- *
- * @param string $user Name of user to remove data for.
- *
- * @return mixed true on success | PEAR_Error on failure
- */
- public function removeUserData($user)
- {
- if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
- return PEAR::raiseError(_("You are not allowed to remove user data."));
- }
-
- $no_maint = true;
- require_once dirname(__FILE__) . '/base.php';
-
- /* Remove all events owned by the user in all calendars. */
- $result = Kronolith::getDriver()->removeUserData($user);
-
- /* Now delete history as well. */
- $history = Horde_History::singleton();
- if (method_exists($history, 'removeByParent')) {
- $histories = $history->removeByParent('kronolith:' . $user);
- } else {
- /* Remove entries 100 at a time. */
- $all = $history->getByTimestamp('>', 0, array(), 'kronolith:' . $user);
- if (is_a($all, 'PEAR_Error')) {
- Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
- } else {
- $all = array_keys($all);
- while (count($d = array_splice($all, 0, 100)) > 0) {
- $history->removebyNames($d);
- }
- }
- }
-
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
-
- /* Get the user's default share */
- $share = $GLOBALS['kronolith_shares']->getShare($user);
- if (is_a($share, 'PEAR_Error')) {
- Horde::logMessage($share, __FILE__, __LINE__, PEAR_LOG_ERR);
- } else {
- $result = $GLOBALS['kronolith_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
- $hasError = true;
- Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- }
-
- /* Get a list of all shares this user has perms to and remove the perms */
- $shares = $GLOBALS['kronolith_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
- Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- foreach ($shares as $share) {
- $share->removeUser($user);
- }
-
- return true;
- }
-
- /**
* Returns the share helper prefix
*
* @return string
$GLOBALS['prefs']->setValue('fb_cals', serialize($fb_calsFiltered));
}
+ /**
+ * Removes user data.
+ *
+ * @param string $user Name of user to remove data for.
+ *
+ * @return mixed true on success | PEAR_Error on failure
+ */
+ public function removeUserData($user)
+ {
+ if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
+ return PEAR::raiseError(_("You are not allowed to remove user data."));
+ }
+
+ $no_maint = true;
+ require_once dirname(__FILE__) . '/base.php';
+
+ /* Remove all events owned by the user in all calendars. */
+ $result = Kronolith::getDriver()->removeUserData($user);
+
+ /* Now delete history as well. */
+ $history = Horde_History::singleton();
+ if (method_exists($history, 'removeByParent')) {
+ $histories = $history->removeByParent('kronolith:' . $user);
+ } else {
+ /* Remove entries 100 at a time. */
+ $all = $history->getByTimestamp('>', 0, array(), 'kronolith:' . $user);
+ if (is_a($all, 'PEAR_Error')) {
+ Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
+ } else {
+ $all = array_keys($all);
+ while (count($d = array_splice($all, 0, 100)) > 0) {
+ $history->removebyNames($d);
+ }
+ }
+ }
+
+ if (is_a($result, 'PEAR_Error')) {
+ return $result;
+ }
+
+ /* Get the user's default share */
+ $share = $GLOBALS['kronolith_shares']->getShare($user);
+ if (is_a($share, 'PEAR_Error')) {
+ Horde::logMessage($share, __FILE__, __LINE__, PEAR_LOG_ERR);
+ } else {
+ $result = $GLOBALS['kronolith_shares']->removeShare($share);
+ if (is_a($result, 'PEAR_Error')) {
+ $hasError = true;
+ Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ }
+
+ /* Get a list of all shares this user has perms to and remove the perms */
+ $shares = $GLOBALS['kronolith_shares']->listShares($user);
+ if (is_a($shares, 'PEAR_Error')) {
+ Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+
+ return true;
+ }
+
}
);
/**
- * Removes user data.
- *
- * @param string $user Name of user to remove data for.
- *
- * @return mixed true on success | PEAR_Error on failure
- */
- public function removeUserData($user)
- {
- require_once dirname(__FILE__) . '/base.php';
-
- if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
- return PEAR::raiseError(_("You are not allowed to remove user data."));
- }
-
- /* Error flag */
- $hasError = false;
-
- /* Get the share for later deletion */
- $share = $GLOBALS['nag_shares']->getShare($user);
- if(is_a($share, 'PEAR_Error')) {
- Horde::logMessage($share->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
- unset($share);
- } else {
- /* Get the list of all tasks */
- $tasks = Nag::listTasks(null, null, null, $user, 1);
- if (is_a($tasks, 'PEAR_Error')) {
- $hasError = true;
- Horde::logMessage($share->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
- } else {
- $uids = array();
- $tasks->reset();
- while ($task = $tasks->each()) {
- $uids[] = $task->uid;
- }
-
- /* ... and delete them. */
- foreach ($uids as $uid) {
- $this->delete($uid);
- }
- }
- }
-
- /* Now delete history as well. */
- $history = Horde_History::singleton();
- if (method_exists($history, 'removeByParent')) {
- $histories = $history->removeByParent('nag:' . $user);
- } else {
- /* Remove entries 100 at a time. */
- $all = $history->getByTimestamp('>', 0, array(), 'nag:' . $user);
- if (is_a($all, 'PEAR_Error')) {
- Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
- } else {
- $all = array_keys($all);
- while (count($d = array_splice($all, 0, 100)) > 0) {
- $history->removebyNames($d);
- }
- }
- }
-
- /* ...and finally, delete the actual share */
- if (!empty($share)) {
- $result = $GLOBALS['nag_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
- $hasError = true;
- Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- }
-
- /* Now remove perms for this user from all other shares */
- $shares = $GLOBALS['nag_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
- $hasError = true;
- Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- foreach ($shares as $share) {
- $share->removeUser($user);
- }
-
- if ($hasError) {
- return PEAR::raiseError(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
- } else {
- return true;
- }
- }
-
- /**
* Retrieves the current user's task list from storage.
*
* This function will also sort the resulting list, if requested.
return Nag::getMenu();
}
+ /**
+ * Removes user data.
+ *
+ * @param string $user Name of user to remove data for.
+ *
+ * @return mixed true on success | PEAR_Error on failure
+ */
+ public function removeUserData($user)
+ {
+ require_once dirname(__FILE__) . '/base.php';
+
+ if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
+ return PEAR::raiseError(_("You are not allowed to remove user data."));
+ }
+
+ /* Error flag */
+ $hasError = false;
+
+ /* Get the share for later deletion */
+ $share = $GLOBALS['nag_shares']->getShare($user);
+ if(is_a($share, 'PEAR_Error')) {
+ Horde::logMessage($share->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ unset($share);
+ } else {
+ /* Get the list of all tasks */
+ $tasks = Nag::listTasks(null, null, null, $user, 1);
+ if (is_a($tasks, 'PEAR_Error')) {
+ $hasError = true;
+ Horde::logMessage($share->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ } else {
+ $uids = array();
+ $tasks->reset();
+ while ($task = $tasks->each()) {
+ $uids[] = $task->uid;
+ }
+
+ /* ... and delete them. */
+ foreach ($uids as $uid) {
+ $this->delete($uid);
+ }
+ }
+ }
+
+ /* Now delete history as well. */
+ $history = Horde_History::singleton();
+ if (method_exists($history, 'removeByParent')) {
+ $histories = $history->removeByParent('nag:' . $user);
+ } else {
+ /* Remove entries 100 at a time. */
+ $all = $history->getByTimestamp('>', 0, array(), 'nag:' . $user);
+ if (is_a($all, 'PEAR_Error')) {
+ Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
+ } else {
+ $all = array_keys($all);
+ while (count($d = array_splice($all, 0, 100)) > 0) {
+ $history->removebyNames($d);
+ }
+ }
+ }
+
+ /* ...and finally, delete the actual share */
+ if (!empty($share)) {
+ $result = $GLOBALS['nag_shares']->removeShare($share);
+ if (is_a($result, 'PEAR_Error')) {
+ $hasError = true;
+ Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ }
+
+ /* Now remove perms for this user from all other shares */
+ $shares = $GLOBALS['nag_shares']->listShares($user);
+ if (is_a($shares, 'PEAR_Error')) {
+ $hasError = true;
+ Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+
+ if ($hasError) {
+ return PEAR::raiseError(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
+ } else {
+ return true;
+ }
+ }
+
}
);
/**
- * Removes user data.
- *
- * @param string $user Name of user to remove data for.
- *
- * @return mixed true on success | PEAR_Error on failure
- */
- public function removeUserData($user)
- {
- require_once dirname(__FILE__) . '/base.php';
-
- if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
- return PEAR::raiseError(_("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'])) {
- // Shares not enabled for this source
- $driver = Turba_Driver::singleton($source);
- if (is_a($driver, 'PEAR_Error')) {
- Horde::logMessage($driver, __FILE__, __LINE__, PEAR_LOG_ERR);
- $hasError = true;
- } else {
- $result = $driver->removeUserData($user);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- }
- }
- }
-
- /* Only attempt share removal if we have shares configured */
- if (!empty($_SESSION['turba']['has_share'])) {
- $shares = &$GLOBALS['turba_shares']->listShares(
- $user, PERMS_EDIT, $user);
-
- /* 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);
- $driver = Turba_Driver::singleton($config);
- $result = $driver->removeUserData($user);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- $hasError = true;
- }
- }
- }
-
- /* Get a list of all shares this user has perms to and remove the perms */
- $shares = $GLOBALS['turba_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
- Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- foreach ($shares as $share) {
- $share->removeUser($user);
- }
-
- }
-
- if ($hasError) {
- return PEAR::raiseError(sprintf(_("There was an error removing an address book for %s"), $user));
- }
-
- return true;
- }
-
- /**
* Callback for comment API
*
* @param integer $id Internal data identifier
return Turba::getMenu();
}
+ /**
+ * Removes user data.
+ *
+ * @param string $user Name of user to remove data for.
+ *
+ * @return mixed true on success | PEAR_Error on failure
+ */
+ public function removeUserData($user)
+ {
+ require_once dirname(__FILE__) . '/base.php';
+
+ if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
+ return PEAR::raiseError(_("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'])) {
+ // Shares not enabled for this source
+ $driver = Turba_Driver::singleton($source);
+ if (is_a($driver, 'PEAR_Error')) {
+ Horde::logMessage($driver, __FILE__, __LINE__, PEAR_LOG_ERR);
+ $hasError = true;
+ } else {
+ $result = $driver->removeUserData($user);
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ }
+ }
+ }
+
+ /* Only attempt share removal if we have shares configured */
+ if (!empty($_SESSION['turba']['has_share'])) {
+ $shares = &$GLOBALS['turba_shares']->listShares(
+ $user, PERMS_EDIT, $user);
+
+ /* 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);
+ $driver = Turba_Driver::singleton($config);
+ $result = $driver->removeUserData($user);
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ $hasError = true;
+ }
+ }
+ }
+
+ /* Get a list of all shares this user has perms to and remove the perms */
+ $shares = $GLOBALS['turba_shares']->listShares($user);
+ if (is_a($shares, 'PEAR_Error')) {
+ Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+
+ }
+
+ if ($hasError) {
+ return PEAR::raiseError(sprintf(_("There was an error removing an address book for %s"), $user));
+ }
+
+ return true;
+ }
+
}