OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
contact.php
Go to the documentation of this file.
1 <?php
2 
10 class Contact extends oxUBase
11 {
12 
18  protected $_aUserData = null;
19 
25  protected $_sContactSubject = null;
26 
32  protected $_sContactMessage = null;
33 
39  protected $_oCaptcha = null;
40 
46  protected $_blContactSendStatus = null;
47 
53  protected $_sThisTemplate = 'page/info/contact.tpl';
54 
61 
68  public function send()
69  {
70  $aParams = oxRegistry::getConfig()->getRequestParameter('editval');
71 
72  // checking email address
73  if (!oxRegistry::getUtils()->isValidEmail($aParams['oxuser__oxusername'])) {
74  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOVALIDEMAIL');
75 
76  return false;
77  }
78 
79  // spam spider prevension
80  $sMac = oxRegistry::getConfig()->getRequestParameter('c_mac');
81  $sMacHash = oxRegistry::getConfig()->getRequestParameter('c_mach');
82  $oCaptcha = $this->getCaptcha();
83 
84  if (!$oCaptcha->pass($sMac, $sMacHash)) {
85  // even if there is no exception, use this as a default display method
86  oxRegistry::get("oxUtilsView")->addErrorToDisplay('MESSAGE_WRONG_VERIFICATION_CODE');
87 
88  return false;
89  }
90 
91  $sSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
92  if (!$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject) {
93  // even if there is no exception, use this as a default display method
94  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOTALLFIELDS');
95 
96  return false;
97  }
98 
99  $oLang = oxRegistry::getLang();
100  $sMessage = $oLang->translateString('MESSAGE_FROM') . " " .
101  $oLang->translateString($aParams['oxuser__oxsal']) . " " .
102  $aParams['oxuser__oxfname'] . " " .
103  $aParams['oxuser__oxlname'] . "(" . $aParams['oxuser__oxusername'] . ")<br /><br />" .
104  nl2br(oxRegistry::getConfig()->getRequestParameter('c_message'));
105 
106  $oEmail = oxNew('oxemail');
107  if ($oEmail->sendContactMail($aParams['oxuser__oxusername'], $sSubject, $sMessage)) {
108  $this->_blContactSendStatus = 1;
109  } else {
110  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
111  }
112  }
113 
119  public function getUserData()
120  {
121  if ($this->_oUserData === null) {
122  $this->_oUserData = oxRegistry::getConfig()->getRequestParameter('editval');
123  }
124 
125  return $this->_oUserData;
126  }
127 
133  public function getContactSubject()
134  {
135  if ($this->_sContactSubject === null) {
136  $this->_sContactSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
137  }
138 
140  }
141 
147  public function getContactMessage()
148  {
149  if ($this->_sContactMessage === null) {
150  $this->_sContactMessage = oxRegistry::getConfig()->getRequestParameter('c_message');
151  }
152 
154  }
155 
161  public function getCaptcha()
162  {
163  if ($this->_oCaptcha === null) {
164  $this->_oCaptcha = oxNew('oxCaptcha');
165  }
166 
167  return $this->_oCaptcha;
168  }
169 
175  public function getContactSendStatus()
176  {
178  }
179 
185  public function getBreadCrumb()
186  {
187  $aPaths = array();
188  $aPath = array();
189 
190  $aPath['title'] = oxRegistry::getLang()->translateString('CONTACT', oxRegistry::getLang()->getBaseLanguage(), false);
191  $aPath['link'] = $this->getLink();
192  $aPaths[] = $aPath;
193 
194  return $aPaths;
195  }
196 
202  public function getTitle()
203  {
204  return $this->getConfig()->getActiveShop()->oxshops__oxcompany->value;
205  }
206 }