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 $_blBargainAction = true; 00088 00093 protected $_blShowTagCloud = false; 00094 00095 00102 public function render() 00103 { 00104 parent::render(); 00105 00106 // performing redirect if needed 00107 $this->redirectAfterLogin(); 00108 00109 // is logged in ? 00110 $oUser = $this->getUser(); 00111 if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) || 00112 ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) { 00113 $this->_sThisTemplate = $this->_getLoginTemplate(); 00114 } 00115 00116 return $this->_sThisTemplate; 00117 } 00118 00126 protected function _getLoginTemplate() 00127 { 00128 return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate; 00129 } 00130 00136 public function confirmTerms() 00137 { 00138 $blConfirm = oxConfig::getParameter( "term" ); 00139 if ( !$blConfirm && $this->isEnabledPrivateSales() ) { 00140 $oUser = $this->getUser(); 00141 if ( $oUser && !$oUser->isTermsAccepted() ) { 00142 $blConfirm = true; 00143 } 00144 } 00145 00146 return $blConfirm; 00147 } 00148 00157 public function getNavigationParams() 00158 { 00159 $aParams = parent::getNavigationParams(); 00160 00161 // source class name 00162 if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) { 00163 $aParams['sourcecl'] = $sSource; 00164 } 00165 00166 if ( $sSource = oxConfig::getParameter( "anid" ) ) { 00167 $aParams['anid'] = $sSource; 00168 } 00169 00170 return $aParams; 00171 } 00172 00184 public function redirectAfterLogin() 00185 { 00186 // in case source class is provided - redirecting back to it with all default parameters 00187 if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) && 00188 $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) { 00189 00190 $sRedirectUrl = $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ); 00191 // building redirect link 00192 00193 foreach ( $this->getNavigationParams() as $sName => $sValue ) { 00194 if ( $sValue && $sName != "sourcecl" ) { 00195 $sRedirectUrl .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue ); 00196 } 00197 } 00198 return oxRegistry::getUtils()->redirect( oxRegistry::get("oxUtilsUrl")->processUrl( $sRedirectUrl ), true, 302 ); 00199 } 00200 } 00201 00207 public function getOrderCnt() 00208 { 00209 if ( $this->_iOrderCnt === null ) { 00210 $this->_iOrderCnt = 0; 00211 if ( $oUser = $this->getUser() ) { 00212 $this->_iOrderCnt = $oUser->getOrderCount(); 00213 } 00214 } 00215 return $this->_iOrderCnt; 00216 } 00217 00223 public function getArticleId() 00224 { 00225 if ( $this->_sArticleId === null) { 00226 // passing wishlist information 00227 if ( $sArticleId = oxConfig::getParameter('aid') ) { 00228 $this->_sArticleId = $sArticleId; 00229 } 00230 } 00231 return $this->_sArticleId; 00232 } 00233 00239 public function getSearchParamForHtml() 00240 { 00241 if ( $this->_sSearchParamForHtml === null ) { 00242 $this->_sSearchParamForHtml = false; 00243 if ( $this->getArticleId() ) { 00244 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' ); 00245 } 00246 } 00247 return $this->_sSearchParamForHtml; 00248 } 00249 00255 public function getSearchParam() 00256 { 00257 if ( $this->_sSearchParam === null ) { 00258 $this->_sSearchParam = false; 00259 if ( $this->getArticleId() ) { 00260 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ); 00261 } 00262 } 00263 return $this->_sSearchParam; 00264 } 00265 00271 public function getListType() 00272 { 00273 if ( $this->_sListType === null ) { 00274 $this->_sListType = false; 00275 if ( $this->getArticleId() ) { 00276 // searching in vendor #671 00277 $this->_sListType = oxConfig::getParameter( 'listtype' ); 00278 } 00279 } 00280 return $this->_sListType; 00281 } 00282 00288 public function getBreadCrumb() 00289 { 00290 $aPaths = array(); 00291 $aPath = array(); 00292 if ( $oUser = $this->getUser() ) { 00293 $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false ) . " - " . $oUser->oxuser__oxusername->value; 00294 } else { 00295 $aPath['title'] = oxRegistry::getLang()->translateString( 'LOGIN', oxRegistry::getLang()->getBaseLanguage(), false ); 00296 } 00297 $aPath['link'] = $this->getLink(); 00298 $aPaths[] = $aPath; 00299 return $aPaths; 00300 } 00301 00307 public function getCompareItemsCnt() 00308 { 00309 $oCompare = oxNew( "compare" ); 00310 $iCompItemsCnt = $oCompare->getCompareItemsCnt(); 00311 return $iCompItemsCnt; 00312 } 00313 }