user.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class User extends oxUBase
00008 {
00013     protected $_sThisTemplate = 'page/checkout/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 
00071         if ( $this->getIsOrderStep() ) {
00072             if ($myConfig->getConfigParam( 'blPsBasketReservationEnabled' )) {
00073                 $this->getSession()->getBasketReservations()->renewExpiration();
00074             }
00075 
00076             $oBasket = $this->getSession()->getBasket();
00077             if ( $this->_blIsOrderStep && $myConfig->getConfigParam( 'blPsBasketReservationEnabled' ) && (!$oBasket || ( $oBasket && !$oBasket->getProductsCount() )) ) {
00078                 oxUtils::getInstance()->redirect( $myConfig->getShopHomeURL() .'cl=basket', true, 302 );
00079             }
00080         }
00081 
00082         parent::render();
00083 
00084         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) && !$this->getUser() ) {
00085              $this->_fillFormWithFacebookData();
00086         }
00087 
00088         return $this->_sThisTemplate;
00089     }
00090 
00096     public function getShowNoRegOption()
00097     {
00098         if ( $this->_blShowNoRegOpt === null ) {
00099             $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam( 'blOrderDisWithoutReg' );
00100         }
00101         return $this->_blShowNoRegOpt;
00102     }
00103 
00109     public function getLoginOption()
00110     {
00111         if ( $this->_iOption === null ) {
00112             // passing user chosen option value to display correct content
00113             $iOption = oxConfig::getParameter( 'option' );
00114             // if user chosen "Option 2"" - we should show user details only if he is authorized
00115             if ( $iOption == 2 && !$this->getUser() ) {
00116                 $iOption = 0;
00117             }
00118             $this->_iOption = $iOption;
00119         }
00120         return $this->_iOption;
00121     }
00122 
00130     public function getCountryList()
00131     {
00132         if ( $this->_oCountryList === null ) {
00133             $this->_oCountryList = false;
00134             // passing country list
00135             $oCountryList = oxNew( 'oxcountrylist' );
00136             $oCountryList->loadActiveCountries();
00137             if ( $oCountryList->count() ) {
00138                 $this->_oCountryList = $oCountryList;
00139             }
00140         }
00141         return $this->_oCountryList;
00142     }
00143 
00149     public function getOrderRemark()
00150     {
00151         if ( $this->_sOrderRemark === null ) {
00152             $sOrderRemark = false;
00153             // if already connected, we can use the session
00154             if ( $this->getUser() ) {
00155                 $sOrderRemark = oxSession::getVar( 'ordrem' );
00156             } else {
00157                 // not connected so nowhere to save, we're gonna use what we get from post
00158                 $sOrderRemark = oxConfig::getParameter( 'order_remark', true );
00159             }
00160 
00161             $this->_sOrderRemark = $sOrderRemark ? oxConfig::checkSpecialChars( $sOrderRemark ) : false;
00162         }
00163         return $this->_sOrderRemark;
00164     }
00165 
00171     public function isNewsSubscribed()
00172     {
00173         if ( $this->_blNewsSubscribed === null ) {
00174             $blNews = false;
00175             if ( ( $blNews = oxConfig::getParameter( 'blnewssubscribed' ) ) === null ) {
00176                 $blNews = false;
00177             }
00178             if ( ( $oUser = $this->getUser() ) ) {
00179                 $blNews = $oUser->getNewsSubscription()->getOptInStatus();
00180             }
00181             $this->_blNewsSubscribed = $blNews;
00182         }
00183 
00184         if (is_null($this->_blNewsSubscribed))
00185             $this->_blNewsSubscribed = false;
00186 
00187         return  $this->_blNewsSubscribed;
00188     }
00189 
00195     public function showShipAddress()
00196     {
00197         return oxSession::getVar( 'blshowshipaddress' );
00198     }
00199 
00205     protected function _fillFormWithFacebookData()
00206     {
00207         // Create our Application instance.
00208         $oFacebook = oxFb::getInstance();
00209 
00210         if ( $oFacebook->isConnected() ) {
00211             $aMe  = $oFacebook->api('/me');
00212 
00213             $aInvAdr = $this->getInvoiceAddress();
00214             $sCharset = oxLang::getInstance()->translateString( "charset" );
00215 
00216             // do not stop converting on error - just try to translit unknown symbols
00217             $sCharset .= '//TRANSLIT';
00218 
00219             if ( !$aInvAdr["oxuser__oxfname"] ) {
00220                 $aInvAdr["oxuser__oxfname"] = iconv( 'UTF-8', $sCharset, $aMe["first_name"] );
00221             }
00222 
00223             if ( !$aInvAdr["oxuser__oxlname"] ) {
00224                 $aInvAdr["oxuser__oxlname"] = iconv( 'UTF-8', $sCharset, $aMe["last_name"] );
00225             }
00226 
00227             $this->setInvoiceAddress( $aInvAdr );
00228         }
00229     }
00230 
00236     public function modifyBillAddress()
00237     {
00238         return oxConfig::getParameter( 'blnewssubscribed' );
00239     }
00240 
00246     public function getBreadCrumb()
00247     {
00248         $aPaths = array();
00249         $aPath = array();
00250 
00251         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_CHECKOUT_USER', oxLang::getInstance()->getBaseLanguage(), false );
00252         $aPath['link']  = $this->getLink();
00253 
00254         $aPaths[] = $aPath;
00255 
00256         return $aPaths;
00257     }
00258 }