OXID eShop CE  4.10.8
 All Classes Namespaces 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  // @deprecated since v5.3 (2016-05-20); Facebook will be extracted into module.
97  if ($myConfig->getConfigParam("bl_showFbConnect") && !$this->getUser()) {
99  }
100  // END deprecated
101 
102  return $this->_sThisTemplate;
103  }
104 
110  public function getShowNoRegOption()
111  {
112  if ($this->_blShowNoRegOpt === null) {
113  $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam('blOrderDisWithoutReg');
114  }
115 
116  return $this->_blShowNoRegOpt;
117  }
118 
124  public function getLoginOption()
125  {
126  if ($this->_iOption === null) {
127  // passing user chosen option value to display correct content
128  $iOption = oxRegistry::getConfig()->getRequestParameter('option');
129  // if user chosen "Option 2"" - we should show user details only if he is authorized
130  if ($iOption == 2 && !$this->getUser()) {
131  $iOption = 0;
132  }
133  $this->_iOption = $iOption;
134  }
135 
136  return $this->_iOption;
137  }
138 
144  public function getOrderRemark()
145  {
146  $oConfig = oxRegistry::getConfig();
147  if ($this->_sOrderRemark === null) {
148  $sOrderRemark = false;
149  // if already connected, we can use the session
150  if ($this->getUser()) {
151  $sOrderRemark = oxRegistry::getSession()->getVariable('ordrem');
152  } else {
153  // not connected so nowhere to save, we're gonna use what we get from post
154  $sOrderRemark = $oConfig->getRequestParameter('order_remark', true);
155  }
156 
157  $this->_sOrderRemark = $sOrderRemark ? $oConfig->checkParamSpecialChars($sOrderRemark) : false;
158  }
159 
160  return $this->_sOrderRemark;
161  }
162 
168  public function isNewsSubscribed()
169  {
170  if ($this->_blNewsSubscribed === null) {
171  $blNews = false;
172  if (($blNews = oxRegistry::getConfig()->getRequestParameter('blnewssubscribed')) === null) {
173  $blNews = false;
174  }
175  if (($oUser = $this->getUser())) {
176  $blNews = $oUser->getNewsSubscription()->getOptInStatus();
177  }
178  $this->_blNewsSubscribed = $blNews;
179  }
180 
181  if (is_null($this->_blNewsSubscribed)) {
182  $this->_blNewsSubscribed = false;
183  }
184 
186  }
187 
193  public function showShipAddress()
194  {
195  return oxRegistry::getSession()->getVariable('blshowshipaddress');
196  }
197 
203  protected function _fillFormWithFacebookData()
204  {
205  // Create our Application instance.
206  $oFacebook = oxRegistry::get("oxFb");
207 
208  if ($oFacebook->isConnected()) {
209  $aMe = $oFacebook->api('/me');
210 
211  $aInvAdr = $this->getInvoiceAddress();
212  $sCharset = oxRegistry::getLang()->translateString("charset");
213 
214  // do not stop converting on error - just try to translit unknown symbols
215  $sCharset .= '//TRANSLIT';
216 
217  if (!$aInvAdr["oxuser__oxfname"]) {
218  $aInvAdr["oxuser__oxfname"] = iconv('UTF-8', $sCharset, $aMe["first_name"]);
219  }
220 
221  if (!$aInvAdr["oxuser__oxlname"]) {
222  $aInvAdr["oxuser__oxlname"] = iconv('UTF-8', $sCharset, $aMe["last_name"]);
223  }
224 
225  $this->setInvoiceAddress($aInvAdr);
226  }
227  }
228 
234  public function modifyBillAddress()
235  {
236  return oxRegistry::getConfig()->getRequestParameter('blnewssubscribed');
237  }
238 
244  public function getBreadCrumb()
245  {
246  $aPaths = array();
247  $aPath = array();
248 
249  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
250  $aPath['title'] = oxRegistry::getLang()->translateString('ADDRESS', $iBaseLanguage, false);
251  $aPath['link'] = $this->getLink();
252 
253  $aPaths[] = $aPath;
254 
255  return $aPaths;
256  }
257 
264  {
265  $oBasket = $this->getSession()->getBasket();
266  if ($oBasket && $this->getConfig()->getConfigParam("blEnableDownloads")) {
267  if ($oBasket->hasDownloadableProducts()) {
268  return true;
269  }
270  }
271 
272  return false;
273  }
274 }