Source for file contact.php
Documentation is available at contact.php
* @subpackage com_contact
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @subpackage com_contact
public function getModel($name =
'', $prefix =
'', $config =
array('ignore_request' =>
true))
return parent::getModel($name, $prefix, array('ignore_request' =>
false));
// Check for request forgeries.
$stub =
$this->input->getString('id');
// Get the data from POST
$data =
$this->input->post->get('jform', array(), 'array');
$contact =
$model->getItem($id);
$params->merge($contact->params);
// Check for a valid session cookie
if ($params->get('validate_session', 0))
// Save the data in the session.
$app->setUserState('com_contact.contact.data', $data);
// Redirect back to the contact form.
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id='.
$stub, false));
// Validate the posted data.
$form =
$model->getForm();
$validate =
$model->validate($form, $data);
// Get the validation messages.
$errors =
$model->getErrors();
// Push up to three validation messages out to the user.
for ($i =
0, $n =
count($errors); $i <
$n &&
$i <
3; $i++
)
if ($errors[$i] instanceof
Exception)
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
$app->enqueueMessage($errors[$i], 'warning');
// Save the data in the session.
$app->setUserState('com_contact.contact.data', $data);
// Redirect back to the contact form.
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id='.
$stub, false));
// Validation succeeded, continue with custom handlers
$results =
$dispatcher->trigger('onValidateContact', array(&$contact, &$data));
foreach ($results as $result)
if ($result instanceof
Exception)
// Passed Validation: Process the contact plugins to integrate with other applications
$dispatcher->trigger('onSubmitContact', array(&$contact, &$data));
if (!$params->get('custom_reply'))
$sent =
$this->_sendEmail($data, $contact);
// Set the success message if it was a success
if (!($sent instanceof
Exception))
$msg =
JText::_('COM_CONTACT_EMAIL_THANKS');
// Flush the data from the session
$app->setUserState('com_contact.contact.data', null);
// Redirect if it is set in the parameters, otherwise redirect back to where we came from
if ($contact->params->get('redirect'))
$this->setRedirect($contact->params->get('redirect'), $msg);
$this->setRedirect(JRoute::_('index.php?option=com_contact&view=contact&id='.
$stub, false), $msg);
private function _sendEmail($data, $contact)
if ($contact->email_to ==
'' &&
$contact->user_id !=
0)
$contact->email_to =
$contact_user->get('email');
$mailfrom =
$app->getCfg('mailfrom');
$fromname =
$app->getCfg('fromname');
$sitename =
$app->getCfg('sitename');
$name =
$data['contact_name'];
$email =
JstringPunycode::emailToPunycode($data['contact_email']);
$subject =
$data['contact_subject'];
$body =
$data['contact_message'];
$body =
$prefix.
"\n".
$name.
' <'.
$email.
'>'.
"\r\n\r\n".
stripslashes($body);
$mail->addRecipient($contact->email_to);
$mail->addReplyTo(array($email, $name));
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($sitename.
': '.
$subject);
//If we are supposed to copy the sender, do so.
// check whether email copy function activated
$copytext =
JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename);
$copytext .=
"\r\n\r\n".
$body;
$copysubject =
JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);
$mail->addRecipient($email);
$mail->addReplyTo(array($email, $name));
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($copysubject);
$mail->setBody($copytext);
Documentation generated on Tue, 19 Nov 2013 14:56:36 +0100 by phpDocumentor 1.4.3