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 = 'account_password.tpl';
00021 
00027     protected $_blPasswordChanged = false;
00028 
00036     public function render()
00037     {
00038         parent::render();
00039         //T2008-07-30
00040         //to maintain compatibility we still set the old template variable using new getter in render
00041         $this->_aViewData['blpasswordchanged'] = $this->isPasswordChanged();
00042 
00043         // is logged in ?
00044         $oUser = $this->getUser();
00045         if ( !$oUser ) {
00046             return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00047         }
00048 
00049         return $this->_sThisTemplate;
00050     }
00051 
00057     public function changePassword()
00058     {
00059         $oUser = $this->getUser();
00060         if ( !$oUser ) {
00061             return;
00062         }
00063 
00064         $sOldPass  = oxConfig::getParameter( 'password_old' );
00065         $sNewPass  = oxConfig::getParameter( 'password_new' );
00066         $sConfPass = oxConfig::getParameter( 'password_new_confirm' );
00067 
00068         if ( !$sNewPass || !$sConfPass ) {
00069             oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00070             return;
00071         }
00072 
00073         if ( $sNewPass != $sConfPass ) {
00074             oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWDONOTMATCH', false, true);
00075             return;
00076         }
00077 
00078         if ( strlen($sNewPass) < 6 ||  strlen($sConfPass) < 6 ) {
00079             oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00080             return;
00081         }
00082 
00083         if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
00084             oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRINCORRECTCURRENTPASSW', false, true, 'user');
00085             return;
00086         }
00087 
00088         // testing passed - changing password
00089         $oUser->setPassword( $sNewPass );
00090         if ( $oUser->save() ) {
00091             $this->_blPasswordChanged = true;
00092         }
00093 
00094     }
00095 
00101     public function isPasswordChanged()
00102     {
00103         return $this->_blPasswordChanged;
00104     }
00105 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5