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 00077 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW; 00078 00083 protected $_blTop5Action = true; 00084 00089 protected $_blBargainAction = true; 00090 00102 public function render() 00103 { 00104 parent::render(); 00105 00106 // performing redirect if needed 00107 $this->redirectAfterLogin(); 00108 00109 00110 // loading actions 00111 $this->_loadActions(); 00112 00113 // 00114 if ( $sArtID = oxConfig::getParameter('aid') ) { 00115 $this->_aViewData['aid'] = $this->getArticleId(); 00116 // #1834M - specialchar search 00117 $this->_aViewData['searchparam'] = $this->getSearchParam(); 00118 $this->_aViewData['searchparamforhtml'] = $this->getSearchParamForHtml(); 00119 $this->_aViewData['searchcnid'] = $this->getSearchCatId(); 00120 $this->_aViewData['searchvendor'] = $this->getSearchVendor(); 00121 $this->_aViewData['searchmanufacturer'] = $this->getSearchManufacturer(); 00122 $this->_aViewData['listtype'] = $this->getListType(); 00123 } 00124 00125 // is logged in ? 00126 $oUser = $this->getUser(); 00127 if ( !$oUser || $oUser->oxuser__oxpassword->value == '' ) { 00128 return $this->_sThisTemplate = $this->_sThisLoginTemplate; 00129 } 00130 00131 // calculating amount of orders made by user 00132 $this->_aViewData['iordersmade'] = $this->getOrderCnt(); 00133 00134 return $this->_sThisTemplate; 00135 } 00136 00145 public function getNavigationParams() 00146 { 00147 $aParams = parent::getNavigationParams(); 00148 00149 // source class name 00150 if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) { 00151 $aParams['sourcecl'] = $sSource; 00152 } 00153 00154 if ( $sSource = oxConfig::getParameter( "anid" ) ) { 00155 $aParams['anid'] = $sSource; 00156 } 00157 00158 return $aParams; 00159 } 00160 00172 public function redirectAfterLogin() 00173 { 00174 // in case source class is provided - redirecting back to it with all default parameters 00175 if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) && 00176 $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) { 00177 00178 $sParams = ''; 00179 // building redirect link 00180 foreach ( $this->getNavigationParams() as $sName => $sValue ) { 00181 if ( $sValue && $sName != "sourcecl" ) { 00182 $sParams .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue ); 00183 } 00184 } 00185 00186 return oxUtils::getInstance()->redirect( $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource ).$sParams ); 00187 } 00188 } 00189 00195 public function getOrderCnt() 00196 { 00197 if ( $this->_iOrderCnt === null ) { 00198 $this->_iOrderCnt = 0; 00199 if ( $oUser = $this->getUser() ) { 00200 $this->_iOrderCnt = $oUser->getOrderCount(); 00201 } 00202 } 00203 return $this->_iOrderCnt; 00204 } 00205 00211 public function getArticleId() 00212 { 00213 if ( $this->_sArticleId === null) { 00214 // passing wishlist information 00215 if ( $sArticleId = oxConfig::getParameter('aid') ) { 00216 $this->_sArticleId = $sArticleId; 00217 } 00218 } 00219 return $this->_sArticleId; 00220 } 00221 00227 public function getSearchParamForHtml() 00228 { 00229 if ( $this->_sSearchParamForHtml === null ) { 00230 $this->_sSearchParamForHtml = false; 00231 if ( $this->getArticleId() ) { 00232 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' ); 00233 } 00234 } 00235 return $this->_sSearchParamForHtml; 00236 } 00237 00243 public function getSearchParam() 00244 { 00245 if ( $this->_sSearchParam === null ) { 00246 $this->_sSearchParam = false; 00247 if ( $this->getArticleId() ) { 00248 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ); 00249 } 00250 } 00251 return $this->_sSearchParam; 00252 } 00253 00259 public function getSearchCatId() 00260 { 00261 if ( $this->_sSearchCatId === null ) { 00262 $this->_sSearchCatId = false; 00263 if ( $this->getArticleId() ) { 00264 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) ); 00265 } 00266 } 00267 return $this->_sSearchCatId; 00268 } 00269 00275 public function getSearchVendor() 00276 { 00277 if ( $this->_sSearchVendor === null ) { 00278 $this->_sSearchVendor = false; 00279 if ( $this->getArticleId() ) { 00280 // searching in vendor #671 00281 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) ); 00282 } 00283 } 00284 return $this->_sSearchVendor; 00285 } 00286 00292 public function getSearchManufacturer() 00293 { 00294 if ( $this->_sSearchManufacturer === null ) { 00295 $this->_sSearchManufacturer = false; 00296 if ( $this->getArticleId() ) { 00297 // searching in Manufacturer #671 00298 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) ); 00299 } 00300 } 00301 return $this->_sSearchManufacturer; 00302 } 00303 00309 public function getListType() 00310 { 00311 if ( $this->_sListType === null ) { 00312 $this->_sListType = false; 00313 if ( $this->getArticleId() ) { 00314 // searching in vendor #671 00315 $this->_sListType = oxConfig::getParameter( 'listtype' ); 00316 } 00317 } 00318 return $this->_sListType; 00319 } 00320 00321 }