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 
00054     protected $_iViewIndexState = 1;
00055 
00066     public function render()
00067     {
00068         parent::render();
00069 
00070         $this->_aViewData['editval']   = $this->getUserData();
00071         $this->_aViewData['c_subject'] = $this->getContactSubject();
00072         $this->_aViewData['c_message'] = $this->getContactMessage();
00073 
00074         //captcha
00075         $this->_aViewData['oCaptcha'] = $this->getCaptcha();
00076         $this->_aViewData['success']  = $this->getContactSendStatus();
00077 
00078         return $this->_sThisTemplate;
00079     }
00080 
00090     public function send()
00091     {
00092         // spam spider prevension
00093         $sMac     = oxConfig::getParameter( 'c_mac' );
00094         $sMacHash = oxConfig::getParameter( 'c_mach' );
00095         $oCaptcha = oxNew('oxCaptcha');
00096         if (!$oCaptcha->pass($sMac, $sMacHash))
00097         {
00098             // even if there is no exception, use this as a default display method
00099             oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00100             return false;
00101         }
00102 
00103         $aParams  = oxConfig::getParameter( 'editval' );
00104         $sSubject = oxConfig::getParameter( 'c_subject' );
00105         $sBody    = oxConfig::getParameter( 'c_message' );
00106         if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
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         $sMessage  = "Message from ".$aParams['oxuser__oxsal']." ".$aParams['oxuser__oxfname']." ".$aParams['oxuser__oxlname']."(".$aParams['oxuser__oxusername'].")\n\n";
00113         $sMessage .= nl2br( $sBody );
00114 
00115         $oEmail = oxNew( 'oxemail' );
00116         if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
00117             $this->_blContactSendStatus = 1;
00118         }
00119     }
00120 
00126     public function getUserData()
00127     {
00128         if ( $this->_oUserData === null ) {
00129             $this->_oUserData = oxConfig::getParameter( 'editval' );
00130         }
00131         return $this->_oUserData;
00132     }
00133 
00139     public function getContactSubject()
00140     {
00141         if ( $this->_sContactSubject === null ) {
00142             $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
00143         }
00144         return $this->_sContactSubject;
00145     }
00146 
00152     public function getContactMessage()
00153     {
00154         if ( $this->_sContactMessage === null ) {
00155             $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
00156         }
00157         return $this->_sContactMessage;
00158     }
00159 
00165     public function getCaptcha()
00166     {
00167         if ( $this->_oCaptcha === null ) {
00168             $this->_oCaptcha = oxNew('oxCaptcha');
00169         }
00170         return $this->_oCaptcha;
00171     }
00172 
00178     public function getContactSendStatus()
00179     {
00180         return $this->_blContactSendStatus;
00181     }
00182 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5