contact.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class Contact extends oxUBase
00011 {
00016     protected $_aUserData = null;
00017 
00022     protected $_sContactSubject = null;
00023 
00028     protected $_sContactMessage = null;
00029 
00034     protected $_oCaptcha = null;
00035 
00040     protected $_blContactSendStatus = null;
00041 
00046     protected $_sThisTemplate = 'contact.tpl';
00047 
00053     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00054 
00065     public function render()
00066     {
00067         parent::render();
00068 
00069         $this->_aViewData['editval']   = $this->getUserData();
00070         $this->_aViewData['c_subject'] = $this->getContactSubject();
00071         $this->_aViewData['c_message'] = $this->getContactMessage();
00072 
00073         //captcha
00074         $this->_aViewData['oCaptcha'] = $this->getCaptcha();
00075         $this->_aViewData['success']  = $this->getContactSendStatus();
00076 
00077         return $this->_sThisTemplate;
00078     }
00079 
00089     public function send()
00090     {
00091         // spam spider prevension
00092         $sMac     = oxConfig::getParameter( 'c_mac' );
00093         $sMacHash = oxConfig::getParameter( 'c_mach' );
00094         $oCaptcha = oxNew('oxCaptcha');
00095 
00096         $aParams  = oxConfig::getParameter( 'editval' );
00097         $sSubject = oxConfig::getParameter( 'c_subject' );
00098         $sBody    = oxConfig::getParameter( 'c_message' );
00099 
00100         // checking email address
00101         if ( !oxUtils::getInstance()->isValidEmail( $aParams['oxuser__oxusername'] ) ) {
00102             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOVALIDEMAIL' );
00103             return false;
00104         }
00105 
00106         if ( !$oCaptcha->pass($sMac, $sMacHash ) ) {
00107             // even if there is no exception, use this as a default display method
00108             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00109             return false;
00110         }
00111 
00112         if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
00113             // even if there is no exception, use this as a default display method
00114             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00115             return false;
00116         }
00117 
00118         $sMessage  = oxLang::getInstance()->translateString( 'CONTACT_FROM' )." ".$aParams['oxuser__oxsal']." ".$aParams['oxuser__oxfname']." ".$aParams['oxuser__oxlname']."(".$aParams['oxuser__oxusername'].")<br /><br />";
00119         $sMessage .= nl2br( $sBody );
00120 
00121         $oEmail = oxNew( 'oxemail' );
00122         if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
00123             $this->_blContactSendStatus = 1;
00124         }
00125     }
00126 
00132     public function getUserData()
00133     {
00134         if ( $this->_oUserData === null ) {
00135             $this->_oUserData = oxConfig::getParameter( 'editval' );
00136         }
00137         return $this->_oUserData;
00138     }
00139 
00145     public function getContactSubject()
00146     {
00147         if ( $this->_sContactSubject === null ) {
00148             $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
00149         }
00150         return $this->_sContactSubject;
00151     }
00152 
00158     public function getContactMessage()
00159     {
00160         if ( $this->_sContactMessage === null ) {
00161             $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
00162         }
00163         return $this->_sContactMessage;
00164     }
00165 
00171     public function getCaptcha()
00172     {
00173         if ( $this->_oCaptcha === null ) {
00174             $this->_oCaptcha = oxNew('oxCaptcha');
00175         }
00176         return $this->_oCaptcha;
00177     }
00178 
00184     public function getContactSendStatus()
00185     {
00186         return $this->_blContactSendStatus;
00187     }
00188 }

Generated on Mon Oct 26 20:07:20 2009 for OXID eShop CE by  doxygen 1.5.5