<?php

/**
 * kataoMemberGroup actions.
 *
 * @package    www.katao.fr
 * @subpackage kataoMemberGroup
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class kataoMemberGroupActions extends sfActions
{
  public function executeIndex()
  {
    $this->katao_member_groupList = KataoMemberGroupPeer::doSelect(new Criteria());
  }

  public function executeShow($request)
  {
    $this->katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('katao_member_group_id'));
    $this->forward404Unless($this->katao_member_group);
  }

  public function executeCreate()
  {
    $this->form = new KataoMemberGroupForm();

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

  public function executeEdit($request)
  {
    $this->katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('id'));
    $this->form = new KataoMemberGroupForm(KataoMemberGroupPeer::retrieveByPk($request->getParameter('id')));
  }

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

    $this->form = new KataoMemberGroupForm(KataoMemberGroupPeer::retrieveByPk($request->getParameter('katao_member_group_id')));

    $this->form->bind($request->getParameter('katao_member_group'));

    if ($this->form->isValid())
    {
      $katao_member_group = $this->form->save();

      wpFlashMessages::addConfirmation('Groupe "' . $katao_member_group->getKataoMemberGroupName() . '" sauvé avec succès.');

      $this->redirect('kataoMemberGroup/index');
    }

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

  public function executeDelete($request)
  {
    $this->forward404Unless($katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('id')));

    $katao_member_group->delete();

    $this->redirect('kataoMemberGroup/index');
  }
}
