OXID eShop CE  4.9.8
 All Classes Files Functions Variables Pages
user.php
Go to the documentation of this file.
1 <?php
2 
7 class User extends oxUBase
8 {
9 
15  protected $_sThisTemplate = 'page/checkout/user.tpl';
16 
22  protected $_blIsOrderStep = true;
23 
29  protected $_blShowNoRegOpt = null;
30 
36  protected $_sSelectedAddress = null;
37 
43  protected $_iOption = null;
44 
50  protected $_oCountryList = null;
51 
57  protected $_sOrderRemark = null;
58 
64  protected $_sWishId = null;
65 
66 
77  public function render()
78  {
79  $myConfig = $this->getConfig();
80 
81  if ($this->getIsOrderStep()) {
82  if ($myConfig->getConfigParam('blPsBasketReservationEnabled')) {
83  $this->getSession()->getBasketReservations()->renewExpiration();
84  }
85 
86  $oBasket = $this->getSession()->getBasket();
87  $blPsBasketReservationsEnabled = $myConfig->getConfigParam('blPsBasketReservationEnabled');
88  if ($this->_blIsOrderStep && $blPsBasketReservationsEnabled &&
89  (!$oBasket || ($oBasket && !$oBasket->getProductsCount()))) {
90  oxRegistry::getUtils()->redirect($myConfig->getShopHomeURL() . 'cl=basket', true, 302);
91  }
92  }
93 
95 
96  if ($myConfig->getConfigParam("bl_showFbConnect") && !$this->getUser()) {
98  }
99 
100  return $this->_sThisTemplate;
101  }
102 
108  public function getShowNoRegOption()
109  {
110  if ($this->_blShowNoRegOpt === null) {
111  $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam('blOrderDisWithoutReg');
112  }
113 
114  return $this->_blShowNoRegOpt;
115  }
116 
122  public function getLoginOption()
123  {
124  if ($this->_iOption === null) {
125  // passing user chosen option value to display correct content
126  $iOption = oxRegistry::getConfig()->getRequestParameter('option');
127  // if user chosen "Option 2"" - we should show user details only if he is authorized
128  if ($iOption == 2 && !$this->getUser()) {
129  $iOption = 0;
130  }
131  $this->_iOption = $iOption;
132  }
133 
134  return $this->_iOption;
135  }
136 
142  public function getOrderRemark()
143  {
144  $oConfig = oxRegistry::getConfig();
145  if ($this->_sOrderRemark === null) {
146  $sOrderRemark = false;
147  // if already connected, we can use the session
148  if ($this->getUser()) {
149  $sOrderRemark = oxRegistry::getSession()->getVariable('ordrem');
150  } else {
151  // not connected so nowhere to save, we're gonna use what we get from post
152  $sOrderRemark = $oConfig->getRequestParameter('order_remark', true);
153  }
154 
155  $this->_sOrderRemark = $sOrderRemark ? $oConfig->checkParamSpecialChars($sOrderRemark) : false;
156  }
157 
158  return $this->_sOrderRemark;
159  }
160 
166  public function isNewsSubscribed()
167  {
168  if ($this->_blNewsSubscribed === null) {
169  $blNews = false;
170  if (($blNews = oxRegistry::getConfig()->getRequestParameter('blnewssubscribed')) === null) {
171  $blNews = false;
172  }
173  if (($oUser = $this->getUser())) {
174  $blNews = $oUser->getNewsSubscription()->getOptInStatus();
175  }
176  $this->_blNewsSubscribed = $blNews;
177  }
178 
179  if (is_null($this->_blNewsSubscribed)) {
180  $this->_blNewsSubscribed = false;
181  }
182 
184  }
185 
191  public function showShipAddress()
192  {
193  return oxRegistry::getSession()->getVariable('blshowshipaddress');
194  }
195 
199  protected function _fillFormWithFacebookData()
200  {
201  // Create our Application instance.
202  $oFacebook = oxRegistry::get("oxFb");
203 
204  if ($oFacebook->isConnected()) {
205  $aMe = $oFacebook->api('/me');
206 
207  $aInvAdr = $this->getInvoiceAddress();
208  $sCharset = oxRegistry::getLang()->translateString("charset");
209 
210  // do not stop converting on error - just try to translit unknown symbols
211  $sCharset .= '//TRANSLIT';
212 
213  if (!$aInvAdr["oxuser__oxfname"]) {
214  $aInvAdr["oxuser__oxfname"] = iconv('UTF-8', $sCharset, $aMe["first_name"]);
215  }
216 
217  if (!$aInvAdr["oxuser__oxlname"]) {
218  $aInvAdr["oxuser__oxlname"] = iconv('UTF-8', $sCharset, $aMe["last_name"]);
219  }
220 
221  $this->setInvoiceAddress($aInvAdr);
222  }
223  }
224 
230  public function modifyBillAddress()
231  {
232  return oxRegistry::getConfig()->getRequestParameter('blnewssubscribed');
233  }
234 
240  public function getBreadCrumb()
241  {
242  $aPaths = array();
243  $aPath = array();
244 
245  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
246  $aPath['title'] = oxRegistry::getLang()->translateString('ADDRESS', $iBaseLanguage, false);
247  $aPath['link'] = $this->getLink();
248 
249  $aPaths[] = $aPath;
250 
251  return $aPaths;
252  }
253 
260  {
261  $oBasket = $this->getSession()->getBasket();
262  if ($oBasket && $this->getConfig()->getConfigParam("blEnableDownloads")) {
263  if ($oBasket->hasDownloadableProducts()) {
264  return true;
265  }
266  }
267 
268  return false;
269  }
270 }