/
actions.class.php
65 lines (62 loc) · 1.63 KB
/
actions.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* contact actions.
*
* @package pumpproedits
* @subpackage contact
* @author JasonWolfman2000Felds
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class contactActions extends sfActions
{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$user = $this->getUser();
if ($user->isAuthenticated())
{
$def = array('name' => $user->getAttribute('name'), 'email' => $user->getAttribute('email'));
$this->form = new ContactForm($def);
}
else
{
$this->form = new ContactForm();
}
}
public function executeValidate(sfWebRequest $request)
{
$this->form = new ContactForm();
$this->form->bind($request->getParameter('validate'));
if ($this->form->isValid())
{
// We can immediately send the email.
$body = $this->form->getValue('content');
$subject = $this->form->getValue('subject');
$name = $this->form->getValue('name');
$email = $this->form->getValue('email');
try
{
$cm = new ContactMessage($email, $name, $subject, $body);
$this->getMailer()->send($cm);
}
catch (Swift_RfcComplianceException $e)
{
$this->getResponse()->setStatusCode(409);
$this->data = array('The mailer is down: please email directly!');
$this->noshow = 1;
$this->subj = $subject;
$this->body = $body;
return sfView::ERROR;
}
}
else
{
$this->getResponse()->setStatusCode(409);
return sfView::ERROR;
}
}
}