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 $_sListType = null; 00043 00048 protected $_sThisTemplate = 'page/account/dashboard.tpl'; 00049 00054 protected $_sThisLoginTemplate = 'page/account/login.tpl'; 00055 00060 protected $_sThisAltLoginTemplate = 'page/privatesales/login.tpl'; 00061 00067 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW; 00068 00074 protected $_sMetaDescriptionIdent = 'oxstartmetadescription'; 00075 00081 protected $_sMetaKeywordsIdent = 'oxstartmetakeywords'; 00082 00087 protected $_blTop5Action = false; 00088 00093 protected $_blBargainAction = true; 00094 00099 protected $_blShowTagCloud = false; 00100 00101 00108 public function render() 00109 { 00110 parent::render(); 00111 00112 // performing redirect if needed 00113 $this->redirectAfterLogin(); 00114 00115 // is logged in ? 00116 $oUser = $this->getUser(); 00117 if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) || 00118 ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) { 00119 $this->_sThisTemplate = $this->_getLoginTemplate(); 00120 } 00121 00122 return $this->_sThisTemplate; 00123 } 00124 00132 protected function _getLoginTemplate() 00133 { 00134 return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate; 00135 } 00136 00142 public function confirmTerms() 00143 { 00144 $blConfirm = oxConfig::getParameter( "term" ); 00145 if ( !$blConfirm && $this->isEnabledPrivateSales() ) { 00146 $oUser = $this->getUser(); 00147 if ( $oUser && !$oUser->isTermsAccepted() ) { 00148 $blConfirm = true; 00149 } 00150 } 00151 00152 return $blConfirm; 00153 } 00154 00163 public function getNavigationParams() 00164 { 00165 $aParams = parent::getNavigationParams(); 00166 00167 // source class name 00168 if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) { 00169 $aParams['sourcecl'] = $sSource; 00170 } 00171 00172 if ( $sSource = oxConfig::getParameter( "anid" ) ) { 00173 $aParams['anid'] = $sSource; 00174 } 00175 00176 return $aParams; 00177 } 00178 00190 public function redirectAfterLogin() 00191 { 00192 // in case source class is provided - redirecting back to it with all default parameters 00193 if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) && 00194 $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) { 00195 00196 $sRedirectUrl = $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ); 00197 // building redirect link 00198 00199 foreach ( $this->getNavigationParams() as $sName => $sValue ) { 00200 if ( $sValue && $sName != "sourcecl" ) { 00201 $sRedirectUrl .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue ); 00202 } 00203 } 00204 return oxRegistry::getUtils()->redirect( oxRegistry::get("oxUtilsUrl")->processUrl( $sRedirectUrl ), true, 302 ); 00205 } 00206 } 00207 00213 public function getOrderCnt() 00214 { 00215 if ( $this->_iOrderCnt === null ) { 00216 $this->_iOrderCnt = 0; 00217 if ( $oUser = $this->getUser() ) { 00218 $this->_iOrderCnt = $oUser->getOrderCount(); 00219 } 00220 } 00221 return $this->_iOrderCnt; 00222 } 00223 00229 public function getArticleId() 00230 { 00231 if ( $this->_sArticleId === null) { 00232 // passing wishlist information 00233 if ( $sArticleId = oxConfig::getParameter('aid') ) { 00234 $this->_sArticleId = $sArticleId; 00235 } 00236 } 00237 return $this->_sArticleId; 00238 } 00239 00245 public function getSearchParamForHtml() 00246 { 00247 if ( $this->_sSearchParamForHtml === null ) { 00248 $this->_sSearchParamForHtml = false; 00249 if ( $this->getArticleId() ) { 00250 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' ); 00251 } 00252 } 00253 return $this->_sSearchParamForHtml; 00254 } 00255 00261 public function getSearchParam() 00262 { 00263 if ( $this->_sSearchParam === null ) { 00264 $this->_sSearchParam = false; 00265 if ( $this->getArticleId() ) { 00266 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ); 00267 } 00268 } 00269 return $this->_sSearchParam; 00270 } 00271 00277 public function getListType() 00278 { 00279 if ( $this->_sListType === null ) { 00280 $this->_sListType = false; 00281 if ( $this->getArticleId() ) { 00282 // searching in vendor #671 00283 $this->_sListType = oxConfig::getParameter( 'listtype' ); 00284 } 00285 } 00286 return $this->_sListType; 00287 } 00288 00294 public function getBreadCrumb() 00295 { 00296 $aPaths = array(); 00297 $aPath = array(); 00298 if ( $oUser = $this->getUser() ) { 00299 $aPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_ACCOUNT_DASHBOARD_MYACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false ) . $oUser->oxuser__oxusername->value; 00300 } else { 00301 $aPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_ACCOUNT_INC_LOGIN_LOGIN', oxRegistry::getLang()->getBaseLanguage(), false ); 00302 } 00303 $aPath['link'] = $this->getLink(); 00304 $aPaths[] = $aPath; 00305 return $aPaths; 00306 } 00307 00313 public function getCompareItemsCnt() 00314 { 00315 $oCompare = oxNew( "compare" ); 00316 $iCompItemsCnt = $oCompare->getCompareItemsCnt(); 00317 return $iCompItemsCnt; 00318 } 00319 }