account.php

Go to the documentation of this file.
00001 <?php
00002 
00012 class Account extends oxUBase
00013 {
00014 
00020     protected $_iOrderCnt = null;
00021 
00027     protected $_sArticleId = null;
00028 
00034     protected $_sSearchParamForHtml = null;
00035 
00041     protected $_sSearchParam = null;
00042 
00048     protected $_sListType = null;
00049 
00055     protected $_sThisTemplate = 'page/account/dashboard.tpl';
00056 
00062     protected $_sThisLoginTemplate = 'page/account/login.tpl';
00063 
00069     protected $_sThisAltLoginTemplate = 'page/privatesales/login.tpl';
00070 
00076     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00077 
00083     protected $_sMetaDescriptionIdent = 'oxstartmetadescription';
00084 
00090     protected $_sMetaKeywordsIdent = 'oxstartmetakeywords';
00091 
00097     protected $_blBargainAction = true;
00098 
00104     protected $_blShowTagCloud = false;
00105 
00106 
00113     public function render()
00114     {
00115         parent::render();
00116 
00117         // performing redirect if needed
00118         $this->redirectAfterLogin();
00119 
00120         // is logged in ?
00121         $oUser = $this->getUser();
00122         $sPasswordField = 'oxuser__oxpassword';
00123         if (!$oUser || ($oUser && !$oUser->$sPasswordField->value) ||
00124             ($this->isEnabledPrivateSales() && $oUser && (!$oUser->isTermsAccepted() || $this->confirmTerms()))
00125         ) {
00126             $this->_sThisTemplate = $this->_getLoginTemplate();
00127         }
00128 
00129         return $this->_sThisTemplate;
00130     }
00131 
00139     protected function _getLoginTemplate()
00140     {
00141         return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
00142     }
00143 
00149     public function confirmTerms()
00150     {
00151         $blConfirm = oxRegistry::getConfig()->getRequestParameter("term");
00152         if (!$blConfirm && $this->isEnabledPrivateSales()) {
00153             $oUser = $this->getUser();
00154             if ($oUser && !$oUser->isTermsAccepted()) {
00155                 $blConfirm = true;
00156             }
00157         }
00158 
00159         return $blConfirm;
00160     }
00161 
00170     public function getNavigationParams()
00171     {
00172         $aParams = parent::getNavigationParams();
00173 
00174         // source class name
00175         if ($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) {
00176             $aParams['sourcecl'] = $sSource;
00177         }
00178 
00179         if ($sSource = oxRegistry::getConfig()->getRequestParameter("anid")) {
00180             $aParams['anid'] = $sSource;
00181         }
00182 
00183         return $aParams;
00184     }
00185 
00197     public function redirectAfterLogin()
00198     {
00199         // in case source class is provided - redirecting back to it with all default parameters
00200         if (($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) &&
00201             $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS
00202         ) {
00203 
00204             $sRedirectUrl = $this->getConfig()->getShopUrl() . 'index.php?cl=' . rawurlencode($sSource);
00205             // building redirect link
00206 
00207             foreach ($this->getNavigationParams() as $sName => $sValue) {
00208                 if ($sValue && $sName != "sourcecl") {
00209                     $sRedirectUrl .= '&' . rawurlencode($sName) . "=" . rawurlencode($sValue);
00210                 }
00211             }
00212 
00214             $oUtilsUrl = oxRegistry::get("oxUtilsUrl");
00215             return oxRegistry::getUtils()->redirect($oUtilsUrl->processUrl($sRedirectUrl), true, 302);
00216         }
00217     }
00218 
00224     public function getOrderCnt()
00225     {
00226         if ($this->_iOrderCnt === null) {
00227             $this->_iOrderCnt = 0;
00228             if ($oUser = $this->getUser()) {
00229                 $this->_iOrderCnt = $oUser->getOrderCount();
00230             }
00231         }
00232 
00233         return $this->_iOrderCnt;
00234     }
00235 
00241     public function getArticleId()
00242     {
00243         if ($this->_sArticleId === null) {
00244             // passing wishlist information
00245             if ($sArticleId = oxRegistry::getConfig()->getRequestParameter('aid')) {
00246                 $this->_sArticleId = $sArticleId;
00247             }
00248         }
00249 
00250         return $this->_sArticleId;
00251     }
00252 
00258     public function getSearchParamForHtml()
00259     {
00260         if ($this->_sSearchParamForHtml === null) {
00261             $this->_sSearchParamForHtml = false;
00262             if ($this->getArticleId()) {
00263                 $this->_sSearchParamForHtml = oxRegistry::getConfig()->getRequestParameter('searchparam');
00264             }
00265         }
00266 
00267         return $this->_sSearchParamForHtml;
00268     }
00269 
00275     public function getSearchParam()
00276     {
00277         if ($this->_sSearchParam === null) {
00278             $this->_sSearchParam = false;
00279             if ($this->getArticleId()) {
00280                 $this->_sSearchParam = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true));
00281             }
00282         }
00283 
00284         return $this->_sSearchParam;
00285     }
00286 
00292     public function getListType()
00293     {
00294         if ($this->_sListType === null) {
00295             $this->_sListType = false;
00296             if ($this->getArticleId()) {
00297                 // searching in vendor #671
00298                 $this->_sListType = oxRegistry::getConfig()->getRequestParameter('listtype');
00299             }
00300         }
00301 
00302         return $this->_sListType;
00303     }
00304 
00310     public function getBreadCrumb()
00311     {
00312         $aPaths = array();
00313         $aPath = array();
00314         $oLang = oxRegistry::getLang();
00315         if ($oUser = $this->getUser()) {
00316             $iBaseLanguage = $oLang->getBaseLanguage();
00317             $sUsernameField = 'oxuser__oxusername';
00318 
00319             $aPath['title'] =
00320                 $oLang->translateString('MY_ACCOUNT', $iBaseLanguage, false) . " - " . $oUser->$sUsernameField->value;
00321         } else {
00322             $aPath['title'] = $oLang->translateString('LOGIN', $iBaseLanguage, false);
00323         }
00324         $aPath['link'] = $this->getLink();
00325         $aPaths[] = $aPath;
00326 
00327         return $aPaths;
00328     }
00329 
00335     public function getCompareItemsCnt()
00336     {
00337         $oCompare = oxNew("compare");
00338         $iCompItemsCnt = $oCompare->getCompareItemsCnt();
00339 
00340         return $iCompItemsCnt;
00341     }
00342 
00348     public function getTitle()
00349     {
00350         $sTitle = parent::getTitle();
00351 
00352         if ($this->getConfig()->getActiveView()->getClassName() == 'account') {
00353             $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
00354             $sTitle = oxRegistry::getLang()->translateString('PAGE_TITLE_ACCOUNT', $iBaseLanguage, false);
00355             if ($oUser = $this->getUser()) {
00356                 $sUsername = 'oxuser__oxusername';
00357                 $sTitle .= ' - "' . $oUser->$sUsername->value . '"';
00358             }
00359         }
00360 
00361         return $sTitle;
00362     }
00363 }