OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
account.php
Go to the documentation of this file.
1 <?php
2 
12 class Account extends oxUBase
13 {
14 
20  protected $_iOrderCnt = null;
21 
27  protected $_sArticleId = null;
28 
34  protected $_sSearchParamForHtml = null;
35 
41  protected $_sSearchParam = null;
42 
48  protected $_sListType = null;
49 
55  protected $_sThisTemplate = 'page/account/dashboard.tpl';
56 
62  protected $_sThisLoginTemplate = 'page/account/login.tpl';
63 
69  protected $_sThisAltLoginTemplate = 'page/privatesales/login.tpl';
70 
77 
83  protected $_sMetaDescriptionIdent = 'oxstartmetadescription';
84 
90  protected $_sMetaKeywordsIdent = 'oxstartmetakeywords';
91 
97  protected $_blBargainAction = true;
98 
104  protected $_blShowTagCloud = false;
105 
106 
113  public function render()
114  {
115  parent::render();
116 
117  // performing redirect if needed
118  $this->redirectAfterLogin();
119 
120  // is logged in ?
121  $oUser = $this->getUser();
122  $sPasswordField = 'oxuser__oxpassword';
123  if (!$oUser || ($oUser && !$oUser->$sPasswordField->value) ||
124  ($this->isEnabledPrivateSales() && $oUser && (!$oUser->isTermsAccepted() || $this->confirmTerms()))
125  ) {
126  $this->_sThisTemplate = $this->_getLoginTemplate();
127  }
128 
129  return $this->_sThisTemplate;
130  }
131 
139  protected function _getLoginTemplate()
140  {
141  return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
142  }
143 
149  public function confirmTerms()
150  {
151  $blConfirm = oxRegistry::getConfig()->getRequestParameter("term");
152  if (!$blConfirm && $this->isEnabledPrivateSales()) {
153  $oUser = $this->getUser();
154  if ($oUser && !$oUser->isTermsAccepted()) {
155  $blConfirm = true;
156  }
157  }
158 
159  return $blConfirm;
160  }
161 
170  public function getNavigationParams()
171  {
172  $aParams = parent::getNavigationParams();
173 
174  // source class name
175  if ($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) {
176  $aParams['sourcecl'] = $sSource;
177  }
178 
179  if ($sSource = oxRegistry::getConfig()->getRequestParameter("anid")) {
180  $aParams['anid'] = $sSource;
181  }
182 
183  return $aParams;
184  }
185 
197  public function redirectAfterLogin()
198  {
199  // in case source class is provided - redirecting back to it with all default parameters
200  if (($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) &&
201  $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS
202  ) {
203 
204  $sRedirectUrl = $this->getConfig()->getShopUrl() . 'index.php?cl=' . rawurlencode($sSource);
205  // building redirect link
206 
207  foreach ($this->getNavigationParams() as $sName => $sValue) {
208  if ($sValue && $sName != "sourcecl") {
209  $sRedirectUrl .= '&' . rawurlencode($sName) . "=" . rawurlencode($sValue);
210  }
211  }
212 
214  $oUtilsUrl = oxRegistry::get("oxUtilsUrl");
215  return oxRegistry::getUtils()->redirect($oUtilsUrl->processUrl($sRedirectUrl), true, 302);
216  }
217  }
218 
224  public function getOrderCnt()
225  {
226  if ($this->_iOrderCnt === null) {
227  $this->_iOrderCnt = 0;
228  if ($oUser = $this->getUser()) {
229  $this->_iOrderCnt = $oUser->getOrderCount();
230  }
231  }
232 
233  return $this->_iOrderCnt;
234  }
235 
241  public function getArticleId()
242  {
243  if ($this->_sArticleId === null) {
244  // passing wishlist information
245  if ($sArticleId = oxRegistry::getConfig()->getRequestParameter('aid')) {
246  $this->_sArticleId = $sArticleId;
247  }
248  }
249 
250  return $this->_sArticleId;
251  }
252 
258  public function getSearchParamForHtml()
259  {
260  if ($this->_sSearchParamForHtml === null) {
261  $this->_sSearchParamForHtml = false;
262  if ($this->getArticleId()) {
263  $this->_sSearchParamForHtml = oxRegistry::getConfig()->getRequestParameter('searchparam');
264  }
265  }
266 
268  }
269 
275  public function getSearchParam()
276  {
277  if ($this->_sSearchParam === null) {
278  $this->_sSearchParam = false;
279  if ($this->getArticleId()) {
280  $this->_sSearchParam = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true));
281  }
282  }
283 
284  return $this->_sSearchParam;
285  }
286 
292  public function getListType()
293  {
294  if ($this->_sListType === null) {
295  $this->_sListType = false;
296  if ($this->getArticleId()) {
297  // searching in vendor #671
298  $this->_sListType = oxRegistry::getConfig()->getRequestParameter('listtype');
299  }
300  }
301 
302  return $this->_sListType;
303  }
304 
310  public function getBreadCrumb()
311  {
312  $aPaths = array();
313  $aPath = array();
314  $oLang = oxRegistry::getLang();
315  if ($oUser = $this->getUser()) {
316  $iBaseLanguage = $oLang->getBaseLanguage();
317  $sUsernameField = 'oxuser__oxusername';
318 
319  $aPath['title'] =
320  $oLang->translateString('MY_ACCOUNT', $iBaseLanguage, false) . " - " . $oUser->$sUsernameField->value;
321  } else {
322  $aPath['title'] = $oLang->translateString('LOGIN', $iBaseLanguage, false);
323  }
324  $aPath['link'] = $this->getLink();
325  $aPaths[] = $aPath;
326 
327  return $aPaths;
328  }
329 
335  public function getCompareItemsCnt()
336  {
337  $oCompare = oxNew("compare");
338  $iCompItemsCnt = $oCompare->getCompareItemsCnt();
339 
340  return $iCompItemsCnt;
341  }
342 
348  public function getTitle()
349  {
350  $sTitle = parent::getTitle();
351 
352  if ($this->getConfig()->getActiveView()->getClassName() == 'account') {
353  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
354  $sTitle = oxRegistry::getLang()->translateString('PAGE_TITLE_ACCOUNT', $iBaseLanguage, false);
355  if ($oUser = $this->getUser()) {
356  $sUsername = 'oxuser__oxusername';
357  $sTitle .= ' - "' . $oUser->$sUsername->value . '"';
358  }
359  }
360 
361  return $sTitle;
362  }
363 }