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         // check if we have to set it here
00100         $oBasket = $this->getSession()->getBasket();
00101         foreach ( $oBasket->getContents() as $oBasketItem ) {
00102             if ( $this->_sWishId = $oBasketItem->getWishId() ) {
00103                 // stop on first found
00104                 break;
00105             }
00106         }
00107         return $this->_sWishId;
00108     }
00109 
00117     protected function _addFakeAddress( $oAddresses )
00118     {
00119         // generate selected no shipping address
00120         $oDefAddress = new oxStdClass();
00121         $oDefAddress->oxaddress__oxid = new oxStdClass();
00122         $oDefAddress->oxaddress__oxid->value    = -2;
00123 
00124         //T2009-08-19
00125         //deprecated part
00126         //no more fields are used in templates anymore
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     protected function _getActiveUser()
00144     {
00145         if ( $this->_oUser === null ) {
00146             $this->_oUser = false;
00147             if ( $oUser = $this->getUser() ) {
00148                 $this->_oUser = $oUser;
00149             }
00150         }
00151         return $this->_oUser;
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             // passing user chosen option value to display correct content
00192             $iOption = oxConfig::getParameter( 'option' );
00193             // if user chosen "Option 2"" - we should show user details only if he is authorized
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             // passing country list
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         // does nothing, used for compat with old templates, remove it
00275         // after removing old templates support
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                 // wishlist user address id
00293                 if ( $sWishId = $this->_getWishListId() ) {
00294                     // if user didn't click on button to hide
00295                     if ( $sWishId && oxSession::getVar( 'blshowshipaddress' ) === null ) {
00296                         // opening address field for wishlist address information
00297                         oxSession::setVar( 'blshowshipaddress', true );
00298                         $this->_blShowShipAddress = true;
00299                     }
00300                 }
00301             }
00302 
00303             if ( '-2' == $sAddressId ) {
00304                 // user decided to use paymetn address as delivery
00305                 oxSession::setVar( 'blshowshipaddress', 0 );
00306                 // unsetting delivery address
00307                 oxSession::deleteVar( 'deladdrid' );
00308                 $this->_blShowShipAddress = false;
00309             }
00310         }
00311 
00312         //if still not set then take it from session
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 }

Generated by  doxygen 1.6.2