OXID eShop CE  4.10.2
 All Classes Namespaces 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 
106  protected $_blShowTagCloud = false;
107 
108 
115  public function render()
116  {
117  parent::render();
118 
119  // performing redirect if needed
120  $this->redirectAfterLogin();
121 
122  // is logged in ?
123  $oUser = $this->getUser();
124  $sPasswordField = 'oxuser__oxpassword';
125  if (!$oUser || ($oUser && !$oUser->$sPasswordField->value) ||
126  ($this->isEnabledPrivateSales() && $oUser && (!$oUser->isTermsAccepted() || $this->confirmTerms()))
127  ) {
128  $this->_sThisTemplate = $this->_getLoginTemplate();
129  }
130 
131  return $this->_sThisTemplate;
132  }
133 
141  protected function _getLoginTemplate()
142  {
143  return $this->isEnabledPrivateSales() ? $this->_sThisAltLoginTemplate : $this->_sThisLoginTemplate;
144  }
145 
151  public function confirmTerms()
152  {
153  $blConfirm = oxRegistry::getConfig()->getRequestParameter("term");
154  if (!$blConfirm && $this->isEnabledPrivateSales()) {
155  $oUser = $this->getUser();
156  if ($oUser && !$oUser->isTermsAccepted()) {
157  $blConfirm = true;
158  }
159  }
160 
161  return $blConfirm;
162  }
163 
172  public function getNavigationParams()
173  {
174  $aParams = parent::getNavigationParams();
175 
176  // source class name
177  if ($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) {
178  $aParams['sourcecl'] = $sSource;
179  }
180 
181  if ($sSource = oxRegistry::getConfig()->getRequestParameter("anid")) {
182  $aParams['anid'] = $sSource;
183  }
184 
185  return $aParams;
186  }
187 
199  public function redirectAfterLogin()
200  {
201  // in case source class is provided - redirecting back to it with all default parameters
202  if (($sSource = oxRegistry::getConfig()->getRequestParameter("sourcecl")) &&
203  $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS
204  ) {
205 
206  $sRedirectUrl = $this->getConfig()->getShopUrl() . 'index.php?cl=' . rawurlencode($sSource);
207  // building redirect link
208 
209  foreach ($this->getNavigationParams() as $sName => $sValue) {
210  if ($sValue && $sName != "sourcecl") {
211  $sRedirectUrl .= '&' . rawurlencode($sName) . "=" . rawurlencode($sValue);
212  }
213  }
214 
216  $oUtilsUrl = oxRegistry::get("oxUtilsUrl");
217  return oxRegistry::getUtils()->redirect($oUtilsUrl->processUrl($sRedirectUrl), true, 302);
218  }
219  }
220 
226  public function getOrderCnt()
227  {
228  if ($this->_iOrderCnt === null) {
229  $this->_iOrderCnt = 0;
230  if ($oUser = $this->getUser()) {
231  $this->_iOrderCnt = $oUser->getOrderCount();
232  }
233  }
234 
235  return $this->_iOrderCnt;
236  }
237 
243  public function getArticleId()
244  {
245  if ($this->_sArticleId === null) {
246  // passing wishlist information
247  if ($sArticleId = oxRegistry::getConfig()->getRequestParameter('aid')) {
248  $this->_sArticleId = $sArticleId;
249  }
250  }
251 
252  return $this->_sArticleId;
253  }
254 
260  public function getSearchParamForHtml()
261  {
262  if ($this->_sSearchParamForHtml === null) {
263  $this->_sSearchParamForHtml = false;
264  if ($this->getArticleId()) {
265  $this->_sSearchParamForHtml = oxRegistry::getConfig()->getRequestParameter('searchparam');
266  }
267  }
268 
270  }
271 
277  public function getSearchParam()
278  {
279  if ($this->_sSearchParam === null) {
280  $this->_sSearchParam = false;
281  if ($this->getArticleId()) {
282  $this->_sSearchParam = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true));
283  }
284  }
285 
286  return $this->_sSearchParam;
287  }
288 
294  public function getListType()
295  {
296  if ($this->_sListType === null) {
297  $this->_sListType = false;
298  if ($this->getArticleId()) {
299  // searching in vendor #671
300  $this->_sListType = oxRegistry::getConfig()->getRequestParameter('listtype');
301  }
302  }
303 
304  return $this->_sListType;
305  }
306 
312  public function getBreadCrumb()
313  {
314  $aPaths = array();
315  $aPath = array();
316  $oLang = oxRegistry::getLang();
317  if ($oUser = $this->getUser()) {
318  $iBaseLanguage = $oLang->getBaseLanguage();
319  $sUsernameField = 'oxuser__oxusername';
320 
321  $aPath['title'] =
322  $oLang->translateString('MY_ACCOUNT', $iBaseLanguage, false) . " - " . $oUser->$sUsernameField->value;
323  } else {
324  $aPath['title'] = $oLang->translateString('LOGIN', $iBaseLanguage, false);
325  }
326  $aPath['link'] = $this->getLink();
327  $aPaths[] = $aPath;
328 
329  return $aPaths;
330  }
331 
337  public function getCompareItemsCnt()
338  {
339  $oCompare = oxNew("compare");
340  $iCompItemsCnt = $oCompare->getCompareItemsCnt();
341 
342  return $iCompItemsCnt;
343  }
344 
350  public function getTitle()
351  {
352  $sTitle = parent::getTitle();
353 
354  if ($this->getConfig()->getActiveView()->getClassName() == 'account') {
355  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
356  $sTitle = oxRegistry::getLang()->translateString('PAGE_TITLE_ACCOUNT', $iBaseLanguage, false);
357  if ($oUser = $this->getUser()) {
358  $sUsername = 'oxuser__oxusername';
359  $sTitle .= ' - "' . $oUser->$sUsername->value . '"';
360  }
361  }
362 
363  return $sTitle;
364  }
365 }