00001 <?php
00002
00007 class User extends oxUBase
00008 {
00013 protected $_sThisTemplate = 'user.tpl';
00014
00019 protected $_blIsOrderStep = true;
00020
00025 protected $_aMustFillFields = null;
00026
00031 protected $_blShowNoRegOpt = null;
00032
00037 protected $_sSelectedAddress = null;
00038
00043 protected $_iOption = null;
00044
00049 protected $_oCountryList = null;
00050
00055 protected $_sOrderRemark = null;
00056
00061 protected $_sWishId = null;
00062
00071 public function render()
00072 {
00073 parent::render();
00074
00075 if ( $this->showShipAddress() && $oUser = $this->getUser()) {
00076 $this->getDelAddress();
00077 $this->_addFakeAddress( $oUser->getUserAddresses() );
00078 }
00079
00080 $this->_aViewData['blshowshipaddress'] = $this->showShipAddress();
00081 $this->_aViewData['delivadr'] = $this->getDelAddress();
00082 $this->_aViewData['blnewssubscribed'] = $this->isNewsSubscribed();
00083
00084 $this->_aViewData['order_remark'] = $this->getOrderRemark();
00085
00086 $this->_aViewData['oxcountrylist'] = $this->getCountryList();
00087
00088 $this->_aViewData['iOption'] = $this->getLoginOption();
00089
00090 $this->_aViewData['blshownoregopt'] = $this->getShowNoRegOption();
00091
00092 $this->_aViewData['aMustFillFields'] = $this->getMustFillFields();
00093
00094 return $this->_sThisTemplate;
00095 }
00096
00102 protected function _getWishListId()
00103 {
00104 $this->_sWishId = null;
00105
00106 $oBasket = $this->getSession()->getBasket();
00107 foreach ( $oBasket->getContents() as $oBasketItem ) {
00108 if ( $this->_sWishId = $oBasketItem->getWishId() ) {
00109
00110 break;
00111 }
00112 }
00113 return $this->_sWishId;
00114 }
00115
00123 protected function _addFakeAddress( $oAddresses )
00124 {
00125
00126 $oDefAddress = new oxStdClass();
00127 $oDefAddress->oxaddress__oxid = new oxStdClass();
00128 $oDefAddress->oxaddress__oxid->value = -2;
00129
00130
00131
00132
00133 $oDefAddress->oxaddress__oxfname = new oxStdClass();
00134 $oDefAddress->oxaddress__oxfname->value = '-';
00135 $oDefAddress->oxaddress__oxlname = new oxStdClass();
00136 $oDefAddress->oxaddress__oxlname->value = '-';
00137 $oDefAddress->oxaddress__oxcity = new oxStdClass();
00138 $oDefAddress->oxaddress__oxcity->value = '-';
00139
00140 $oAddresses->offsetSet( $oAddresses->count(), $oDefAddress );
00141 }
00142
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00165 protected function _getSelectedAddress()
00166 {
00167 if ( $this->_sSelectedAddress === null ) {
00168 $this->_sSelectedAddress = false;
00169 if ( $oUser = $this->getUser() ) {
00170 $this->_sSelectedAddress = $oUser->getSelectedAddress( $this->_getWishListId() );
00171 }
00172 }
00173 return $this->_sSelectedAddress;
00174 }
00175
00181 public function getMustFillFields()
00182 {
00183
00184 if ( $this->_aMustFillFields === null ) {
00185 $this->_aMustFillFields = false;
00186 $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields');
00187 if ( is_array( $aMustFillFields ) ) {
00188 $this->_aMustFillFields = array_flip( $aMustFillFields );
00189 }
00190 }
00191 return $this->_aMustFillFields;
00192 }
00193
00199 public function getShowNoRegOption()
00200 {
00201 if ( $this->_blShowNoRegOpt === null ) {
00202 $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam( 'blOrderDisWithoutReg' );
00203 }
00204 return $this->_blShowNoRegOpt;
00205 }
00206
00212 public function getLoginOption()
00213 {
00214 if ( $this->_iOption === null ) {
00215
00216 $iOption = oxConfig::getParameter( 'option' );
00217
00218 if ( $iOption == 2 && !$this->getUser() ) {
00219 $iOption = 0;
00220 }
00221 $this->_iOption = $iOption;
00222 }
00223 return $this->_iOption;
00224 }
00225
00231 public function getCountryList()
00232 {
00233 if ( $this->_oCountryList === null ) {
00234 $this->_oCountryList = false;
00235
00236 $oCountryList = oxNew( 'oxcountrylist' );
00237 $oCountryList->loadActiveCountries();
00238 if ( $oCountryList->count() ) {
00239 $this->_oCountryList = $oCountryList;
00240 }
00241 }
00242 return $this->_oCountryList;
00243 }
00244
00250 public function getOrderRemark()
00251 {
00252 if ( $this->_sOrderRemark === null ) {
00253 $this->_sOrderRemark = false;
00254 if ( $sOrderRemark = oxSession::getVar( 'ordrem' ) ) {
00255 $this->_sOrderRemark = $sOrderRemark;
00256 } elseif ($sOrderRemark = oxConfig::getParameter( 'order_remark' )) {
00257 $this->_sOrderRemark = $sOrderRemark;
00258 }
00259 }
00260 return $this->_sOrderRemark;
00261 }
00262
00268 public function isNewsSubscribed()
00269 {
00270 if ( $this->_blNewsSubscribed === null ) {
00271 $blNews = false;
00272 if ( ( $blNews = oxConfig::getParameter( 'blnewssubscribed' ) ) === null ) {
00273 $blNews = true;
00274 }
00275 if ( ( $oUser = $this->getUser() ) ) {
00276 $blNews = $oUser->getNewsSubscription()->getOptInStatus();
00277 }
00278 $this->_blNewsSubscribed = $blNews;
00279 }
00280
00281 if (is_null($this->_blNewsSubscribed))
00282 $this->_blNewsSubscribed = false;
00283
00284 return $this->_blNewsSubscribed;
00285 }
00286
00296 public function setShowShipAddress( $blShowShipAddress )
00297 {
00298
00299
00300 }
00301
00307 public function showShipAddress()
00308 {
00309
00310 if ( $this->_blShowShipAddress === null ) {
00311
00312 $sAddressId = (int) oxConfig::getParameter( 'oxaddressid' );
00313 $this->_blShowShipAddress = ( $sAddressId == -2 ) ? 0 : oxConfig::getParameter( 'blshowshipaddress' );
00314
00315 if ( ( $oUser = $this->getUser() ) ) {
00316
00317 if ( $sWishId = $this->_getWishListId() ) {
00318
00319 if ( $sWishId && oxSession::getVar( 'blshowshipaddress' ) === null ) {
00320
00321 oxSession::setVar( 'blshowshipaddress', true );
00322 $this->_blShowShipAddress = true;
00323 }
00324 }
00325 }
00326
00327 if ( '-2' == $sAddressId ) {
00328
00329 oxSession::setVar( 'blshowshipaddress', 0 );
00330
00331 oxSession::deleteVar( 'deladdrid' );
00332 $this->_blShowShipAddress = false;
00333 }
00334 }
00335
00336
00337 if ( $this->_blShowShipAddress === null ) {
00338 $this->_blShowShipAddress = oxSession::getVar( 'blshowshipaddress');
00339 }
00340
00341 if ( $this->_blShowShipAddress === null ) {
00342 $this->_blShowShipAddress = false;
00343 }
00344
00345 return $this->_blShowShipAddress;
00346 }
00347
00353 public function getDelAddress()
00354 {
00355 if ( $this->_oDelAddress === null ) {
00356 $this->_oDelAddress = false;
00357 if ( $this->showShipAddress() ) {
00358 $sAddressId = $this->_getSelectedAddress();
00359 if ( $sAddressId && $sAddressId != '-1' ) {
00360 $oAdress = oxNew( 'oxbase' );
00361 $oAdress->init( 'oxaddress' );
00362 if ( $oAdress->load( $sAddressId ) ) {
00363 $this->_oDelAddress = $oAdress;
00364 }
00365 }
00366 }
00367 }
00368 return $this->_oDelAddress;
00369 }
00370
00371 }