public function actionContact()
{
$options = XenForo_Application::get('options');
if ($options->contactUrl['type'] == 'custom')
{
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL,
$options->contactUrl['custom']
);
}
else if (!$options->contactUrl['type'])
{
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL,
XenForo_Link::buildPublicLink('index')
);
}
if ($this->_request->isPost())
{
if (!XenForo_Captcha_Abstract::validateDefault($this->_input))
{
return $this->responseCaptchaFailed();
}
$user = XenForo_Visitor::getInstance()->toArray();
if (!$user['user_id'])
{
$user['email'] = $this->_input->filterSingle('email', XenForo_Input::STRING);
if (!Zend_Validate::is($user['email'], 'EmailAddress'))
{
return $this->responseError(new XenForo_Phrase('please_enter_valid_email'));
}
}
$input = $this->_input->filter(array(
'subject' => XenForo_Input::STRING,
'message' => XenForo_Input::STRING
));
if (!$user['username'] || !$input['subject'] || !$input['message'])
{
return $this->responseError(new XenForo_Phrase('please_complete_required_fields'));
}
$this->assertNotFlooding('contact');
$mailParams = array(
'user' => $user,
'subject' => $input['subject'],
'message' => $input['message']
);
$mail = XenForo_Mail::create('contact', $mailParams, 0);
$mail->send(
XenForo_Application::get('options')->contactEmailAddress, '', array(
'Sender' => XenForo_Application::get('options')->contactEmailAddress
),
$user['email'], $user['username']
);
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
$this->getDynamicRedirect(),
new XenForo_Phrase('your_message_has_been_sent')
);
}
else
{
$viewParams = array(
'redirect' => $this->getDynamicRedirect(),
'subject' => $this->_input->filterSingle('subject', XenForo_Input::STRING),
'captcha' => XenForo_Captcha_Abstract::createDefault()
);
return $this->responseView('XenForo_ViewPublic_Misc_Contact', 'contact', $viewParams);
}
}