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         $oUser = $this->getUser();
00058         if ( !$oUser ) {
00059             return;
00060         }
00061 
00062         $sOldPass  = oxConfig::getParameter( 'password_old' );
00063         $sNewPass  = oxConfig::getParameter( 'password_new' );
00064         $sConfPass = oxConfig::getParameter( 'password_new_confirm' );
00065 
00066         if ( ( $oExcp = $oUser->checkPassword( $sNewPass, $sConfPass, true ) ) ) {
00067             switch ( $oExcp->getMessage() ) {
00068                 case 'EXCEPTION_INPUT_EMPTYPASS':
00069                 case 'EXCEPTION_INPUT_PASSTOOSHORT':
00070                     return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00071                 default:
00072                     return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWDONOTMATCH', false, true);
00073             }
00074         }
00075 
00076         if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
00077             return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRINCORRECTCURRENTPASSW', false, true, 'user');
00078         }
00079 
00080         // testing passed - changing password
00081         $oUser->setPassword( $sNewPass );
00082         if ( $oUser->save() ) {
00083             $this->_blPasswordChanged = true;
00084         }
00085     }
00086 
00092     public function isPasswordChanged()
00093     {
00094         return $this->_blPasswordChanged;
00095     }
00096 
00102     public function getBreadCrumb()
00103     {
00104         $aPaths = array();
00105         $aPath = array();
00106 
00107         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false );
00108         $aPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00109         $aPaths[] = $aPath;
00110 
00111         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_PASSWORD_PERSONALSETTINGS', oxLang::getInstance()->getBaseLanguage(), false );
00112         $aPath['link']  = $this->getLink();
00113         $aPaths[] = $aPath;
00114 
00115         return $aPaths;
00116     }
00117 }