account_password.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00012 class Account_Password extends Account
00013 {
00019     protected $_sThisTemplate = 'page/account/password.tpl';
00020 
00026     protected $_blPasswordChanged = false;
00027 
00035     public function render()
00036     {
00037 
00038         parent::render();
00039 
00040         // is logged in ?
00041         $oUser = $this->getUser();
00042         if ( !$oUser ) {
00043             return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00044         }
00045 
00046         return $this->_sThisTemplate;
00047 
00048     }
00049 
00055     public function changePassword()
00056     {
00057         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00058             return;
00059         }
00060 
00061         $oUser = $this->getUser();
00062         if ( !$oUser ) {
00063             return;
00064         }
00065 
00066         $sOldPass  = oxConfig::getParameter( 'password_old', true );
00067         $sNewPass  = oxConfig::getParameter( 'password_new', true );
00068         $sConfPass = oxConfig::getParameter( 'password_new_confirm', true );
00069 
00070         if ( ( $oExcp = $oUser->checkPassword( $sNewPass, $sConfPass, true ) ) ) {
00071             switch ( $oExcp->getMessage() ) {
00072                 case 'ERROR_MESSAGE_INPUT_EMPTYPASS':
00073                 case 'ERROR_MESSAGE_PASSWORD_TOO_SHORT':
00074                     return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_PASSWORD_TOO_SHORT', false, true);
00075                 default:
00076                     return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH', false, true);
00077             }
00078         }
00079         
00080         if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
00081             return oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CURRENT_PASSWORD_INVALID', false, true);
00082         }
00083 
00084         // testing passed - changing password
00085         $oUser->setPassword( $sNewPass );
00086         if ( $oUser->save() ) {
00087             $this->_blPasswordChanged = true;
00088             // deleting user autologin cookies.
00089             oxRegistry::get("oxUtilsServer")->deleteUserCookie( $this->getConfig()->getShopId() );
00090         }
00091     }
00092 
00098     public function isPasswordChanged()
00099     {
00100         return $this->_blPasswordChanged;
00101     }
00102 
00108     public function getBreadCrumb()
00109     {
00110         $aPaths = array();
00111         $aPath = array();
00112 
00113         $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false );
00114         $aPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00115         $aPaths[] = $aPath;
00116 
00117         $aPath['title'] = oxRegistry::getLang()->translateString( 'CHANGE_PASSWORD', oxRegistry::getLang()->getBaseLanguage(), false );
00118         $aPath['link']  = $this->getLink();
00119         $aPaths[] = $aPath;
00120 
00121         return $aPaths;
00122     }
00123 }