OXID eShop CE  4.10.1
 All Classes Namespaces 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 
41  protected $_oCaptcha = null;
42 
48  protected $_blContactSendStatus = null;
49 
55  protected $_sThisTemplate = 'page/info/contact.tpl';
56 
63 
70  public function send()
71  {
72  $aParams = oxRegistry::getConfig()->getRequestParameter('editval');
73 
74  // checking email address
75  if (!oxRegistry::getUtils()->isValidEmail($aParams['oxuser__oxusername'])) {
76  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOVALIDEMAIL');
77 
78  return false;
79  }
80 
81  // spam spider prevension
82  $sMac = oxRegistry::getConfig()->getRequestParameter('c_mac');
83  $sMacHash = oxRegistry::getConfig()->getRequestParameter('c_mach');
84  $oCaptcha = $this->getCaptcha();
85 
86  if (!$oCaptcha->pass($sMac, $sMacHash)) {
87  // even if there is no exception, use this as a default display method
88  oxRegistry::get("oxUtilsView")->addErrorToDisplay('MESSAGE_WRONG_VERIFICATION_CODE');
89 
90  return false;
91  }
92 
93  $sSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
94  if (!$aParams['oxuser__oxfname'] || !$aParams['oxuser__oxlname'] || !$aParams['oxuser__oxusername'] || !$sSubject) {
95  // even if there is no exception, use this as a default display method
96  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_INPUT_NOTALLFIELDS');
97 
98  return false;
99  }
100 
101  $oLang = oxRegistry::getLang();
102  $sMessage = $oLang->translateString('MESSAGE_FROM') . " " .
103  $oLang->translateString($aParams['oxuser__oxsal']) . " " .
104  $aParams['oxuser__oxfname'] . " " .
105  $aParams['oxuser__oxlname'] . "(" . $aParams['oxuser__oxusername'] . ")<br /><br />" .
106  nl2br(oxRegistry::getConfig()->getRequestParameter('c_message'));
107 
108  $oEmail = oxNew('oxemail');
109  if ($oEmail->sendContactMail($aParams['oxuser__oxusername'], $sSubject, $sMessage)) {
110  $this->_blContactSendStatus = 1;
111  } else {
112  oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
113  }
114  }
115 
121  public function getUserData()
122  {
123  if ($this->_oUserData === null) {
124  $this->_oUserData = oxRegistry::getConfig()->getRequestParameter('editval');
125  }
126 
127  return $this->_oUserData;
128  }
129 
135  public function getContactSubject()
136  {
137  if ($this->_sContactSubject === null) {
138  $this->_sContactSubject = oxRegistry::getConfig()->getRequestParameter('c_subject');
139  }
140 
142  }
143 
149  public function getContactMessage()
150  {
151  if ($this->_sContactMessage === null) {
152  $this->_sContactMessage = oxRegistry::getConfig()->getRequestParameter('c_message');
153  }
154 
156  }
157 
165  public function getCaptcha()
166  {
167  if ($this->_oCaptcha === null) {
168  $this->_oCaptcha = oxNew('oxCaptcha');
169  }
170 
171  return $this->_oCaptcha;
172  }
173 
179  public function getContactSendStatus()
180  {
182  }
183 
189  public function getBreadCrumb()
190  {
191  $aPaths = array();
192  $aPath = array();
193 
194  $aPath['title'] = oxRegistry::getLang()->translateString('CONTACT', oxRegistry::getLang()->getBaseLanguage(), false);
195  $aPath['link'] = $this->getLink();
196  $aPaths[] = $aPath;
197 
198  return $aPaths;
199  }
200 
206  public function getTitle()
207  {
208  return $this->getConfig()->getActiveShop()->oxshops__oxcompany->value;
209  }
210 }