OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
account_password.php
Go to the documentation of this file.
1 <?php
2 
3 
13 {
14 
20  protected $_sThisTemplate = 'page/account/password.tpl';
21 
27  protected $_blPasswordChanged = false;
28 
36  public function render()
37  {
38 
40 
41  // is logged in ?
42  $oUser = $this->getUser();
43  if (!$oUser) {
44  return $this->_sThisTemplate = $this->_sThisLoginTemplate;
45  }
46 
47  return $this->_sThisTemplate;
48 
49  }
50 
56  public function changePassword()
57  {
58  if (!oxRegistry::getSession()->checkSessionChallenge()) {
59  return;
60  }
61 
62  $oUser = $this->getUser();
63  if (!$oUser) {
64  return;
65  }
66 
67  $sOldPass = oxRegistry::getConfig()->getRequestParameter('password_old', true);
68  $sNewPass = oxRegistry::getConfig()->getRequestParameter('password_new', true);
69  $sConfPass = oxRegistry::getConfig()->getRequestParameter('password_new_confirm', true);
70 
72  $oInputValidator = oxRegistry::get('oxInputValidator');
73  if (($oExcp = $oInputValidator->checkPassword($oUser, $sNewPass, $sConfPass, true))) {
74  switch ($oExcp->getMessage()) {
75  case 'ERROR_MESSAGE_INPUT_EMPTYPASS':
76  case 'ERROR_MESSAGE_PASSWORD_TOO_SHORT':
77  return oxRegistry::get("oxUtilsView")->addErrorToDisplay(
78  'ERROR_MESSAGE_PASSWORD_TOO_SHORT',
79  false,
80  true
81  );
82  default:
83  return oxRegistry::get("oxUtilsView")->addErrorToDisplay(
84  'ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH',
85  false,
86  true
87  );
88  }
89  }
90 
91  if (!$sOldPass || !$oUser->isSamePassword($sOldPass)) {
93  $oUtilsView = oxRegistry::get("oxUtilsView");
94 
95  return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_CURRENT_PASSWORD_INVALID', false, true);
96  }
97 
98  // testing passed - changing password
99  $oUser->setPassword($sNewPass);
100  if ($oUser->save()) {
101  $this->_blPasswordChanged = true;
102  // deleting user autologin cookies.
103  oxRegistry::get("oxUtilsServer")->deleteUserCookie($this->getConfig()->getShopId());
104  }
105  }
106 
112  public function isPasswordChanged()
113  {
115  }
116 
122  public function getBreadCrumb()
123  {
124  $aPaths = array();
125  $aPath = array();
126 
128  $oSeoEncoder = oxRegistry::get("oxSeoEncoder");
129  $oLang = oxRegistry::getLang();
130  $iBaseLanguage = $oLang->getBaseLanguage();
131  $aPath['title'] = $oLang->translateString('MY_ACCOUNT', $iBaseLanguage, false);
132  $aPath['link'] = $oSeoEncoder->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=account');
133  $aPaths[] = $aPath;
134 
135  $aPath['title'] = $oLang->translateString('CHANGE_PASSWORD', $iBaseLanguage, false);
136  $aPath['link'] = $this->getLink();
137  $aPaths[] = $aPath;
138 
139  return $aPaths;
140  }
141 }