Go to the documentation of this file.00001 <?php
00002
00003
00012 class Account_Password extends Account
00013 {
00019 protected $_sThisTemplate = 'account_password.tpl';
00020
00026 protected $_blPasswordChanged = false;
00027
00033 protected $_blHasPassword = null;
00034
00042 public function render()
00043 {
00044 parent::render();
00045
00046
00047 $this->_aViewData['blpasswordchanged'] = $this->isPasswordChanged();
00048
00049
00050 $oUser = $this->getUser();
00051 if ( !$oUser ) {
00052 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00053 }
00054
00055 return $this->_sThisTemplate;
00056 }
00057
00063 public function changePassword()
00064 {
00065 $oUser = $this->getUser();
00066 if ( !$oUser ) {
00067 return;
00068 }
00069
00070 $sOldPass = oxConfig::getParameter( 'password_old' );
00071 $sNewPass = oxConfig::getParameter( 'password_new' );
00072 $sConfPass = oxConfig::getParameter( 'password_new_confirm' );
00073
00074 try {
00075 $oUser->checkPassword( $sNewPass, $sConfPass, true );
00076 } catch ( Exception $oExcp ) {
00077 switch ( $oExcp->getMessage() ) {
00078 case 'EXCEPTION_INPUT_EMPTYPASS':
00079 case 'EXCEPTION_INPUT_PASSTOOSHORT':
00080 return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00081 default:
00082 return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWDONOTMATCH', false, true);
00083 }
00084 }
00085
00086 if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
00087 return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRINCORRECTCURRENTPASSW', false, true, 'user');
00088 }
00089
00090
00091 $oUser->setPassword( $sNewPass );
00092 if ( $oUser->save() ) {
00093 $this->_blPasswordChanged = true;
00094 }
00095 }
00096
00102 public function isPasswordChanged()
00103 {
00104 return $this->_blPasswordChanged;
00105 }
00106
00112 public function hasPassword()
00113 {
00114 if ( $this->_blHasPassword === null ) {
00115 $this->_blHasPassword = true;
00116 if ( ( $oUser = $this->getUser() ) ) {
00117 if ( $oUser->oxuser__oxisopenid->value == 1 && strpos( $oUser->oxuser__oxpassword->value, 'openid_' ) === 0 ) {
00118 $this->_blHasPassword = false;
00119 }
00120 }
00121 }
00122 return $this->_blHasPassword;
00123 }
00124 }