OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
contact.php
Go to the documentation of this file.
1 <?php
2 
10 class Contact extends oxUBase
11 {
16  protected $_aUserData = null;
17 
22  protected $_sContactSubject = null;
23 
28  protected $_sContactMessage = null;
29 
34  protected $_oCaptcha = null;
35 
40  protected $_blContactSendStatus = null;
41 
46  protected $_sThisTemplate = 'page/info/contact.tpl';
47 
54 
61  public function send()
62  {
63  $aParams = oxConfig::getParameter( 'editval' );
64 
65  // checking email address
66  if ( !oxRegistry::getUtils()->isValidEmail( $aParams['oxuser__oxusername'] ) ) {
67  oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_INPUT_NOVALIDEMAIL' );
68  return false;
69  }
70 
71  // spam spider prevension
72  $sMac = oxConfig::getParameter( 'c_mac' );
73  $sMacHash = oxConfig::getParameter( 'c_mach' );
74  $oCaptcha = $this->getCaptcha();
75 
76  if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
77  // even if there is no exception, use this as a default display method
78  oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'MESSAGE_WRONG_VERIFICATION_CODE' );
79  return false;
80  }
81 
82  $sSubject = oxConfig::getParameter( 'c_subject' );
83  if ( !$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject ) {
84  // even if there is no exception, use this as a default display method
85  oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_INPUT_NOTALLFIELDS' );
86  return false;
87  }
88 
89  $oLang = oxRegistry::getLang();
90  $sMessage = $oLang->translateString( 'MESSAGE_FROM' ) . " " .
91  $oLang->translateString( $aParams['oxuser__oxsal'] ) ." " .
92  $aParams['oxuser__oxfname'] . " " .
93  $aParams['oxuser__oxlname'] . "(" .$aParams['oxuser__oxusername'] . ")<br /><br />" .
94  nl2br( oxConfig::getParameter( 'c_message' ) );
95 
96  $oEmail = oxNew( 'oxemail' );
97  if ( $oEmail->sendContactMail( $aParams['oxuser__oxusername'], $sSubject, $sMessage ) ) {
98  $this->_blContactSendStatus = 1;
99  } else {
100  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
101  }
102  }
103 
109  public function getUserData()
110  {
111  if ( $this->_oUserData === null ) {
112  $this->_oUserData = oxConfig::getParameter( 'editval' );
113  }
114  return $this->_oUserData;
115  }
116 
122  public function getContactSubject()
123  {
124  if ( $this->_sContactSubject === null ) {
125  $this->_sContactSubject = oxConfig::getParameter( 'c_subject' );
126  }
128  }
129 
135  public function getContactMessage()
136  {
137  if ( $this->_sContactMessage === null ) {
138  $this->_sContactMessage = oxConfig::getParameter( 'c_message' );
139  }
141  }
142 
148  public function getCaptcha()
149  {
150  if ( $this->_oCaptcha === null ) {
151  $this->_oCaptcha = oxNew('oxCaptcha');
152  }
153  return $this->_oCaptcha;
154  }
155 
161  public function getContactSendStatus()
162  {
164  }
165 
171  public function getBreadCrumb()
172  {
173  $aPaths = array();
174  $aPath = array();
175 
176  $aPath['title'] = oxRegistry::getLang()->translateString( 'CONTACT', oxRegistry::getLang()->getBaseLanguage(), false );
177  $aPath['link'] = $this->getLink();
178  $aPaths[] = $aPath;
179 
180  return $aPaths;
181  }
182 }