Go to the documentation of this file.00001 <?php
00002
00007 class User extends oxUBase
00008 {
00013 protected $_sThisTemplate = 'user.tpl';
00014
00019 protected $_blIsOrderStep = true;
00020
00025 protected $_blShowNoRegOpt = null;
00026
00031 protected $_sSelectedAddress = null;
00032
00037 protected $_iOption = null;
00038
00043 protected $_oCountryList = null;
00044
00049 protected $_sOrderRemark = null;
00050
00055 protected $_sWishId = null;
00056
00067 public function render()
00068 {
00069 $myConfig = $this->getConfig();
00070 if ($myConfig->getConfigParam( 'blPsBasketReservationEnabled' )) {
00071 $this->getSession()->getBasketReservations()->renewExpiration();
00072 }
00073
00074 $oBasket = $this->getSession()->getBasket();
00075 if ( $myConfig->getConfigParam( 'blPsBasketReservationEnabled' ) && (!$oBasket || ( $oBasket && !$oBasket->getProductsCount() )) ) {
00076 oxUtils::getInstance()->redirect( $myConfig->getShopHomeURL() .'cl=basket' );
00077 }
00078
00079 parent::render();
00080
00081 if ( $this->showShipAddress() && $oUser = $this->getUser()) {
00082 $this->getDelAddress();
00083 $this->_addFakeAddress( $oUser->getUserAddresses() );
00084 }
00085
00086 $this->_aViewData['blshowshipaddress'] = $this->showShipAddress();
00087 $this->_aViewData['delivadr'] = $this->getDelAddress();
00088 $this->_aViewData['blnewssubscribed'] = $this->isNewsSubscribed();
00089
00090 $this->_aViewData['order_remark'] = $this->getOrderRemark();
00091
00092 $this->_aViewData['oxcountrylist'] = $this->getCountryList();
00093
00094 $this->_aViewData['iOption'] = $this->getLoginOption();
00095
00096 $this->_aViewData['blshownoregopt'] = $this->getShowNoRegOption();
00097
00098 $this->_aViewData['aMustFillFields'] = $this->getMustFillFields();
00099
00100 if ( $myConfig->getConfigParam( "bl_showFbConnect" ) && !$this->getUser() ) {
00101 $this->_fillFormWithFacebookData();
00102 }
00103
00104 return $this->_sThisTemplate;
00105 }
00106
00112 protected function _getWishListId()
00113 {
00114 $this->_sWishId = null;
00115
00116 $oBasket = $this->getSession()->getBasket();
00117 foreach ( $oBasket->getContents() as $oBasketItem ) {
00118 if ( $this->_sWishId = $oBasketItem->getWishId() ) {
00119
00120 break;
00121 }
00122 }
00123 return $this->_sWishId;
00124 }
00125
00133 protected function _addFakeAddress( $oAddresses )
00134 {
00135
00136 $oDefAddress = new oxStdClass();
00137 $oDefAddress->oxaddress__oxid = new oxStdClass();
00138 $oDefAddress->oxaddress__oxid->value = -2;
00139
00140
00141
00142
00143 $oDefAddress->oxaddress__oxfname = new oxStdClass();
00144 $oDefAddress->oxaddress__oxfname->value = '-';
00145 $oDefAddress->oxaddress__oxlname = new oxStdClass();
00146 $oDefAddress->oxaddress__oxlname->value = '-';
00147 $oDefAddress->oxaddress__oxcity = new oxStdClass();
00148 $oDefAddress->oxaddress__oxcity->value = '-';
00149
00150 $oAddresses->offsetSet( $oAddresses->count(), $oDefAddress );
00151 }
00152
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00175 protected function _getSelectedAddress()
00176 {
00177 if ( $this->_sSelectedAddress === null ) {
00178 $this->_sSelectedAddress = false;
00179 if ( $oUser = $this->getUser() ) {
00180 $this->_sSelectedAddress = $oUser->getSelectedAddress( $this->_getWishListId() );
00181 }
00182 }
00183 return $this->_sSelectedAddress;
00184 }
00185
00191 public function getShowNoRegOption()
00192 {
00193 if ( $this->_blShowNoRegOpt === null ) {
00194 $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam( 'blOrderDisWithoutReg' );
00195 }
00196 return $this->_blShowNoRegOpt;
00197 }
00198
00204 public function getLoginOption()
00205 {
00206 if ( $this->_iOption === null ) {
00207
00208 $iOption = oxConfig::getParameter( 'option' );
00209
00210 if ( $iOption == 2 && !$this->getUser() ) {
00211 $iOption = 0;
00212 }
00213 $this->_iOption = $iOption;
00214 }
00215 return $this->_iOption;
00216 }
00217
00223 public function getCountryList()
00224 {
00225 if ( $this->_oCountryList === null ) {
00226 $this->_oCountryList = false;
00227
00228 $oCountryList = oxNew( 'oxcountrylist' );
00229 $oCountryList->loadActiveCountries();
00230 if ( $oCountryList->count() ) {
00231 $this->_oCountryList = $oCountryList;
00232 }
00233 }
00234 return $this->_oCountryList;
00235 }
00236
00242 public function getOrderRemark()
00243 {
00244 if ( $this->_sOrderRemark === null ) {
00245 $this->_sOrderRemark = false;
00246 if ( $sOrderRemark = oxSession::getVar( 'ordrem' ) ) {
00247 $this->_sOrderRemark = oxConfig::checkSpecialChars( $sOrderRemark );
00248 } elseif ( $sOrderRemark = oxConfig::getParameter( 'order_remark' ) ) {
00249 $this->_sOrderRemark = $sOrderRemark;
00250 }
00251 }
00252 return $this->_sOrderRemark;
00253 }
00254
00260 public function isNewsSubscribed()
00261 {
00262 if ( $this->_blNewsSubscribed === null ) {
00263 $blNews = false;
00264 if ( ( $blNews = oxConfig::getParameter( 'blnewssubscribed' ) ) === null ) {
00265 $blNews = false;
00266 }
00267 if ( ( $oUser = $this->getUser() ) ) {
00268 $blNews = $oUser->getNewsSubscription()->getOptInStatus();
00269 }
00270 $this->_blNewsSubscribed = $blNews;
00271 }
00272
00273 if (is_null($this->_blNewsSubscribed))
00274 $this->_blNewsSubscribed = false;
00275
00276 return $this->_blNewsSubscribed;
00277 }
00278
00288 public function setShowShipAddress( $blShowShipAddress )
00289 {
00290
00291
00292 }
00293
00299 public function showShipAddress()
00300 {
00301
00302 if ( $this->_blShowShipAddress === null ) {
00303
00304 $sAddressId = (int) oxConfig::getParameter( 'oxaddressid' );
00305 $this->_blShowShipAddress = ( $sAddressId == -2 ) ? 0 : oxConfig::getParameter( 'blshowshipaddress' );
00306
00307 if ( ( $oUser = $this->getUser() ) ) {
00308
00309 if ( $sWishId = $this->_getWishListId() ) {
00310
00311 if ( $sWishId && oxSession::getVar( 'blshowshipaddress' ) === null ) {
00312
00313 oxSession::setVar( 'blshowshipaddress', true );
00314 $this->_blShowShipAddress = true;
00315 }
00316 }
00317 }
00318
00319 if ( '-2' == $sAddressId ) {
00320
00321 oxSession::setVar( 'blshowshipaddress', 0 );
00322
00323 $this->_blShowShipAddress = false;
00324 }
00325 }
00326
00327
00328 if ( $this->_blShowShipAddress === null ) {
00329 $this->_blShowShipAddress = oxSession::getVar( 'blshowshipaddress');
00330 }
00331
00332 if ( $this->_blShowShipAddress === null ) {
00333 $this->_blShowShipAddress = false;
00334 }
00335
00336 return $this->_blShowShipAddress;
00337 }
00338
00344 public function getDelAddress()
00345 {
00346 if ( $this->_oDelAddress === null ) {
00347 $this->_oDelAddress = false;
00348 if ( $this->showShipAddress() ) {
00349 $sAddressId = $this->_getSelectedAddress();
00350 if ( $sAddressId && $sAddressId != '-1' ) {
00351 $oAdress = oxNew( 'oxaddress' );
00352 if ( $oAdress->load( $sAddressId ) ) {
00353 $this->_oDelAddress = $oAdress;
00354 $this->_aViewData['deladr'] = null;
00355 }
00356 }
00357 }
00358 }
00359 return $this->_oDelAddress;
00360 }
00361
00367 protected function _fillFormWithFacebookData()
00368 {
00369
00370 $oFacebook = oxFb::getInstance();
00371
00372 if ( $oFacebook->isConnected() ) {
00373 $aMe = $oFacebook->api('/me');
00374
00375 $aInvAdr = $this->_aViewData['invadr'];
00376
00377 if ( !$aInvAdr["oxuser__oxfname"] ) {
00378 $aInvAdr["oxuser__oxfname"] = $aMe["first_name"];
00379 }
00380
00381 if ( !$aInvAdr["oxuser__oxlname"] ) {
00382 $aInvAdr["oxuser__oxlname"] = $aMe["last_name"];
00383 }
00384
00385 $this->_aViewData['invadr'] = $aInvAdr;
00386 }
00387 }
00388 }