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 = 'page/info/contact.tpl';
00047 
00053     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00054 
00061     public function send()
00062     {
00063         $aParams = oxConfig::getParameter( 'editval' );
00064 
00065         // checking email address
00066         if ( !oxRegistry::getUtils()->isValidEmail( $aParams['oxuser__oxusername'] ) ) {
00067             oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_INPUT_NOVALIDEMAIL' );
00068             return false;
00069         }
00070 
00071         // spam spider prevension
00072         $sMac     = oxConfig::getParameter( 'c_mac' );
00073         $sMacHash = oxConfig::getParameter( 'c_mach' );
00074         $oCaptcha = $this->getCaptcha();
00075 
00076         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
00077             // even if there is no exception, use this as a default display method
00078             oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'MESSAGE_WRONG_VERIFICATION_CODE' );
00079             return false;
00080         }
00081 
00082         $sSubject = oxConfig::getParameter( 'c_subject' );
00083         if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
00084             // even if there is no exception, use this as a default display method
00085             oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_INPUT_NOTALLFIELDS' );
00086             return false;
00087         }
00088 
00089         $oLang = oxRegistry::getLang();
00090         $sMessage  = $oLang->translateString( 'MESSAGE_FROM' ) . " " .
00091                      $oLang->translateString( $aParams['oxuser__oxsal'] ) ." " .
00092                      $aParams['oxuser__oxfname'] . " " .
00093                      $aParams['oxuser__oxlname'] . "(" .$aParams['oxuser__oxusername'] . ")<br /><br />" .
00094                      nl2br( oxConfig::getParameter( 'c_message' ) );
00095 
00096         $oEmail = oxNew( 'oxemail' );
00097         if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
00098             $this->_blContactSendStatus = 1;
00099         } else {
00100             oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
00101         }
00102     }
00103 
00109     public function getUserData()
00110     {
00111         if ( $this->_oUserData === null ) {
00112             $this->_oUserData = oxConfig::getParameter( 'editval' );
00113         }
00114         return $this->_oUserData;
00115     }
00116 
00122     public function getContactSubject()
00123     {
00124         if ( $this->_sContactSubject === null ) {
00125             $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
00126         }
00127         return $this->_sContactSubject;
00128     }
00129 
00135     public function getContactMessage()
00136     {
00137         if ( $this->_sContactMessage === null ) {
00138             $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
00139         }
00140         return $this->_sContactMessage;
00141     }
00142 
00148     public function getCaptcha()
00149     {
00150         if ( $this->_oCaptcha === null ) {
00151             $this->_oCaptcha = oxNew('oxCaptcha');
00152         }
00153         return $this->_oCaptcha;
00154     }
00155 
00161     public function getContactSendStatus()
00162     {
00163         return $this->_blContactSendStatus;
00164     }
00165 
00171     public function getBreadCrumb()
00172     {
00173         $aPaths = array();
00174         $aPath = array();
00175 
00176         $aPath['title'] = oxRegistry::getLang()->translateString( 'CONTACT', oxRegistry::getLang()->getBaseLanguage(), false );
00177         $aPath['link']  = $this->getLink();
00178         $aPaths[] = $aPath;
00179 
00180         return $aPaths;
00181     }
00182 }