OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
user.php
Go to the documentation of this file.
1 <?php
2 
7 class User extends oxUBase
8 {
13  protected $_sThisTemplate = 'page/checkout/user.tpl';
14 
19  protected $_blIsOrderStep = true;
20 
25  protected $_blShowNoRegOpt = null;
26 
31  protected $_sSelectedAddress = null;
32 
37  protected $_iOption = null;
38 
43  protected $_oCountryList = null;
44 
49  protected $_sOrderRemark = null;
50 
55  protected $_sWishId = null;
56 
57 
68  public function render()
69  {
70  $myConfig = $this->getConfig();
71 
72  if ( $this->getIsOrderStep() ) {
73  if ($myConfig->getConfigParam( 'blPsBasketReservationEnabled' )) {
74  $this->getSession()->getBasketReservations()->renewExpiration();
75  }
76 
77  $oBasket = $this->getSession()->getBasket();
78  if ( $this->_blIsOrderStep && $myConfig->getConfigParam( 'blPsBasketReservationEnabled' ) && (!$oBasket || ( $oBasket && !$oBasket->getProductsCount() )) ) {
79  oxRegistry::getUtils()->redirect( $myConfig->getShopHomeURL() .'cl=basket', true, 302 );
80  }
81  }
82 
84 
85  if ( $myConfig->getConfigParam( "bl_showFbConnect" ) && !$this->getUser() ) {
87  }
88 
89  return $this->_sThisTemplate;
90  }
91 
97  public function getShowNoRegOption()
98  {
99  if ( $this->_blShowNoRegOpt === null ) {
100  $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam( 'blOrderDisWithoutReg' );
101  }
102  return $this->_blShowNoRegOpt;
103  }
104 
110  public function getLoginOption()
111  {
112  if ( $this->_iOption === null ) {
113  // passing user chosen option value to display correct content
114  $iOption = oxConfig::getParameter( 'option' );
115  // if user chosen "Option 2"" - we should show user details only if he is authorized
116  if ( $iOption == 2 && !$this->getUser() ) {
117  $iOption = 0;
118  }
119  $this->_iOption = $iOption;
120  }
121  return $this->_iOption;
122  }
123 
129  public function getOrderRemark()
130  {
131  if ( $this->_sOrderRemark === null ) {
132  $sOrderRemark = false;
133  // if already connected, we can use the session
134  if ( $this->getUser() ) {
135  $sOrderRemark = oxSession::getVar( 'ordrem' );
136  } else {
137  // not connected so nowhere to save, we're gonna use what we get from post
138  $sOrderRemark = oxConfig::getParameter( 'order_remark', true );
139  }
140 
141  $this->_sOrderRemark = $sOrderRemark ? oxRegistry::getConfig()->checkParamSpecialChars( $sOrderRemark ) : false;
142  }
143  return $this->_sOrderRemark;
144  }
145 
151  public function isNewsSubscribed()
152  {
153  if ( $this->_blNewsSubscribed === null ) {
154  $blNews = false;
155  if ( ( $blNews = oxConfig::getParameter( 'blnewssubscribed' ) ) === null ) {
156  $blNews = false;
157  }
158  if ( ( $oUser = $this->getUser() ) ) {
159  $blNews = $oUser->getNewsSubscription()->getOptInStatus();
160  }
161  $this->_blNewsSubscribed = $blNews;
162  }
163 
164  if (is_null($this->_blNewsSubscribed))
165  $this->_blNewsSubscribed = false;
166 
168  }
169 
175  public function showShipAddress()
176  {
177  return oxSession::getVar( 'blshowshipaddress' );
178  }
179 
185  protected function _fillFormWithFacebookData()
186  {
187  // Create our Application instance.
188  $oFacebook = oxRegistry::get("oxFb");
189 
190  if ( $oFacebook->isConnected() ) {
191  $aMe = $oFacebook->api('/me');
192 
193  $aInvAdr = $this->getInvoiceAddress();
194  $sCharset = oxRegistry::getLang()->translateString( "charset" );
195 
196  // do not stop converting on error - just try to translit unknown symbols
197  $sCharset .= '//TRANSLIT';
198 
199  if ( !$aInvAdr["oxuser__oxfname"] ) {
200  $aInvAdr["oxuser__oxfname"] = iconv( 'UTF-8', $sCharset, $aMe["first_name"] );
201  }
202 
203  if ( !$aInvAdr["oxuser__oxlname"] ) {
204  $aInvAdr["oxuser__oxlname"] = iconv( 'UTF-8', $sCharset, $aMe["last_name"] );
205  }
206 
207  $this->setInvoiceAddress( $aInvAdr );
208  }
209  }
210 
216  public function modifyBillAddress()
217  {
218  return oxConfig::getParameter( 'blnewssubscribed' );
219  }
220 
226  public function getBreadCrumb()
227  {
228  $aPaths = array();
229  $aPath = array();
230 
231  $aPath['title'] = oxRegistry::getLang()->translateString( 'ADDRESS', oxRegistry::getLang()->getBaseLanguage(), false );
232  $aPath['link'] = $this->getLink();
233 
234  $aPaths[] = $aPath;
235 
236  return $aPaths;
237  }
238 
245  {
246  $oBasket = $this->getSession()->getBasket();
247  if ( $oBasket && $this->getConfig()->getConfigParam( "blEnableDownloads" ) ) {
248  if ( $oBasket->hasDownloadableProducts() ) {
249  return true;
250  }
251  }
252  return false;
253  }
254 }