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 // loading actions 00116 $this->_loadActions(); 00117 00118 // 00119 if ( $sArtId = $this->getArticleId() ) { 00120 $this->_aViewData['aid'] = $sArtId; 00121 // #1834M - specialchar search 00122 $this->_aViewData['searchparam'] = $this->getSearchParam(); 00123 $this->_aViewData['searchparamforhtml'] = $this->getSearchParamForHtml(); 00124 $this->_aViewData['searchcnid'] = $this->getSearchCatId(); 00125 $this->_aViewData['searchvendor'] = $this->getSearchVendor(); 00126 $this->_aViewData['searchmanufacturer'] = $this->getSearchManufacturer(); 00127 $this->_aViewData['listtype'] = $this->getListType(); 00128 } 00129 00130 // is logged in ? 00131 $oUser = $this->getUser(); 00132 if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) || 00133 ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) { 00134 $this->_sThisTemplate = $this->_getLoginTemplate(); 00135 } else { 00136 // calculating amount of orders made by user 00137 $this->_aViewData['iordersmade'] = $this->getOrderCnt(); 00138 } 00139 00140 return $this->_sThisTemplate; 00141 } 00142 00150 protected function _getLoginTemplate() 00151 { 00152 return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate; 00153 } 00154 00160 public function confirmTerms() 00161 { 00162 $blConfirm = oxConfig::getParameter( "term" ); 00163 if ( !$blConfirm && $this->isEnabledPrivateSales() ) { 00164 $oUser = $this->getUser(); 00165 if ( $oUser && !$oUser->isTermsAccepted() ) { 00166 $blConfirm = true; 00167 } 00168 } 00169 00170 return $blConfirm; 00171 } 00172 00181 public function getNavigationParams() 00182 { 00183 $aParams = parent::getNavigationParams(); 00184 00185 // source class name 00186 if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) { 00187 $aParams['sourcecl'] = $sSource; 00188 } 00189 00190 if ( $sSource = oxConfig::getParameter( "anid" ) ) { 00191 $aParams['anid'] = $sSource; 00192 } 00193 00194 return $aParams; 00195 } 00196 00208 public function redirectAfterLogin() 00209 { 00210 // in case source class is provided - redirecting back to it with all default parameters 00211 if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) && 00212 $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) { 00213 00214 $sParams = ''; 00215 // building redirect link 00216 foreach ( $this->getNavigationParams() as $sName => $sValue ) { 00217 if ( $sValue && $sName != "sourcecl" ) { 00218 $sParams .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue ); 00219 } 00220 } 00221 00222 return oxUtils::getInstance()->redirect( $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ).$sParams ); 00223 } 00224 } 00225 00231 public function getOrderCnt() 00232 { 00233 if ( $this->_iOrderCnt === null ) { 00234 $this->_iOrderCnt = 0; 00235 if ( $oUser = $this->getUser() ) { 00236 $this->_iOrderCnt = $oUser->getOrderCount(); 00237 } 00238 } 00239 return $this->_iOrderCnt; 00240 } 00241 00247 public function getArticleId() 00248 { 00249 if ( $this->_sArticleId === null) { 00250 // passing wishlist information 00251 if ( $sArticleId = oxConfig::getParameter('aid') ) { 00252 $this->_sArticleId = $sArticleId; 00253 } 00254 } 00255 return $this->_sArticleId; 00256 } 00257 00263 public function getSearchParamForHtml() 00264 { 00265 if ( $this->_sSearchParamForHtml === null ) { 00266 $this->_sSearchParamForHtml = false; 00267 if ( $this->getArticleId() ) { 00268 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' ); 00269 } 00270 } 00271 return $this->_sSearchParamForHtml; 00272 } 00273 00279 public function getSearchParam() 00280 { 00281 if ( $this->_sSearchParam === null ) { 00282 $this->_sSearchParam = false; 00283 if ( $this->getArticleId() ) { 00284 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ); 00285 } 00286 } 00287 return $this->_sSearchParam; 00288 } 00289 00295 public function getSearchCatId() 00296 { 00297 if ( $this->_sSearchCatId === null ) { 00298 $this->_sSearchCatId = false; 00299 if ( $this->getArticleId() ) { 00300 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) ); 00301 } 00302 } 00303 return $this->_sSearchCatId; 00304 } 00305 00311 public function getSearchVendor() 00312 { 00313 if ( $this->_sSearchVendor === null ) { 00314 $this->_sSearchVendor = false; 00315 if ( $this->getArticleId() ) { 00316 // searching in vendor #671 00317 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) ); 00318 } 00319 } 00320 return $this->_sSearchVendor; 00321 } 00322 00328 public function getSearchManufacturer() 00329 { 00330 if ( $this->_sSearchManufacturer === null ) { 00331 $this->_sSearchManufacturer = false; 00332 if ( $this->getArticleId() ) { 00333 // searching in Manufacturer #671 00334 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) ); 00335 } 00336 } 00337 return $this->_sSearchManufacturer; 00338 } 00339 00345 public function getListType() 00346 { 00347 if ( $this->_sListType === null ) { 00348 $this->_sListType = false; 00349 if ( $this->getArticleId() ) { 00350 // searching in vendor #671 00351 $this->_sListType = oxConfig::getParameter( 'listtype' ); 00352 } 00353 } 00354 return $this->_sListType; 00355 } 00356 }