Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Contacts_Helper_Data
  • Mage_Contacts_IndexController
  • Mage_Contacts_Model_System_Config_Backend_Links
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Contacts
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Contacts index controller
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Contacts
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action
 35: {
 36: 
 37:     const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
 38:     const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
 39:     const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
 40:     const XML_PATH_ENABLED          = 'contacts/contacts/enabled';
 41: 
 42:     public function preDispatch()
 43:     {
 44:         parent::preDispatch();
 45: 
 46:         if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
 47:             $this->norouteAction();
 48:         }
 49:     }
 50: 
 51:     public function indexAction()
 52:     {
 53:         $this->loadLayout();
 54:         $this->getLayout()->getBlock('contactForm')
 55:             ->setFormAction( Mage::getUrl('*/*/post') );
 56: 
 57:         $this->_initLayoutMessages('customer/session');
 58:         $this->_initLayoutMessages('catalog/session');
 59:         $this->renderLayout();
 60:     }
 61: 
 62:     public function postAction()
 63:     {
 64:         $post = $this->getRequest()->getPost();
 65:         if ( $post ) {
 66:             $translate = Mage::getSingleton('core/translate');
 67:             /* @var $translate Mage_Core_Model_Translate */
 68:             $translate->setTranslateInline(false);
 69:             try {
 70:                 $postObject = new Varien_Object();
 71:                 $postObject->setData($post);
 72: 
 73:                 $error = false;
 74: 
 75:                 if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
 76:                     $error = true;
 77:                 }
 78: 
 79:                 if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
 80:                     $error = true;
 81:                 }
 82: 
 83:                 if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
 84:                     $error = true;
 85:                 }
 86: 
 87:                 if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
 88:                     $error = true;
 89:                 }
 90: 
 91:                 if ($error) {
 92:                     throw new Exception();
 93:                 }
 94:                 $mailTemplate = Mage::getModel('core/email_template');
 95:                 /* @var $mailTemplate Mage_Core_Model_Email_Template */
 96:                 $mailTemplate->setDesignConfig(array('area' => 'frontend'))
 97:                     ->setReplyTo($post['email'])
 98:                     ->sendTransactional(
 99:                         Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
100:                         Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
101:                         Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
102:                         null,
103:                         array('data' => $postObject)
104:                     );
105: 
106:                 if (!$mailTemplate->getSentSuccess()) {
107:                     throw new Exception();
108:                 }
109: 
110:                 $translate->setTranslateInline(true);
111: 
112:                 Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
113:                 $this->_redirect('*/*/');
114: 
115:                 return;
116:             } catch (Exception $e) {
117:                 $translate->setTranslateInline(true);
118: 
119:                 Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
120:                 $this->_redirect('*/*/');
121:                 return;
122:             }
123: 
124:         } else {
125:             $this->_redirect('*/*/');
126:         }
127:     }
128: 
129: }
130: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0