OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
account_password.php
Go to the documentation of this file.
1 <?php
2 
3 
13 {
19  protected $_sThisTemplate = 'page/account/password.tpl';
20 
26  protected $_blPasswordChanged = false;
27 
35  public function render()
36  {
37 
39 
40  // is logged in ?
41  $oUser = $this->getUser();
42  if ( !$oUser ) {
43  return $this->_sThisTemplate = $this->_sThisLoginTemplate;
44  }
45 
46  return $this->_sThisTemplate;
47 
48  }
49 
55  public function changePassword()
56  {
57  if (!oxRegistry::getSession()->checkSessionChallenge()) {
58  return;
59  }
60 
61  $oUser = $this->getUser();
62  if ( !$oUser ) {
63  return;
64  }
65 
66  $sOldPass = oxConfig::getParameter( 'password_old', true );
67  $sNewPass = oxConfig::getParameter( 'password_new', true );
68  $sConfPass = oxConfig::getParameter( 'password_new_confirm', true );
69 
70  if ( ( $oExcp = $oUser->checkPassword( $sNewPass, $sConfPass, true ) ) ) {
71  switch ( $oExcp->getMessage() ) {
72  case 'ERROR_MESSAGE_INPUT_EMPTYPASS':
73  case 'ERROR_MESSAGE_PASSWORD_TOO_SHORT':
74  return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_PASSWORD_TOO_SHORT', false, true);
75  default:
76  return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH', false, true);
77  }
78  }
79 
80  if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
81  return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CURRENT_PASSWORD_INVALID', false, true);
82  }
83 
84  // testing passed - changing password
85  $oUser->setPassword( $sNewPass );
86  if ( $oUser->save() ) {
87  $this->_blPasswordChanged = true;
88  // deleting user autologin cookies.
89  oxRegistry::get("oxUtilsServer")->deleteUserCookie( $this->getConfig()->getShopId() );
90  }
91  }
92 
98  public function isPasswordChanged()
99  {
101  }
102 
108  public function getBreadCrumb()
109  {
110  $aPaths = array();
111  $aPath = array();
112 
113  $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false );
114  $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
115  $aPaths[] = $aPath;
116 
117  $aPath['title'] = oxRegistry::getLang()->translateString( 'CHANGE_PASSWORD', oxRegistry::getLang()->getBaseLanguage(), false );
118  $aPath['link'] = $this->getLink();
119  $aPaths[] = $aPath;
120 
121  return $aPaths;
122  }
123 }