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 00091 protected $_blTop5Action = false; 00092 00097 protected $_blBargainAction = true; 00098 00103 protected $_blShowTagCloud = false; 00104 00111 public function render() 00112 { 00113 parent::render(); 00114 00115 // performing redirect if needed 00116 $this->redirectAfterLogin(); 00117 00118 // is logged in ? 00119 $oUser = $this->getUser(); 00120 if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) || 00121 ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) { 00122 $this->_sThisTemplate = $this->_getLoginTemplate(); 00123 } 00124 00125 return $this->_sThisTemplate; 00126 } 00127 00135 protected function _getLoginTemplate() 00136 { 00137 return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate; 00138 } 00139 00145 public function confirmTerms() 00146 { 00147 $blConfirm = oxConfig::getParameter( "term" ); 00148 if ( !$blConfirm && $this->isEnabledPrivateSales() ) { 00149 $oUser = $this->getUser(); 00150 if ( $oUser && !$oUser->isTermsAccepted() ) { 00151 $blConfirm = true; 00152 } 00153 } 00154 00155 return $blConfirm; 00156 } 00157 00166 public function getNavigationParams() 00167 { 00168 $aParams = parent::getNavigationParams(); 00169 00170 // source class name 00171 if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) { 00172 $aParams['sourcecl'] = $sSource; 00173 } 00174 00175 if ( $sSource = oxConfig::getParameter( "anid" ) ) { 00176 $aParams['anid'] = $sSource; 00177 } 00178 00179 return $aParams; 00180 } 00181 00193 public function redirectAfterLogin() 00194 { 00195 // in case source class is provided - redirecting back to it with all default parameters 00196 if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) && 00197 $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) { 00198 00199 $sRedirectUrl = $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ); 00200 // building redirect link 00201 00202 foreach ( $this->getNavigationParams() as $sName => $sValue ) { 00203 if ( $sValue && $sName != "sourcecl" ) { 00204 $sRedirectUrl .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue ); 00205 } 00206 } 00207 return oxUtils::getInstance()->redirect( oxUtilsUrl::getInstance()->processUrl( $sRedirectUrl ), true, 302 ); 00208 } 00209 } 00210 00216 public function getOrderCnt() 00217 { 00218 if ( $this->_iOrderCnt === null ) { 00219 $this->_iOrderCnt = 0; 00220 if ( $oUser = $this->getUser() ) { 00221 $this->_iOrderCnt = $oUser->getOrderCount(); 00222 } 00223 } 00224 return $this->_iOrderCnt; 00225 } 00226 00232 public function getArticleId() 00233 { 00234 if ( $this->_sArticleId === null) { 00235 // passing wishlist information 00236 if ( $sArticleId = oxConfig::getParameter('aid') ) { 00237 $this->_sArticleId = $sArticleId; 00238 } 00239 } 00240 return $this->_sArticleId; 00241 } 00242 00248 public function getSearchParamForHtml() 00249 { 00250 if ( $this->_sSearchParamForHtml === null ) { 00251 $this->_sSearchParamForHtml = false; 00252 if ( $this->getArticleId() ) { 00253 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' ); 00254 } 00255 } 00256 return $this->_sSearchParamForHtml; 00257 } 00258 00264 public function getSearchParam() 00265 { 00266 if ( $this->_sSearchParam === null ) { 00267 $this->_sSearchParam = false; 00268 if ( $this->getArticleId() ) { 00269 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ); 00270 } 00271 } 00272 return $this->_sSearchParam; 00273 } 00274 00280 public function getSearchCatId() 00281 { 00282 if ( $this->_sSearchCatId === null ) { 00283 $this->_sSearchCatId = false; 00284 if ( $this->getArticleId() ) { 00285 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) ); 00286 } 00287 } 00288 return $this->_sSearchCatId; 00289 } 00290 00296 public function getSearchVendor() 00297 { 00298 if ( $this->_sSearchVendor === null ) { 00299 $this->_sSearchVendor = false; 00300 if ( $this->getArticleId() ) { 00301 // searching in vendor #671 00302 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) ); 00303 } 00304 } 00305 return $this->_sSearchVendor; 00306 } 00307 00313 public function getSearchManufacturer() 00314 { 00315 if ( $this->_sSearchManufacturer === null ) { 00316 $this->_sSearchManufacturer = false; 00317 if ( $this->getArticleId() ) { 00318 // searching in Manufacturer #671 00319 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) ); 00320 } 00321 } 00322 return $this->_sSearchManufacturer; 00323 } 00324 00330 public function getListType() 00331 { 00332 if ( $this->_sListType === null ) { 00333 $this->_sListType = false; 00334 if ( $this->getArticleId() ) { 00335 // searching in vendor #671 00336 $this->_sListType = oxConfig::getParameter( 'listtype' ); 00337 } 00338 } 00339 return $this->_sListType; 00340 } 00341 00347 public function getBreadCrumb() 00348 { 00349 $aPaths = array(); 00350 $aPath = array(); 00351 if ( $oUser = $this->getUser() ) { 00352 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_DASHBOARD_MYACCOUNT', oxLang::getInstance()->getBaseLanguage(), false ) . $oUser->oxuser__oxusername->value; 00353 } else { 00354 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_INC_LOGIN_LOGIN', oxLang::getInstance()->getBaseLanguage(), false ); 00355 } 00356 $aPath['link'] = $this->getLink(); 00357 $aPaths[] = $aPath; 00358 return $aPaths; 00359 } 00360 }