account.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class Account extends oxUBase
00011 {
00016     protected $_iOrderCnt = null;
00017 
00022     protected $_sArticleId = null;
00023 
00028     protected $_sSearchParamForHtml = null;
00029 
00034     protected $_sSearchParam = null;
00035 
00040     protected $_sSearchCatId = null;
00041 
00046     protected $_sSearchVendor = null;
00047 
00052     protected $_sSearchManufacturer = null;
00053 
00058     protected $_sListType = null;
00059 
00064     protected $_sThisTemplate = 'account_main.tpl';
00065 
00070     protected $_sThisLoginTemplate = 'account_login.tpl';
00071 
00076     protected $_sThisAltLoginTemplate = 'account_login_alt.tpl';
00077 
00083     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00084 
00089     protected $_blTop5Action = true;
00090 
00095     protected $_blBargainAction = true;
00096 
00108     public function render()
00109     {
00110         parent::render();
00111 
00112         // performing redirect if needed
00113         $this->redirectAfterLogin();
00114 
00115 
00116         // loading actions
00117         $this->_loadActions();
00118 
00119         //
00120         if ( $sArtId = $this->getArticleId() ) {
00121             $this->_aViewData['aid'] = $sArtId;
00122             // #1834M - specialchar search
00123             $this->_aViewData['searchparam']        = $this->getSearchParam();
00124             $this->_aViewData['searchparamforhtml'] = $this->getSearchParamForHtml();
00125             $this->_aViewData['searchcnid']         = $this->getSearchCatId();
00126             $this->_aViewData['searchvendor']       = $this->getSearchVendor();
00127             $this->_aViewData['searchmanufacturer'] = $this->getSearchManufacturer();
00128             $this->_aViewData['listtype']           = $this->getListType();
00129         }
00130 
00131         // is logged in ?
00132         $oUser = $this->getUser();
00133         if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) ||
00134              ( $this->getConfig()->getConfigParam( 'blPsLoginEnabled' ) && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) {
00135             $this->_sThisTemplate = $this->_getLoginTemplate();
00136         } else {
00137             // calculating amount of orders made by user
00138             $this->_aViewData['iordersmade'] = $this->getOrderCnt();
00139         }
00140 
00141         return $this->_sThisTemplate;
00142     }
00143 
00151     protected function _getLoginTemplate()
00152     {
00153         return $this->getConfig()->getConfigParam( 'blPsLoginEnabled' ) ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
00154     }
00155 
00161     public function confirmTerms()
00162     {
00163         $blConfirm = oxConfig::getParameter( "term" );
00164         if ( !$blConfirm && $this->getConfig()->getConfigParam( 'blPsLoginEnabled' ) ) {
00165             $oUser = $this->getUser();
00166             if ( $oUser && !$oUser->isTermsAccepted() ) {
00167                 $blConfirm = true;
00168             }
00169         }
00170 
00171         return $blConfirm;
00172     }
00173 
00182     public function getNavigationParams()
00183     {
00184         $aParams = parent::getNavigationParams();
00185 
00186         // source class name
00187         if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) {
00188             $aParams['sourcecl'] = $sSource;
00189         }
00190 
00191         if ( $sSource = oxConfig::getParameter( "anid" ) ) {
00192             $aParams['anid'] = $sSource;
00193         }
00194 
00195         return $aParams;
00196     }
00197 
00209     public function redirectAfterLogin()
00210     {
00211         // in case source class is provided - redirecting back to it with all default parameters
00212         if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) &&
00213              $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) {
00214 
00215             $sParams = '';
00216             // building redirect link
00217             foreach ( $this->getNavigationParams() as $sName => $sValue ) {
00218                 if ( $sValue && $sName != "sourcecl" ) {
00219                     $sParams .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue );
00220                 }
00221             }
00222 
00223             return oxUtils::getInstance()->redirect( $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ).$sParams );
00224         }
00225     }
00226 
00232     public function getOrderCnt()
00233     {
00234         if ( $this->_iOrderCnt === null ) {
00235             $this->_iOrderCnt = 0;
00236             if ( $oUser = $this->getUser() ) {
00237                 $this->_iOrderCnt = $oUser->getOrderCount();
00238             }
00239         }
00240         return $this->_iOrderCnt;
00241     }
00242 
00248     public function getArticleId()
00249     {
00250         if ( $this->_sArticleId === null) {
00251             // passing wishlist information
00252             if ( $sArticleId = oxConfig::getParameter('aid') ) {
00253                 $this->_sArticleId = $sArticleId;
00254             }
00255         }
00256         return $this->_sArticleId;
00257     }
00258 
00264     public function getSearchParamForHtml()
00265     {
00266         if ( $this->_sSearchParamForHtml === null ) {
00267             $this->_sSearchParamForHtml = false;
00268             if ( $this->getArticleId() ) {
00269                 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
00270             }
00271         }
00272         return $this->_sSearchParamForHtml;
00273     }
00274 
00280     public function getSearchParam()
00281     {
00282         if ( $this->_sSearchParam === null ) {
00283             $this->_sSearchParam = false;
00284             if ( $this->getArticleId() ) {
00285                 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00286             }
00287         }
00288         return $this->_sSearchParam;
00289     }
00290 
00296     public function getSearchCatId()
00297     {
00298         if ( $this->_sSearchCatId === null ) {
00299             $this->_sSearchCatId = false;
00300             if ( $this->getArticleId() ) {
00301                 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) );
00302             }
00303         }
00304         return $this->_sSearchCatId;
00305     }
00306 
00312     public function getSearchVendor()
00313     {
00314         if ( $this->_sSearchVendor === null ) {
00315             $this->_sSearchVendor = false;
00316             if ( $this->getArticleId() ) {
00317                 // searching in vendor #671
00318                 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) );
00319             }
00320         }
00321         return $this->_sSearchVendor;
00322     }
00323 
00329     public function getSearchManufacturer()
00330     {
00331         if ( $this->_sSearchManufacturer === null ) {
00332             $this->_sSearchManufacturer = false;
00333             if ( $this->getArticleId() ) {
00334                 // searching in Manufacturer #671
00335                 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) );
00336             }
00337         }
00338         return $this->_sSearchManufacturer;
00339     }
00340 
00346     public function getListType()
00347     {
00348         if ( $this->_sListType === null ) {
00349             $this->_sListType = false;
00350             if ( $this->getArticleId() ) {
00351                 // searching in vendor #671
00352                 $this->_sListType = oxConfig::getParameter( 'listtype' );
00353             }
00354         }
00355         return $this->_sListType;
00356     }
00357 }