00001 <?php
00002
00010 class ForgotPwd extends oxUBase
00011 {
00016 protected $_sThisTemplate = 'forgotpwd.tpl';
00017
00022 protected $_sForgotEmail = null;
00023
00029 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00030
00036 protected $_blUpdateLinkStatus = null;
00037
00042 protected $_blTop5Action = true;
00043
00048 protected $_blBargainAction = true;
00049
00059 public function forgotPassword()
00060 {
00061 $sEmail = oxConfig::getParameter( 'lgn_usr' );
00062 $this->_sForgotEmail = $sEmail;
00063 $oEmail = oxNew( 'oxemail' );
00064
00065
00066 if ( !$sEmail || !$oEmail->sendForgotPwdEmail( $sEmail ) ) {
00067 oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRUNABLETOSEND', false, true);
00068 $this->_sForgotEmail = false;
00069 }
00070 }
00071
00078 public function updatePassword()
00079 {
00080 $sNewPass = oxConfig::getParameter( 'password_new', true );
00081 $sConfPass = oxConfig::getParameter( 'password_new_confirm', true );
00082
00083 try {
00084 $oUser = oxNew( 'oxuser' );
00085 $oUser->checkPassword( $sNewPass, $sConfPass, true );
00086 } catch ( Exception $oExcp ) {
00087 switch ( $oExcp->getMessage() ) {
00088 case 'EXCEPTION_INPUT_EMPTYPASS':
00089 case 'EXCEPTION_INPUT_PASSTOOSHORT':
00090 return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true);
00091 default:
00092 return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWDONOTMATCH', false, true);
00093 }
00094 }
00095
00096
00097 if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) {
00098
00099
00100 $oUser->setPassword( $sNewPass );
00101
00102
00103 $oUser->setUpdateKey( true );
00104
00105
00106 $oUser->save();
00107
00108
00109 oxSession::setVar( 'usr', $oUser->getId() );
00110 return 'forgotpwd?success=1';
00111 } else {
00112
00113 return oxUtilsView::getInstance()->addErrorToDisplay( 'FORGOTPWD_ERRLINKEXPIRED', false, true );
00114 }
00115 }
00116
00122 public function updateSuccess()
00123 {
00124 return (bool) oxConfig::getParameter( 'success' );
00125 }
00126
00132 public function showUpdateScreen()
00133 {
00134 return (bool) $this->getUpdateId();
00135 }
00136
00142 public function getUpdateId()
00143 {
00144 return oxConfig::getParameter( 'uid' );
00145 }
00146
00152 public function isExpiredLink()
00153 {
00154 if ( ( $sKey = $this->getUpdateId() ) ) {
00155 $blExpired = oxNew( 'oxuser' )->isExpiredUpdateId( $sKey );
00156 }
00157
00158 return $blExpired;
00159 }
00160
00167 public function render()
00168 {
00169 $this->_aViewData['sendForgotMail'] = $this->getForgotEmail();
00170
00171 parent::render();
00172
00173
00174 $this->_loadActions();
00175
00176 return $this->_sThisTemplate;
00177 }
00178
00184 public function getForgotEmail()
00185 {
00186 return $this->_sForgotEmail;
00187 }
00188 }