user.php
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
00065 public function render()
00066 {
00067 parent::render();
00068
00069 if ( $this->showShipAddress() && $oUser = $this->getUser()) {
00070 $this->getDelAddress();
00071 $this->_addFakeAddress( $oUser->getUserAddresses() );
00072 }
00073
00074 $this->_aViewData['blshowshipaddress'] = $this->showShipAddress();
00075 $this->_aViewData['delivadr'] = $this->getDelAddress();
00076 $this->_aViewData['blnewssubscribed'] = $this->isNewsSubscribed();
00077
00078 $this->_aViewData['order_remark'] = $this->getOrderRemark();
00079
00080 $this->_aViewData['oxcountrylist'] = $this->getCountryList();
00081
00082 $this->_aViewData['iOption'] = $this->getLoginOption();
00083
00084 $this->_aViewData['blshownoregopt'] = $this->getShowNoRegOption();
00085
00086 $this->_aViewData['aMustFillFields'] = $this->getMustFillFields();
00087
00088 return $this->_sThisTemplate;
00089 }
00090
00096 protected function _getWishListId()
00097 {
00098 $this->_sWishId = null;
00099
00100 $oBasket = $this->getSession()->getBasket();
00101 foreach ( $oBasket->getContents() as $oBasketItem ) {
00102 if ( $this->_sWishId = $oBasketItem->getWishId() ) {
00103
00104 break;
00105 }
00106 }
00107 return $this->_sWishId;
00108 }
00109
00117 protected function _addFakeAddress( $oAddresses )
00118 {
00119
00120 $oDefAddress = new oxStdClass();
00121 $oDefAddress->oxaddress__oxid = new oxStdClass();
00122 $oDefAddress->oxaddress__oxid->value = -2;
00123
00124
00125
00126
00127 $oDefAddress->oxaddress__oxfname = new oxStdClass();
00128 $oDefAddress->oxaddress__oxfname->value = '-';
00129 $oDefAddress->oxaddress__oxlname = new oxStdClass();
00130 $oDefAddress->oxaddress__oxlname->value = '-';
00131 $oDefAddress->oxaddress__oxcity = new oxStdClass();
00132 $oDefAddress->oxaddress__oxcity->value = '-';
00133
00134 $oAddresses->offsetSet( $oAddresses->count(), $oDefAddress );
00135 }
00136
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00159 protected function _getSelectedAddress()
00160 {
00161 if ( $this->_sSelectedAddress === null ) {
00162 $this->_sSelectedAddress = false;
00163 if ( $oUser = $this->getUser() ) {
00164 $this->_sSelectedAddress = $oUser->getSelectedAddress( $this->_getWishListId() );
00165 }
00166 }
00167 return $this->_sSelectedAddress;
00168 }
00169
00175 public function getShowNoRegOption()
00176 {
00177 if ( $this->_blShowNoRegOpt === null ) {
00178 $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam( 'blOrderDisWithoutReg' );
00179 }
00180 return $this->_blShowNoRegOpt;
00181 }
00182
00188 public function getLoginOption()
00189 {
00190 if ( $this->_iOption === null ) {
00191
00192 $iOption = oxConfig::getParameter( 'option' );
00193
00194 if ( $iOption == 2 && !$this->getUser() ) {
00195 $iOption = 0;
00196 }
00197 $this->_iOption = $iOption;
00198 }
00199 return $this->_iOption;
00200 }
00201
00207 public function getCountryList()
00208 {
00209 if ( $this->_oCountryList === null ) {
00210 $this->_oCountryList = false;
00211
00212 $oCountryList = oxNew( 'oxcountrylist' );
00213 $oCountryList->loadActiveCountries();
00214 if ( $oCountryList->count() ) {
00215 $this->_oCountryList = $oCountryList;
00216 }
00217 }
00218 return $this->_oCountryList;
00219 }
00220
00226 public function getOrderRemark()
00227 {
00228 if ( $this->_sOrderRemark === null ) {
00229 $this->_sOrderRemark = false;
00230 if ( $sOrderRemark = oxSession::getVar( 'ordrem' ) ) {
00231 $this->_sOrderRemark = oxConfig::checkSpecialChars( $sOrderRemark );
00232 } elseif ( $sOrderRemark = oxConfig::getParameter( 'order_remark' ) ) {
00233 $this->_sOrderRemark = $sOrderRemark;
00234 }
00235 }
00236 return $this->_sOrderRemark;
00237 }
00238
00244 public function isNewsSubscribed()
00245 {
00246 if ( $this->_blNewsSubscribed === null ) {
00247 $blNews = false;
00248 if ( ( $blNews = oxConfig::getParameter( 'blnewssubscribed' ) ) === null ) {
00249 $blNews = false;
00250 }
00251 if ( ( $oUser = $this->getUser() ) ) {
00252 $blNews = $oUser->getNewsSubscription()->getOptInStatus();
00253 }
00254 $this->_blNewsSubscribed = $blNews;
00255 }
00256
00257 if (is_null($this->_blNewsSubscribed))
00258 $this->_blNewsSubscribed = false;
00259
00260 return $this->_blNewsSubscribed;
00261 }
00262
00272 public function setShowShipAddress( $blShowShipAddress )
00273 {
00274
00275
00276 }
00277
00283 public function showShipAddress()
00284 {
00285
00286 if ( $this->_blShowShipAddress === null ) {
00287
00288 $sAddressId = (int) oxConfig::getParameter( 'oxaddressid' );
00289 $this->_blShowShipAddress = ( $sAddressId == -2 ) ? 0 : oxConfig::getParameter( 'blshowshipaddress' );
00290
00291 if ( ( $oUser = $this->getUser() ) ) {
00292
00293 if ( $sWishId = $this->_getWishListId() ) {
00294
00295 if ( $sWishId && oxSession::getVar( 'blshowshipaddress' ) === null ) {
00296
00297 oxSession::setVar( 'blshowshipaddress', true );
00298 $this->_blShowShipAddress = true;
00299 }
00300 }
00301 }
00302
00303 if ( '-2' == $sAddressId ) {
00304
00305 oxSession::setVar( 'blshowshipaddress', 0 );
00306
00307 oxSession::deleteVar( 'deladdrid' );
00308 $this->_blShowShipAddress = false;
00309 }
00310 }
00311
00312
00313 if ( $this->_blShowShipAddress === null ) {
00314 $this->_blShowShipAddress = oxSession::getVar( 'blshowshipaddress');
00315 }
00316
00317 if ( $this->_blShowShipAddress === null ) {
00318 $this->_blShowShipAddress = false;
00319 }
00320
00321 return $this->_blShowShipAddress;
00322 }
00323
00329 public function getDelAddress()
00330 {
00331 if ( $this->_oDelAddress === null ) {
00332 $this->_oDelAddress = false;
00333 if ( $this->showShipAddress() ) {
00334 $sAddressId = $this->_getSelectedAddress();
00335 if ( $sAddressId && $sAddressId != '-1' ) {
00336 $oAdress = oxNew( 'oxaddress' );
00337 if ( $oAdress->load( $sAddressId ) ) {
00338 $this->_oDelAddress = $oAdress;
00339 $this->_aViewData['deladr'] = null;
00340 }
00341 }
00342 }
00343 }
00344 return $this->_oDelAddress;
00345 }
00346
00347 }