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 && $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         return oxConfig::getParameter( "term" );
00164     }
00165 
00174     public function getNavigationParams()
00175     {
00176         $aParams = parent::getNavigationParams();
00177 
00178         // source class name
00179         if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) {
00180             $aParams['sourcecl'] = $sSource;
00181         }
00182 
00183         if ( $sSource = oxConfig::getParameter( "anid" ) ) {
00184             $aParams['anid'] = $sSource;
00185         }
00186 
00187         return $aParams;
00188     }
00189 
00201     public function redirectAfterLogin()
00202     {
00203         // in case source class is provided - redirecting back to it with all default parameters
00204         if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) &&
00205              $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) {
00206 
00207             $sParams = '';
00208             // building redirect link
00209             foreach ( $this->getNavigationParams() as $sName => $sValue ) {
00210                 if ( $sValue && $sName != "sourcecl" ) {
00211                     $sParams .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue );
00212                 }
00213             }
00214 
00215             return oxUtils::getInstance()->redirect( $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ).$sParams );
00216         }
00217     }
00218 
00224     public function getOrderCnt()
00225     {
00226         if ( $this->_iOrderCnt === null ) {
00227             $this->_iOrderCnt = 0;
00228             if ( $oUser = $this->getUser() ) {
00229                 $this->_iOrderCnt = $oUser->getOrderCount();
00230             }
00231         }
00232         return $this->_iOrderCnt;
00233     }
00234 
00240     public function getArticleId()
00241     {
00242         if ( $this->_sArticleId === null) {
00243             // passing wishlist information
00244             if ( $sArticleId = oxConfig::getParameter('aid') ) {
00245                 $this->_sArticleId = $sArticleId;
00246             }
00247         }
00248         return $this->_sArticleId;
00249     }
00250 
00256     public function getSearchParamForHtml()
00257     {
00258         if ( $this->_sSearchParamForHtml === null ) {
00259             $this->_sSearchParamForHtml = false;
00260             if ( $this->getArticleId() ) {
00261                 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
00262             }
00263         }
00264         return $this->_sSearchParamForHtml;
00265     }
00266 
00272     public function getSearchParam()
00273     {
00274         if ( $this->_sSearchParam === null ) {
00275             $this->_sSearchParam = false;
00276             if ( $this->getArticleId() ) {
00277                 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00278             }
00279         }
00280         return $this->_sSearchParam;
00281     }
00282 
00288     public function getSearchCatId()
00289     {
00290         if ( $this->_sSearchCatId === null ) {
00291             $this->_sSearchCatId = false;
00292             if ( $this->getArticleId() ) {
00293                 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) );
00294             }
00295         }
00296         return $this->_sSearchCatId;
00297     }
00298 
00304     public function getSearchVendor()
00305     {
00306         if ( $this->_sSearchVendor === null ) {
00307             $this->_sSearchVendor = false;
00308             if ( $this->getArticleId() ) {
00309                 // searching in vendor #671
00310                 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) );
00311             }
00312         }
00313         return $this->_sSearchVendor;
00314     }
00315 
00321     public function getSearchManufacturer()
00322     {
00323         if ( $this->_sSearchManufacturer === null ) {
00324             $this->_sSearchManufacturer = false;
00325             if ( $this->getArticleId() ) {
00326                 // searching in Manufacturer #671
00327                 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) );
00328             }
00329         }
00330         return $this->_sSearchManufacturer;
00331     }
00332 
00338     public function getListType()
00339     {
00340         if ( $this->_sListType === null ) {
00341             $this->_sListType = false;
00342             if ( $this->getArticleId() ) {
00343                 // searching in vendor #671
00344                 $this->_sListType = oxConfig::getParameter( 'listtype' );
00345             }
00346         }
00347         return $this->_sListType;
00348     }
00349 }