Horde_Core_Prefs_Ui::handleForm PHP Метод

handleForm() публичный Метод

Handle a preferences form submission if there is one, updating any preferences which have been changed.
public handleForm ( )
    public function handleForm()
    {
        /* Toggle Advanced/Basic mode. */
        if (!empty($this->vars->show_advanced) || !empty($this->vars->show_basic)) {
            $GLOBALS['session']->set('horde', 'prefs_advanced', !empty($this->vars->show_advanced));
        } elseif (!$this->vars->actionID || !$this->group || !$this->groupIsEditable($this->group)) {
            return;
        } elseif (isset($this->vars->prefs_return)) {
            $this->group = $this->vars->actionID = '';
            return;
        } else {
            try {
                $GLOBALS['injector']->getInstance('Horde_Token')->validate($this->vars->horde_prefs_token, 'horde.prefs');
            } catch (Horde_Token_Exception $e) {
                $GLOBALS['notification']->push($e);
                return;
            }
        }
        switch ($this->vars->actionID) {
            case 'update_prefs':
                if (isset($this->prefGroups[$this->group]['type']) && $this->prefGroups[$this->group]['type'] == 'identities') {
                    $this->_identitiesUpdate();
                } else {
                    $this->_handleForm($this->getChangeablePrefs($this->group), $GLOBALS['prefs']);
                }
                break;
            case 'update_special':
                $special = array();
                foreach ($this->getChangeablePrefs($this->group) as $pref) {
                    if ($this->prefs[$pref]['type'] == 'special') {
                        $special[] = $pref;
                    }
                }
                $this->_handleForm($special, $GLOBALS['prefs']);
                break;
        }
        $this->nobuttons = false;
        $this->suppress = array();
    }

Usage Example

Пример #1
0
<?php

/**
 * Preferences UI page.
 *
 * URL Parameters
 * --------------
 *   - actionID: (string) Action ID.
 *   - app: (string) The current Horde application.
 *   - group: (string) The current preferences group.
 *
 * Copyright 1999-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL-2). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   Chuck Hagenbuch <*****@*****.**>
 * @author   Jan Schneider <*****@*****.**>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL-2
 * @package  Horde
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde');
$prefs_ui = new Horde_Core_Prefs_Ui($injector->getInstance('Horde_Variables'));
/* Handle form submission. */
$prefs_ui->handleForm();
/* Generate the UI. */
$prefs_ui->generateUI();