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         if ( !$oCaptcha->pass($sMac, $sMacHash ) ) {
00096             // even if there is no exception, use this as a default display method
00097             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00098             return false;
00099         }
00100 
00101         $aParams  = oxConfig::getParameter( 'editval' );
00102         $sSubject = oxConfig::getParameter( 'c_subject' );
00103         $sBody    = oxConfig::getParameter( 'c_message' );
00104         if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
00105             // even if there is no exception, use this as a default display method
00106             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00107             return false;
00108         }
00109 
00110         $sMessage  = oxLang::getInstance()->translateString( 'CONTACT_FROM' )." ".$aParams['oxuser__oxsal']." ".$aParams['oxuser__oxfname']." ".$aParams['oxuser__oxlname']."(".$aParams['oxuser__oxusername'].")\n\n";
00111         $sMessage .= nl2br( $sBody );
00112 
00113         $oEmail = oxNew( 'oxemail' );
00114         if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
00115             $this->_blContactSendStatus = 1;
00116         }
00117     }
00118 
00124     public function getUserData()
00125     {
00126         if ( $this->_oUserData === null ) {
00127             $this->_oUserData = oxConfig::getParameter( 'editval' );
00128         }
00129         return $this->_oUserData;
00130     }
00131 
00137     public function getContactSubject()
00138     {
00139         if ( $this->_sContactSubject === null ) {
00140             $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
00141         }
00142         return $this->_sContactSubject;
00143     }
00144 
00150     public function getContactMessage()
00151     {
00152         if ( $this->_sContactMessage === null ) {
00153             $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
00154         }
00155         return $this->_sContactMessage;
00156     }
00157 
00163     public function getCaptcha()
00164     {
00165         if ( $this->_oCaptcha === null ) {
00166             $this->_oCaptcha = oxNew('oxCaptcha');
00167         }
00168         return $this->_oCaptcha;
00169     }
00170 
00176     public function getContactSendStatus()
00177     {
00178         return $this->_blContactSendStatus;
00179     }
00180 }

Generated on Wed May 13 13:25:55 2009 for OXID eShop CE by  doxygen 1.5.5