Horde_Registry::removeUserData PHP Method

removeUserData() public method

Removes user's application data.
public removeUserData ( string $user, string $app = null )
$user string The user ID to delete.
$app string If set, only removes data from this application. By default, removes data from all apps.
    public function removeUserData($user, $app = null)
    {
        if (!$this->isAdmin() && $user != $this->getAuth()) {
            throw new Horde_Exception(Horde_Core_Translation::t("You are not allowed to remove user data."));
        }
        $applist = empty($app) ? $this->listApps(array('notoolbar', 'hidden', 'active', 'admin', 'noadmin')) : array($app);
        $errApps = array();
        if (!empty($applist)) {
            $prefs_ob = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('horde', array('user' => $user));
            // Remove all preference at once, if possible.
            if (empty($app)) {
                try {
                    $prefs_ob->removeAll();
                } catch (Horde_Exception $e) {
                    Horde::log($e);
                }
            }
        }
        foreach ($applist as $item) {
            try {
                $this->callAppMethod($item, 'removeUserData', array('args' => array($user)));
            } catch (Exception $e) {
                Horde::log($e);
                $errApps[] = $item;
            }
            if (empty($app)) {
                continue;
            }
            try {
                $prefs_ob->retrieve($item);
                $prefs_ob->remove();
            } catch (Horde_Exception $e) {
                Horde::log($e);
                $errApps[] = $item;
            }
        }
        if (count($errApps)) {
            throw new Horde_Exception(sprintf(Horde_Core_Translation::t("The following applications encountered errors removing user data: %s"), implode(', ', array_unique($errApps))));
        }
    }