Horde_Core_Prefs_Ui::_identitiesUpdate PHP Метод

_identitiesUpdate() защищенный Метод

Update identities prefs.
protected _identitiesUpdate ( )
    protected function _identitiesUpdate()
    {
        global $conf, $notification, $prefs;
        $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create(null, $this->app);
        if ($this->vars->delete_identity) {
            $id = intval($this->vars->identity);
            $deleted_identity = $identity->delete($id);
            $this->_loadPrefs($this->app);
            $notification->push(sprintf(Horde_Core_Translation::t("The identity \"%s\" has been deleted."), $deleted_identity['id']), 'horde.success');
            return;
        }
        $old_default = $identity->getDefault();
        $from_addresses = $identity->getAll('from_addr');
        $current_from = $identity->getValue('from_addr');
        $id = intval($this->vars->identity);
        if ($prefs->isLocked('default_identity')) {
            $id = $old_default;
        } else {
            $new_default = intval($this->vars->default_identity);
            if ($new_default != $old_default) {
                $identity->setDefault($new_default);
                $old_default = $new_default;
                $notification->push(Horde_Core_Translation::t("Your default identity has been changed."), 'horde.success');
                /* Need to immediately save, since we may short-circuit
                 * saving the identities below. */
                $identity->save();
            }
        }
        // TODO: Remove for H6
        if ($id == -2) {
            return;
        }
        if ($id == -1) {
            $id = $identity->add();
        }
        $identity->setDefault($id);
        try {
            $this->_handleForm($this->_addHordeIdentitiesPrefs($this->getChangeablePrefs($this->group)), $identity);
        } catch (Exception $e) {
            $notification->push($e, 'horde.error');
            return;
        }
        $new_from = $identity->getValue('from_addr');
        if (!empty($conf['user']['verify_from_addr']) && empty($new_from)) {
            $notification->push(Horde_Core_Translation::t("The e-mail field cannot be empty."), 'horde.error');
        } elseif (!empty($conf['user']['verify_from_addr']) && $current_from != $new_from && !in_array($new_from, $from_addresses)) {
            try {
                $identity->verifyIdentity($id, empty($current_from) ? $new_from : $current_from);
            } catch (Horde_Exception $e) {
                $notification->push(Horde_Core_Translation::t("The new from address can't be verified, try again later: ") . $e->getMessage(), 'horde.error');
                Horde::log($e, 'ERR');
            }
        } else {
            $identity->setDefault($old_default);
            $identity->save();
        }
    }