forgotpwd.php

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         // problems sending passwd reminder ?
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         $oUser = oxNew( 'oxuser' );
00084         if ( ( $oExcp = $oUser->checkPassword( $sNewPass, $sConfPass, true ) ) ) {
00085             switch ( $oExcp->getMessage() ) {
00086                 case 'EXCEPTION_INPUT_EMPTYPASS':
00087                 case 'EXCEPTION_INPUT_PASSTOOSHORT':
00088                     return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true);
00089                 default:
00090                     return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWDONOTMATCH', false, true);
00091             }
00092         }
00093 
00094         // passwords are fine - updating and loggin user in
00095         if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) {
00096 
00097             // setting new pass ..
00098             $oUser->setPassword( $sNewPass );
00099 
00100             // resetting update pass params
00101             $oUser->setUpdateKey( true );
00102 
00103             // saving ..
00104             $oUser->save();
00105 
00106             // forcing user login
00107             oxSession::setVar( 'usr', $oUser->getId() );
00108             return 'forgotpwd?success=1';
00109         } else {
00110             // expired reminder
00111             return oxUtilsView::getInstance()->addErrorToDisplay( 'FORGOTPWD_ERRLINKEXPIRED', false, true );
00112         }
00113     }
00114 
00120     public function updateSuccess()
00121     {
00122         return (bool) oxConfig::getParameter( 'success' );
00123     }
00124 
00130     public function showUpdateScreen()
00131     {
00132         return (bool) $this->getUpdateId();
00133     }
00134 
00140     public function getUpdateId()
00141     {
00142         return oxConfig::getParameter( 'uid' );
00143     }
00144 
00150     public function isExpiredLink()
00151     {
00152         if ( ( $sKey = $this->getUpdateId() ) ) {
00153             $blExpired = oxNew( 'oxuser' )->isExpiredUpdateId( $sKey );
00154         }
00155 
00156         return $blExpired;
00157     }
00158 
00164     public function getForgotEmail()
00165     {
00166         return $this->_sForgotEmail;
00167     }
00168 
00174     public function getBreadCrumb()
00175     {
00176         $aPaths = array();
00177         $aPath = array();
00178 
00179         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_FORGOTPWD_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
00180         $aPath['link']  = $this->getLink();
00181         $aPaths[] = $aPath;
00182 
00183         return $aPaths;
00184     }
00185 }