user.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class User extends oxUBase
00008 {
00009 
00015     protected $_sThisTemplate = 'page/checkout/user.tpl';
00016 
00022     protected $_blIsOrderStep = true;
00023 
00029     protected $_blShowNoRegOpt = null;
00030 
00036     protected $_sSelectedAddress = null;
00037 
00043     protected $_iOption = null;
00044 
00050     protected $_oCountryList = null;
00051 
00057     protected $_sOrderRemark = null;
00058 
00064     protected $_sWishId = null;
00065 
00066 
00077     public function render()
00078     {
00079         $myConfig = $this->getConfig();
00080 
00081         if ($this->getIsOrderStep()) {
00082             if ($myConfig->getConfigParam('blPsBasketReservationEnabled')) {
00083                 $this->getSession()->getBasketReservations()->renewExpiration();
00084             }
00085 
00086             $oBasket = $this->getSession()->getBasket();
00087             $blPsBasketReservationsEnabled = $myConfig->getConfigParam('blPsBasketReservationEnabled');
00088             if ($this->_blIsOrderStep && $blPsBasketReservationsEnabled &&
00089                 (!$oBasket || ($oBasket && !$oBasket->getProductsCount()))) {
00090                 oxRegistry::getUtils()->redirect($myConfig->getShopHomeURL() . 'cl=basket', true, 302);
00091             }
00092         }
00093 
00094         parent::render();
00095 
00096         if ($myConfig->getConfigParam("bl_showFbConnect") && !$this->getUser()) {
00097             $this->_fillFormWithFacebookData();
00098         }
00099 
00100         return $this->_sThisTemplate;
00101     }
00102 
00108     public function getShowNoRegOption()
00109     {
00110         if ($this->_blShowNoRegOpt === null) {
00111             $this->_blShowNoRegOpt = !$this->getConfig()->getConfigParam('blOrderDisWithoutReg');
00112         }
00113 
00114         return $this->_blShowNoRegOpt;
00115     }
00116 
00122     public function getLoginOption()
00123     {
00124         if ($this->_iOption === null) {
00125             // passing user chosen option value to display correct content
00126             $iOption = oxRegistry::getConfig()->getRequestParameter('option');
00127             // if user chosen "Option 2"" - we should show user details only if he is authorized
00128             if ($iOption == 2 && !$this->getUser()) {
00129                 $iOption = 0;
00130             }
00131             $this->_iOption = $iOption;
00132         }
00133 
00134         return $this->_iOption;
00135     }
00136 
00142     public function getOrderRemark()
00143     {
00144         $oConfig = oxRegistry::getConfig();
00145         if ($this->_sOrderRemark === null) {
00146             $sOrderRemark = false;
00147             // if already connected, we can use the session
00148             if ($this->getUser()) {
00149                 $sOrderRemark = oxRegistry::getSession()->getVariable('ordrem');
00150             } else {
00151                 // not connected so nowhere to save, we're gonna use what we get from post
00152                 $sOrderRemark = $oConfig->getRequestParameter('order_remark', true);
00153             }
00154 
00155             $this->_sOrderRemark = $sOrderRemark ? $oConfig->checkParamSpecialChars($sOrderRemark) : false;
00156         }
00157 
00158         return $this->_sOrderRemark;
00159     }
00160 
00166     public function isNewsSubscribed()
00167     {
00168         if ($this->_blNewsSubscribed === null) {
00169             $blNews = false;
00170             if (($blNews = oxRegistry::getConfig()->getRequestParameter('blnewssubscribed')) === null) {
00171                 $blNews = false;
00172             }
00173             if (($oUser = $this->getUser())) {
00174                 $blNews = $oUser->getNewsSubscription()->getOptInStatus();
00175             }
00176             $this->_blNewsSubscribed = $blNews;
00177         }
00178 
00179         if (is_null($this->_blNewsSubscribed)) {
00180             $this->_blNewsSubscribed = false;
00181         }
00182 
00183         return $this->_blNewsSubscribed;
00184     }
00185 
00191     public function showShipAddress()
00192     {
00193         return oxRegistry::getSession()->getVariable('blshowshipaddress');
00194     }
00195 
00199     protected function _fillFormWithFacebookData()
00200     {
00201         // Create our Application instance.
00202         $oFacebook = oxRegistry::get("oxFb");
00203 
00204         if ($oFacebook->isConnected()) {
00205             $aMe = $oFacebook->api('/me');
00206 
00207             $aInvAdr = $this->getInvoiceAddress();
00208             $sCharset = oxRegistry::getLang()->translateString("charset");
00209 
00210             // do not stop converting on error - just try to translit unknown symbols
00211             $sCharset .= '//TRANSLIT';
00212 
00213             if (!$aInvAdr["oxuser__oxfname"]) {
00214                 $aInvAdr["oxuser__oxfname"] = iconv('UTF-8', $sCharset, $aMe["first_name"]);
00215             }
00216 
00217             if (!$aInvAdr["oxuser__oxlname"]) {
00218                 $aInvAdr["oxuser__oxlname"] = iconv('UTF-8', $sCharset, $aMe["last_name"]);
00219             }
00220 
00221             $this->setInvoiceAddress($aInvAdr);
00222         }
00223     }
00224 
00230     public function modifyBillAddress()
00231     {
00232         return oxRegistry::getConfig()->getRequestParameter('blnewssubscribed');
00233     }
00234 
00240     public function getBreadCrumb()
00241     {
00242         $aPaths = array();
00243         $aPath = array();
00244 
00245         $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
00246         $aPath['title'] = oxRegistry::getLang()->translateString('ADDRESS', $iBaseLanguage, false);
00247         $aPath['link'] = $this->getLink();
00248 
00249         $aPaths[] = $aPath;
00250 
00251         return $aPaths;
00252     }
00253 
00259     public function isDownloadableProductWarning()
00260     {
00261         $oBasket = $this->getSession()->getBasket();
00262         if ($oBasket && $this->getConfig()->getConfigParam("blEnableDownloads")) {
00263             if ($oBasket->hasDownloadableProducts()) {
00264                 return true;
00265             }
00266         }
00267 
00268         return false;
00269     }
00270 }