<?php
/*
* This file is part of the pwp package.
* (c) 2009-2010 Victor Rad' <victor.v.rad[at]gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Contact actions
*
* @package pwp
* @subpackage contact
* @author Victor Rad'
*/
class contactActions extends sfActions
{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->form = new contactForm();
if ($request->isMethod('post') and $request->hasParameter($this->form->getName())) {
$this->form->bind($request->getParameter($this->form->getName()));
if($this->form->isValid()) {
$this->sendEmail($this->form->getValues());
$this->getUser()->setFlash('delivered', 'Thank you. Your message will be delivered');
$this->redirect('@contact_index');
}
}
}
public function postExecute()
{
$this->getResponse()->setSlot('colOne', $this->getPartial('colOne'));
}
/**
* Send email
*
* @param array $values
*/
protected function sendEmail($values)
{
$message = $this->getMailer()->compose(
array($values['email'] => $values['name']),
sfConfig::get('app_contact_email'),
'PWP - User notification',
$values['message']
);
$this->getMailer()->send($message);
}
}