Go to the documentation of this file.00001 <?php
00002
00010 class ForgotPwd extends oxUBase
00011 {
00016 protected $_sThisTemplate = 'page/account/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 $iSuccess = false;
00067 if ( $sEmail ) {
00068 $iSuccess = $oEmail->sendForgotPwdEmail( $sEmail );
00069 }
00070 if ( $iSuccess !== true ) {
00071 $sError = ($iSuccess === false)? 'ERROR_MESSAGE_PASSWORD_EMAIL_INVALID' : 'MESSAGE_NOT_ABLE_TO_SEND_EMAIL';
00072 oxUtilsView::getInstance()->addErrorToDisplay($sError, false, true);
00073 $this->_sForgotEmail = false;
00074 }
00075 }
00076
00083 public function updatePassword()
00084 {
00085 $sNewPass = oxConfig::getParameter( 'password_new', true );
00086 $sConfPass = oxConfig::getParameter( 'password_new_confirm', true );
00087
00088 $oUser = oxNew( 'oxuser' );
00089 if ( ( $oExcp = $oUser->checkPassword( $sNewPass, $sConfPass, true ) ) ) {
00090 switch ( $oExcp->getMessage() ) {
00091 case 'EXCEPTION_INPUT_EMPTYPASS':
00092 case 'EXCEPTION_INPUT_PASSTOOSHORT':
00093 return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true);
00094 default:
00095 return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWDONOTMATCH', false, true);
00096 }
00097 }
00098
00099
00100 if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) {
00101
00102
00103 $oUser->setPassword( $sNewPass );
00104
00105
00106 $oUser->setUpdateKey( true );
00107
00108
00109 $oUser->save();
00110
00111
00112 oxSession::setVar( 'usr', $oUser->getId() );
00113 return 'forgotpwd?success=1';
00114 } else {
00115
00116 return oxUtilsView::getInstance()->addErrorToDisplay( 'FORGOTPWD_ERRLINKEXPIRED', false, true );
00117 }
00118 }
00119
00125 public function updateSuccess()
00126 {
00127 return (bool) oxConfig::getParameter( 'success' );
00128 }
00129
00135 public function showUpdateScreen()
00136 {
00137 return (bool) $this->getUpdateId();
00138 }
00139
00145 public function getUpdateId()
00146 {
00147 return oxConfig::getParameter( 'uid' );
00148 }
00149
00155 public function isExpiredLink()
00156 {
00157 if ( ( $sKey = $this->getUpdateId() ) ) {
00158 $blExpired = oxNew( 'oxuser' )->isExpiredUpdateId( $sKey );
00159 }
00160
00161 return $blExpired;
00162 }
00163
00169 public function getForgotEmail()
00170 {
00171 return $this->_sForgotEmail;
00172 }
00173
00179 public function getBreadCrumb()
00180 {
00181 $aPaths = array();
00182 $aPath = array();
00183
00184 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_FORGOTPWD_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
00185 $aPath['link'] = $this->getLink();
00186 $aPaths[] = $aPath;
00187
00188 return $aPaths;
00189 }
00190 }