OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
account.php
Go to the documentation of this file.
1 <?php
2 
12 class Account extends oxUBase
13 {
18  protected $_iOrderCnt = null;
19 
24  protected $_sArticleId = null;
25 
30  protected $_sSearchParamForHtml = null;
31 
36  protected $_sSearchParam = null;
37 
42  protected $_sListType = null;
43 
48  protected $_sThisTemplate = 'page/account/dashboard.tpl';
49 
54  protected $_sThisLoginTemplate = 'page/account/login.tpl';
55 
60  protected $_sThisAltLoginTemplate = 'page/privatesales/login.tpl';
61 
68 
74  protected $_sMetaDescriptionIdent = 'oxstartmetadescription';
75 
81  protected $_sMetaKeywordsIdent = 'oxstartmetakeywords';
82 
87  protected $_blBargainAction = true;
88 
93  protected $_blShowTagCloud = false;
94 
95 
102  public function render()
103  {
104  parent::render();
105 
106  // performing redirect if needed
107  $this->redirectAfterLogin();
108 
109  // is logged in ?
110  $oUser = $this->getUser();
111  if ( !$oUser || ( $oUser && !$oUser->oxuser__oxpassword->value ) ||
112  ( $this->isEnabledPrivateSales() && $oUser && ( !$oUser->isTermsAccepted() || $this->confirmTerms() ) ) ) {
113  $this->_sThisTemplate = $this->_getLoginTemplate();
114  }
115 
116  return $this->_sThisTemplate;
117  }
118 
126  protected function _getLoginTemplate()
127  {
128  return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
129  }
130 
136  public function confirmTerms()
137  {
138  $blConfirm = oxConfig::getParameter( "term" );
139  if ( !$blConfirm && $this->isEnabledPrivateSales() ) {
140  $oUser = $this->getUser();
141  if ( $oUser && !$oUser->isTermsAccepted() ) {
142  $blConfirm = true;
143  }
144  }
145 
146  return $blConfirm;
147  }
148 
157  public function getNavigationParams()
158  {
159  $aParams = parent::getNavigationParams();
160 
161  // source class name
162  if ( $sSource = oxConfig::getParameter( "sourcecl" ) ) {
163  $aParams['sourcecl'] = $sSource;
164  }
165 
166  if ( $sSource = oxConfig::getParameter( "anid" ) ) {
167  $aParams['anid'] = $sSource;
168  }
169 
170  return $aParams;
171  }
172 
184  public function redirectAfterLogin()
185  {
186  // in case source class is provided - redirecting back to it with all default parameters
187  if ( ( $sSource = oxConfig::getParameter( "sourcecl" ) ) &&
188  $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS ) {
189 
190  $sRedirectUrl = $this->getConfig()->getShopUrl().'index.php?cl='.rawurlencode( $sSource );
191  // building redirect link
192 
193  foreach ( $this->getNavigationParams() as $sName => $sValue ) {
194  if ( $sValue && $sName != "sourcecl" ) {
195  $sRedirectUrl .= '&'.rawurlencode( $sName ) . "=" . rawurlencode( $sValue );
196  }
197  }
198  return oxRegistry::getUtils()->redirect( oxRegistry::get("oxUtilsUrl")->processUrl( $sRedirectUrl ), true, 302 );
199  }
200  }
201 
207  public function getOrderCnt()
208  {
209  if ( $this->_iOrderCnt === null ) {
210  $this->_iOrderCnt = 0;
211  if ( $oUser = $this->getUser() ) {
212  $this->_iOrderCnt = $oUser->getOrderCount();
213  }
214  }
215  return $this->_iOrderCnt;
216  }
217 
223  public function getArticleId()
224  {
225  if ( $this->_sArticleId === null) {
226  // passing wishlist information
227  if ( $sArticleId = oxConfig::getParameter('aid') ) {
228  $this->_sArticleId = $sArticleId;
229  }
230  }
231  return $this->_sArticleId;
232  }
233 
239  public function getSearchParamForHtml()
240  {
241  if ( $this->_sSearchParamForHtml === null ) {
242  $this->_sSearchParamForHtml = false;
243  if ( $this->getArticleId() ) {
244  $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
245  }
246  }
248  }
249 
255  public function getSearchParam()
256  {
257  if ( $this->_sSearchParam === null ) {
258  $this->_sSearchParam = false;
259  if ( $this->getArticleId() ) {
260  $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
261  }
262  }
263  return $this->_sSearchParam;
264  }
265 
271  public function getListType()
272  {
273  if ( $this->_sListType === null ) {
274  $this->_sListType = false;
275  if ( $this->getArticleId() ) {
276  // searching in vendor #671
277  $this->_sListType = oxConfig::getParameter( 'listtype' );
278  }
279  }
280  return $this->_sListType;
281  }
282 
288  public function getBreadCrumb()
289  {
290  $aPaths = array();
291  $aPath = array();
292  if ( $oUser = $this->getUser() ) {
293  $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false ) . " - " . $oUser->oxuser__oxusername->value;
294  } else {
295  $aPath['title'] = oxRegistry::getLang()->translateString( 'LOGIN', oxRegistry::getLang()->getBaseLanguage(), false );
296  }
297  $aPath['link'] = $this->getLink();
298  $aPaths[] = $aPath;
299  return $aPaths;
300  }
301 
307  public function getCompareItemsCnt()
308  {
309  $oCompare = oxNew( "compare" );
310  $iCompItemsCnt = $oCompare->getCompareItemsCnt();
311  return $iCompItemsCnt;
312  }
313 }