account.php

Go to the documentation of this file.
00001 <?php
00002 
00012 class Account extends oxUBase
00013 {
00018     protected $_iOrderCnt = null;
00019 
00024     protected $_sArticleId = null;
00025 
00030     protected $_sSearchParamForHtml = null;
00031 
00036     protected $_sSearchParam = null;
00037 
00042     protected $_sSearchCatId = null;
00043 
00048     protected $_sSearchVendor = null;
00049 
00054     protected $_sSearchManufacturer = null;
00055 
00060     protected $_sListType = null;
00061 
00066     protected $_sThisTemplate = 'page/account/dashboard.tpl';
00067 
00072     protected $_sThisLoginTemplate = 'page/account/login.tpl';
00073 
00078     protected $_sThisAltLoginTemplate = 'page/privatesales/login.tpl';
00079 
00085     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00086 
00092     protected $_sMetaDescriptionIdent = 'oxstartmetadescription';
00093 
00099     protected $_sMetaKeywordsIdent = 'oxstartmetakeywords';
00100 
00105     protected $_blTop5Action = false;
00106 
00111     protected $_blBargainAction = true;
00112 
00117     protected $_blShowTagCloud = false;
00118 
00125     public function render()
00126     {
00127         parent::render();
00128 
00129         // performing redirect if needed
00130         $this->redirectAfterLogin();
00131 
00132         // is logged in ?
00133         $oUser = $this->getUser();
00134         if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) ||
00135              ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) {
00136             $this->_sThisTemplate = $this->_getLoginTemplate();
00137         }
00138 
00139         return $this->_sThisTemplate;
00140     }
00141 
00149     protected function _getLoginTemplate()
00150     {
00151         return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
00152     }
00153 
00159     public function confirmTerms()
00160     {
00161         $blConfirm = oxConfig::getParameter( "term" );
00162         if ( !$blConfirm && $this->isEnabledPrivateSales() ) {
00163             $oUser = $this->getUser();
00164             if ( $oUser && !$oUser->isTermsAccepted() ) {
00165                 $blConfirm = true;
00166             }
00167         }
00168 
00169         return $blConfirm;
00170     }
00171 
00180     public function getNavigationParams()
00181     {
00182         $aParams = parent::getNavigationParams();
00183 
00184         // source class name
00185         if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) {
00186             $aParams['sourcecl'] = $sSource;
00187         }
00188 
00189         if ( $sSource = oxConfig::getParameter( "anid" ) ) {
00190             $aParams['anid'] = $sSource;
00191         }
00192 
00193         return $aParams;
00194     }
00195 
00207     public function redirectAfterLogin()
00208     {
00209         // in case source class is provided - redirecting back to it with all default parameters
00210         if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) &&
00211             $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) {
00212 
00213             $sRedirectUrl = $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource );
00214             // building redirect link
00215 
00216             foreach ( $this->getNavigationParams() as $sName => $sValue ) {
00217                 if ( $sValue && $sName != "sourcecl" ) {
00218                     $sRedirectUrl .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue );
00219                 }
00220             }
00221             return oxUtils::getInstance()->redirect( oxUtilsUrl::getInstance()->processUrl( $sRedirectUrl ), true, 302 );
00222         }
00223     }
00224 
00230     public function getOrderCnt()
00231     {
00232         if ( $this->_iOrderCnt === null ) {
00233             $this->_iOrderCnt = 0;
00234             if ( $oUser = $this->getUser() ) {
00235                 $this->_iOrderCnt = $oUser->getOrderCount();
00236             }
00237         }
00238         return $this->_iOrderCnt;
00239     }
00240 
00246     public function getArticleId()
00247     {
00248         if ( $this->_sArticleId === null) {
00249             // passing wishlist information
00250             if ( $sArticleId = oxConfig::getParameter('aid') ) {
00251                 $this->_sArticleId = $sArticleId;
00252             }
00253         }
00254         return $this->_sArticleId;
00255     }
00256 
00262     public function getSearchParamForHtml()
00263     {
00264         if ( $this->_sSearchParamForHtml === null ) {
00265             $this->_sSearchParamForHtml = false;
00266             if ( $this->getArticleId() ) {
00267                 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
00268             }
00269         }
00270         return $this->_sSearchParamForHtml;
00271     }
00272 
00278     public function getSearchParam()
00279     {
00280         if ( $this->_sSearchParam === null ) {
00281             $this->_sSearchParam = false;
00282             if ( $this->getArticleId() ) {
00283                 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00284             }
00285         }
00286         return $this->_sSearchParam;
00287     }
00288 
00294     public function getSearchCatId()
00295     {
00296         if ( $this->_sSearchCatId === null ) {
00297             $this->_sSearchCatId = false;
00298             if ( $this->getArticleId() ) {
00299                 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) );
00300             }
00301         }
00302         return $this->_sSearchCatId;
00303     }
00304 
00310     public function getSearchVendor()
00311     {
00312         if ( $this->_sSearchVendor === null ) {
00313             $this->_sSearchVendor = false;
00314             if ( $this->getArticleId() ) {
00315                 // searching in vendor #671
00316                 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) );
00317             }
00318         }
00319         return $this->_sSearchVendor;
00320     }
00321 
00327     public function getSearchManufacturer()
00328     {
00329         if ( $this->_sSearchManufacturer === null ) {
00330             $this->_sSearchManufacturer = false;
00331             if ( $this->getArticleId() ) {
00332                 // searching in Manufacturer #671
00333                 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) );
00334             }
00335         }
00336         return $this->_sSearchManufacturer;
00337     }
00338 
00344     public function getListType()
00345     {
00346         if ( $this->_sListType === null ) {
00347             $this->_sListType = false;
00348             if ( $this->getArticleId() ) {
00349                 // searching in vendor #671
00350                 $this->_sListType = oxConfig::getParameter( 'listtype' );
00351             }
00352         }
00353         return $this->_sListType;
00354     }
00355 
00361     public function getBreadCrumb()
00362     {
00363         $aPaths = array();
00364         $aPath  = array();
00365         if ( $oUser = $this->getUser() ) {
00366             $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_DASHBOARD_MYACCOUNT', oxLang::getInstance()->getBaseLanguage(), false ) . $oUser->oxuser__oxusername->value;
00367         } else {
00368             $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_INC_LOGIN_LOGIN', oxLang::getInstance()->getBaseLanguage(), false );
00369         }
00370         $aPath['link'] = $this->getLink();
00371         $aPaths[] = $aPath;
00372         return $aPaths;
00373     }
00374 }