contact.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class Contact extends oxUBase
00011 {
00012 
00018     protected $_aUserData = null;
00019 
00025     protected $_sContactSubject = null;
00026 
00032     protected $_sContactMessage = null;
00033 
00039     protected $_oCaptcha = null;
00040 
00046     protected $_blContactSendStatus = null;
00047 
00053     protected $_sThisTemplate = 'page/info/contact.tpl';
00054 
00060     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00061 
00068     public function send()
00069     {
00070         $aParams = oxRegistry::getConfig()->getRequestParameter('editval');
00071 
00072         // checking email address
00073         if (!oxRegistry::getUtils()->isValidEmail($aParams['oxuser__oxusername'])) {
00074             oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOVALIDEMAIL');
00075 
00076             return false;
00077         }
00078 
00079         // spam spider prevension
00080         $sMac = oxRegistry::getConfig()->getRequestParameter('c_mac');
00081         $sMacHash = oxRegistry::getConfig()->getRequestParameter('c_mach');
00082         $oCaptcha = $this->getCaptcha();
00083 
00084         if (!$oCaptcha->pass($sMac, $sMacHash)) {
00085             // even if there is no exception, use this as a default display method
00086             oxRegistry::get("oxUtilsView")->addErrorToDisplay('MESSAGE_WRONG_VERIFICATION_CODE');
00087 
00088             return false;
00089         }
00090 
00091         $sSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
00092         if (!$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject) {
00093             // even if there is no exception, use this as a default display method
00094             oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOTALLFIELDS');
00095 
00096             return false;
00097         }
00098 
00099         $oLang = oxRegistry::getLang();
00100         $sMessage = $oLang->translateString('MESSAGE_FROM') . " " .
00101                     $oLang->translateString($aParams['oxuser__oxsal']) . " " .
00102                     $aParams['oxuser__oxfname'] . " " .
00103                     $aParams['oxuser__oxlname'] . "(" . $aParams['oxuser__oxusername'] . ")<br /><br />" .
00104                     nl2br(oxRegistry::getConfig()->getRequestParameter('c_message'));
00105 
00106         $oEmail = oxNew('oxemail');
00107         if ($oEmail->sendContactMail($aParams['oxuser__oxusername'], $sSubject, $sMessage)) {
00108             $this->_blContactSendStatus = 1;
00109         } else {
00110             oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
00111         }
00112     }
00113 
00119     public function getUserData()
00120     {
00121         if ($this->_oUserData === null) {
00122             $this->_oUserData = oxRegistry::getConfig()->getRequestParameter('editval');
00123         }
00124 
00125         return $this->_oUserData;
00126     }
00127 
00133     public function getContactSubject()
00134     {
00135         if ($this->_sContactSubject === null) {
00136             $this->_sContactSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
00137         }
00138 
00139         return $this->_sContactSubject;
00140     }
00141 
00147     public function getContactMessage()
00148     {
00149         if ($this->_sContactMessage === null) {
00150             $this->_sContactMessage = oxRegistry::getConfig()->getRequestParameter('c_message');
00151         }
00152 
00153         return $this->_sContactMessage;
00154     }
00155 
00161     public function getCaptcha()
00162     {
00163         if ($this->_oCaptcha === null) {
00164             $this->_oCaptcha = oxNew('oxCaptcha');
00165         }
00166 
00167         return $this->_oCaptcha;
00168     }
00169 
00175     public function getContactSendStatus()
00176     {
00177         return $this->_blContactSendStatus;
00178     }
00179 
00185     public function getBreadCrumb()
00186     {
00187         $aPaths = array();
00188         $aPath = array();
00189 
00190         $aPath['title'] = oxRegistry::getLang()->translateString('CONTACT', oxRegistry::getLang()->getBaseLanguage(), false);
00191         $aPath['link'] = $this->getLink();
00192         $aPaths[] = $aPath;
00193 
00194         return $aPaths;
00195     }
00196 
00202     public function getTitle()
00203     {
00204         return $this->getConfig()->getActiveShop()->oxshops__oxcompany->value;
00205     }
00206 }