class Horde_Hooks {
         * Setting value at login
         * ----------------------
         * If the 'hook' parameter is non-empty for a preference (config/prefs.php),
         * the prefs_init hook will be run on login to allow alteration of the value.
         * This hook receives the preference name, preference value, username, and
         * the master scope object (Horde_Prefs_Scope) as parameters and uses the
         * return value from the hook as the new preference value.
         * Username will be null if the user is not authenticated.
         * This hook is ONLY executed on login and preferences are cached during a
         * users' session.
         * We're making the settings permanent using $scope_ob->set
        public function prefs_init($pref, $value, $username, $scope_ob) {

                if (is_null($username)) {    // not logged in
                        return $value;

                switch ($pref) {
                        case 'from_addr':    // Define "from" address if it hasn't been set before
                                if($value == '') {
                                        $value = $username;
                                        $scope_ob->set($pref, $value);
                                        $scope_ob->setDirty($pref, true);
                                return $value;