00001 <?php 00002 00007 class Register extends User 00008 { 00014 protected $_sThisTemplate = 'register.tpl'; 00015 00021 protected $_sSuccessTemplate = 'register_success.tpl'; 00022 00028 protected $_sConfirmTemplate = 'register_confirm.tpl'; 00029 00034 protected $_blIsOrderStep = false; 00035 00041 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW; 00042 00049 public function render() 00050 { 00051 parent::render(); 00052 00053 // checking registration status 00054 if ( $this->getConfig()->getConfigParam( 'blPsLoginEnabled' ) && $this->isConfirmed() ) { 00055 $sTemplate = $this->_sConfirmTemplate; 00056 } elseif ( $this->getRegistrationStatus() ) { 00057 //for older templates 00058 $this->_aViewData['error'] = $this->getRegistrationError(); 00059 $this->_aViewData['success'] = $this->getRegistrationStatus(); 00060 $sTemplate = $this->_sSuccessTemplate; 00061 } else { 00062 $this->_aViewData['aMustFillFields'] = $this->getMustFillFields(); 00063 $sTemplate = $this->_sThisTemplate; 00064 } 00065 00066 return $sTemplate; 00067 } 00068 00074 public function getRegistrationError() 00075 { 00076 return oxConfig::getParameter( 'newslettererror' ); 00077 } 00078 00084 public function getRegistrationStatus() 00085 { 00086 return oxConfig::getParameter( 'success' ); 00087 } 00088 00094 public function getDelAddress() 00095 { 00096 // is logged in ? 00097 if ( $this->_oDelAddress === null ) { 00098 $this->_oDelAddress = false; 00099 00100 if ( $oUser = $this->getUser() ) { 00101 $sAddressId = $oUser->getSelectedAddress(); 00102 if ( $sAddressId && $sAddressId != '-1' ) { 00103 $this->_oDelAddress = oxNew( 'oxaddress' ); 00104 $this->_oDelAddress->load( $sAddressId ); 00105 } 00106 } 00107 } 00108 00109 return $this->_oDelAddress; 00110 } 00111 00119 protected function _addFakeAddress( $oAddresses ) 00120 { 00121 } 00122 00130 public function isFieldRequired( $sField ) 00131 { 00132 if ( $aMustFillFields = $this->getMustFillFields() ) { 00133 if ( isset( $aMustFillFields[$sField] ) ) { 00134 return true; 00135 } 00136 } 00137 00138 return false; 00139 } 00140 00148 public function confirmRegistration() 00149 { 00150 $oUser = oxNew( 'oxuser' ); 00151 if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) { 00152 00153 // resetting update key parameter 00154 $oUser->setUpdateKey( true ); 00155 00156 // saving .. 00157 $oUser->oxuser__oxactive = new oxField( 1 ); 00158 $oUser->save(); 00159 00160 // forcing user login 00161 oxSession::setVar( 'usr', $oUser->getId() ); 00162 00163 // redirecting to confirmation page 00164 return 'register?confirmstate=1'; 00165 } else { 00166 // confirmation failed 00167 oxUtilsView::getInstance()->addErrorToDisplay( 'REGISTER_ERRLINKEXPIRED', false, true ); 00168 00169 // redirecting to confirmation page 00170 return 'account'; 00171 } 00172 } 00173 00179 public function getUpdateId() 00180 { 00181 return oxConfig::getParameter( 'uid' ); 00182 } 00183 00189 public function isConfirmed() 00190 { 00191 return (bool) oxConfig::getParameter( "confirmstate" ); 00192 } 00193 00194 }