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 = 'page/info/contact.tpl';
00047
00053 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00054
00061 public function send()
00062 {
00063
00064 $sMac = oxConfig::getParameter( 'c_mac' );
00065 $sMacHash = oxConfig::getParameter( 'c_mach' );
00066 $oCaptcha = $this->getCaptcha();
00067
00068 $aParams = oxConfig::getParameter( 'editval' );
00069 $sSubject = oxConfig::getParameter( 'c_subject' );
00070 $sBody = oxConfig::getParameter( 'c_message' );
00071
00072
00073 if ( !oxUtils::getInstance()->isValidEmail( $aParams['oxuser__oxusername'] ) ) {
00074 oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOVALIDEMAIL' );
00075 return false;
00076 }
00077
00078 if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
00079
00080 oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_WRONGCAPTCHA' );
00081 return false;
00082 }
00083
00084 if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
00085
00086 oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00087 return false;
00088 }
00089
00090 $sMessage = oxLang::getInstance()->translateString( 'CONTACT_FROM' )." ".$aParams['oxuser__oxsal']." ".$aParams['oxuser__oxfname']." ".$aParams['oxuser__oxlname']."(".$aParams['oxuser__oxusername'].")<br /><br />";
00091 $sMessage .= nl2br( $sBody );
00092
00093 $oEmail = oxNew( 'oxemail' );
00094 if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
00095 $this->_blContactSendStatus = 1;
00096 }
00097 }
00098
00104 public function getUserData()
00105 {
00106 if ( $this->_oUserData === null ) {
00107 $this->_oUserData = oxConfig::getParameter( 'editval' );
00108 }
00109 return $this->_oUserData;
00110 }
00111
00117 public function getContactSubject()
00118 {
00119 if ( $this->_sContactSubject === null ) {
00120 $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
00121 }
00122 return $this->_sContactSubject;
00123 }
00124
00130 public function getContactMessage()
00131 {
00132 if ( $this->_sContactMessage === null ) {
00133 $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
00134 }
00135 return $this->_sContactMessage;
00136 }
00137
00143 public function getCaptcha()
00144 {
00145 if ( $this->_oCaptcha === null ) {
00146 $this->_oCaptcha = oxNew('oxCaptcha');
00147 }
00148 return $this->_oCaptcha;
00149 }
00150
00156 public function getContactSendStatus()
00157 {
00158 return $this->_blContactSendStatus;
00159 }
00160
00166 public function getBreadCrumb()
00167 {
00168 $aPaths = array();
00169 $aPath = array();
00170
00171 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_INFO_CONTACT_TITLECONTACT', oxLang::getInstance()->getBaseLanguage(), false );
00172 $aPath['link'] = $this->getLink();
00173 $aPaths[] = $aPath;
00174
00175 return $aPaths;
00176 }
00177 }