forgotpwd.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class ForgotPwd extends oxUBase
00011 {
00016     protected $_sThisTemplate = 'forgotpwd.tpl';
00017 
00022     protected $_sForgotEmail = null;
00023 
00030     protected $_iViewIndexState = 1;
00031 
00037     protected $_blUpdateLinkStatus = null;
00038 
00048     public function forgotPassword()
00049     {
00050         $sEmail = oxConfig::getParameter( 'lgn_usr' );
00051         $this->_sForgotEmail = $sEmail;
00052         $oEmail = oxNew( 'oxemail' );
00053 
00054         // problems sending passwd reminder ?
00055         if ( !$sEmail || !$oEmail->sendForgotPwdEmail( $sEmail ) ) {
00056             oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRUNABLETOSEND', false, true);
00057             $this->_sForgotEmail = ' - ';
00058         }
00059     }
00060 
00067     public function updatePassword()
00068     {
00069         $sNewPass  = oxConfig::getParameter( 'password_new', true );
00070         $sConfPass = oxConfig::getParameter( 'password_new_confirm', true );
00071 
00072         if ( !$sNewPass || !$sConfPass ) {
00073             return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true);
00074         }
00075 
00076         if ( $sNewPass != $sConfPass ) {
00077             return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWDONOTMATCH', false, true);
00078         }
00079 
00080         if ( strlen($sNewPass) < 6 ||  strlen($sConfPass) < 6 ) {
00081             return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true);
00082         }
00083 
00084         // passwords are fine - updating and loggin user in
00085         $oUser = oxNew( 'oxuser' );
00086         if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) {
00087 
00088             // setting new pass ..
00089             $oUser->setPassword( $sNewPass );
00090 
00091             // resetting update pass params
00092             $oUser->setUpdateKey( true );
00093 
00094             // saving ..
00095             $oUser->save();
00096 
00097             // forcing user login
00098             oxSession::setVar( 'usr', $oUser->getId() );
00099             return 'forgotpwd?success=1';
00100         } else {
00101             // expired reminder
00102             return oxUtilsView::getInstance()->addErrorToDisplay( 'FORGOTPWD_ERRLINKEXPIRED', false, true );
00103         }
00104     }
00105 
00111     public function updateSuccess()
00112     {
00113         return (bool) oxConfig::getParameter( 'success' );
00114     }
00115 
00121     public function showUpdateScreen()
00122     {
00123         return (bool) $this->getUpdateId();
00124     }
00125 
00131     public function getUpdateId()
00132     {
00133         return oxConfig::getParameter( 'uid' );
00134     }
00135 
00141     public function isExpiredLink()
00142     {
00143         if ( ( $sKey = $this->getUpdateId() ) ) {
00144             $blExpired = oxNew( 'oxuser' )->isExpiredUpdateKey( $sKey );
00145         }
00146 
00147         return $blExpired;
00148     }
00149 
00156     public function render()
00157     {
00158         $this->_aViewData['sendForgotMail'] = $this->getForgotEmail();
00159 
00160         parent::render();
00161 
00162         // loading actions
00163         $this->_loadActions();
00164 
00165         return $this->_sThisTemplate;
00166     }
00167 
00173     public function getForgotEmail()
00174     {
00175         return $this->_sForgotEmail;
00176     }
00177 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5