00001 <?php
00002
00003
00012 class Account_Password extends Account
00013 {
00014
00020 protected $_sThisTemplate = 'account_password.tpl';
00021
00027 protected $_blPasswordChanged = false;
00028
00034 protected $_blHasPassword = true;
00035
00043 public function render()
00044 {
00045 parent::render();
00046
00047
00048 $this->_aViewData['blpasswordchanged'] = $this->isPasswordChanged();
00049
00050
00051 $oUser = $this->getUser();
00052 if ( !$oUser ) {
00053 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00054 }
00055 if ( $oUser->oxuser__oxisopenid->value == 1 && strpos( $oUser->oxuser__oxpassword->value, 'openid_' ) === 0 ) {
00056 $this->_blHasPassword = false;
00057 }
00058
00059 return $this->_sThisTemplate;
00060 }
00061
00067 public function changePassword()
00068 {
00069 $oUser = $this->getUser();
00070 if ( !$oUser ) {
00071 return;
00072 }
00073
00074 $sOldPass = oxConfig::getParameter( 'password_old' );
00075 $sNewPass = oxConfig::getParameter( 'password_new' );
00076 $sConfPass = oxConfig::getParameter( 'password_new_confirm' );
00077
00078 if ( !$sNewPass || !$sConfPass ) {
00079 oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00080 return;
00081 }
00082
00083 if ( $sNewPass != $sConfPass ) {
00084 oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWDONOTMATCH', false, true);
00085 return;
00086 }
00087
00088 if ( strlen($sNewPass) < 6 || strlen($sConfPass) < 6 ) {
00089 oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true);
00090 return;
00091 }
00092
00093 if ( !$sOldPass || !$oUser->isSamePassword( $sOldPass ) ) {
00094 oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRINCORRECTCURRENTPASSW', false, true, 'user');
00095 return;
00096 }
00097
00098
00099 $oUser->setPassword( $sNewPass );
00100 if ( $oUser->save() ) {
00101 $this->_blPasswordChanged = true;
00102 }
00103
00104 }
00105
00111 public function isPasswordChanged()
00112 {
00113 return $this->_blPasswordChanged;
00114 }
00115
00121 public function hasPassword()
00122 {
00123 return $this->_blHasPassword;
00124 }
00125 }