<?php

/**
 * kataoConfig actions.
 *
 * @package www.katao.fr
 * @subpackage kataoConfig
 * @author Your name here
 * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class kataoConfigActions extends wpActions {
    public function executeIndex() {
        $this->form = new KataoConfigForm(KataoConfigPeer::retrieveByPK(wpConfig::DEFAULT_ID));
    }

    public function executeUpdate($request) {
        $this->redirectWithErrorUnless($request->isMethod('post'));

        $this->form = new KataoConfigForm(KataoConfigPeer::retrieveByPK(wpConfig::DEFAULT_ID));

        $this->form->bind($request->getParameter('katao_config'), $request->getFiles('katao_config'));
        if ($this->form->isValid()) {
            $katao_config = $this->form->save();
            wpConfig::setInstance($katao_config);

            wpFlashMessages::addConfirmation('Configuration sauvée avec succès.');
            $this->redirect('kataoConfig/index');
        }

        $this->setTemplate('index');
    }
}