account_password.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00012 class Account_Password extends Account
00013 {
00014 
00020     protected $_sThisTemplate = 'page/account/password.tpl';
00021 
00027     protected $_blPasswordChanged = false;
00028 
00036     public function render()
00037     {
00038 
00039         parent::render();
00040 
00041         // is logged in ?
00042         $oUser = $this->getUser();
00043         if (!$oUser) {
00044             return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00045         }
00046 
00047         return $this->_sThisTemplate;
00048 
00049     }
00050 
00056     public function changePassword()
00057     {
00058         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00059             return;
00060         }
00061 
00062         $oUser = $this->getUser();
00063         if (!$oUser) {
00064             return;
00065         }
00066 
00067         $sOldPass = oxRegistry::getConfig()->getRequestParameter('password_old', true);
00068         $sNewPass = oxRegistry::getConfig()->getRequestParameter('password_new', true);
00069         $sConfPass = oxRegistry::getConfig()->getRequestParameter('password_new_confirm', true);
00070 
00072         $oInputValidator = oxRegistry::get('oxInputValidator');
00073         if (($oExcp = $oInputValidator->checkPassword($oUser, $sNewPass, $sConfPass, true))) {
00074             switch ($oExcp->getMessage()) {
00075                 case 'ERROR_MESSAGE_INPUT_EMPTYPASS':
00076                 case 'ERROR_MESSAGE_PASSWORD_TOO_SHORT':
00077                     return oxRegistry::get("oxUtilsView")->addErrorToDisplay(
00078                         'ERROR_MESSAGE_PASSWORD_TOO_SHORT',
00079                         false,
00080                         true
00081                     );
00082                 default:
00083                     return oxRegistry::get("oxUtilsView")->addErrorToDisplay(
00084                         'ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH',
00085                         false,
00086                         true
00087                     );
00088             }
00089         }
00090 
00091         if (!$sOldPass || !$oUser->isSamePassword($sOldPass)) {
00093             $oUtilsView = oxRegistry::get("oxUtilsView");
00094 
00095             return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_CURRENT_PASSWORD_INVALID', false, true);
00096         }
00097 
00098         // testing passed - changing password
00099         $oUser->setPassword($sNewPass);
00100         if ($oUser->save()) {
00101             $this->_blPasswordChanged = true;
00102             // deleting user autologin cookies.
00103             oxRegistry::get("oxUtilsServer")->deleteUserCookie($this->getConfig()->getShopId());
00104         }
00105     }
00106 
00112     public function isPasswordChanged()
00113     {
00114         return $this->_blPasswordChanged;
00115     }
00116 
00122     public function getBreadCrumb()
00123     {
00124         $aPaths = array();
00125         $aPath = array();
00126 
00128         $oSeoEncoder = oxRegistry::get("oxSeoEncoder");
00129         $oLang = oxRegistry::getLang();
00130         $iBaseLanguage = $oLang->getBaseLanguage();
00131         $aPath['title'] = $oLang->translateString('MY_ACCOUNT', $iBaseLanguage, false);
00132         $aPath['link'] = $oSeoEncoder->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=account');
00133         $aPaths[] = $aPath;
00134 
00135         $aPath['title'] = $oLang->translateString('CHANGE_PASSWORD', $iBaseLanguage, false);
00136         $aPath['link'] = $this->getLink();
00137         $aPaths[] = $aPath;
00138 
00139         return $aPaths;
00140     }
00141 }